/* STARTPLAY GAMES — RICOSHET premium host shell v1.
   Canonical splash/field pixels, geometry and gameplay remain untouched. */

@font-face {
  font-family: "Nunito";
  src: url("assets/fonts/Nunito-variable.ttf") format("truetype");
  font-weight: 200 1000;
  font-style: normal;
  font-display: block;
}

:root {
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --safe-top: max(var(--sat-host, 0px), var(--sat));
  --safe-right: max(var(--sar-host, 0px), var(--sar));
  --safe-bottom: max(var(--sab-host, 0px), var(--sab));
  --safe-left: max(var(--sal-host, 0px), var(--sal));
  --bg-0: #08100b;
  --bg-1: #0d1810;
  --bg-2: #142219;
  --leaf: #edf5e5;
  --leaf-soft: #cbd9c2;
  --leaf-dim: #99aa94;
  --gold: #e8c96f;
  --gold-hi: #f6df9a;
  --gold-deep: #8f6e2d;
  --glass: rgba(11, 19, 13, 0.82);
  --glass-strong: rgba(8, 14, 10, 0.96);
  --hairline: rgba(232, 201, 111, 0.24);
  --hairline-hi: rgba(246, 223, 154, 0.44);
  --shadow: rgba(0, 0, 0, 0.46);
  --ui-font: "Nunito", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  width: 100%;
  min-width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--leaf);
  font-family: var(--ui-font);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
button, select, input { font: inherit; }
button, summary, select { -webkit-tap-highlight-color: transparent; }
button[hidden], [hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.shell-root {
  width: 100vw;
  height: 100dvh;
  padding:
    calc(0.45rem + var(--safe-top))
    calc(0.5rem + var(--safe-right))
    calc(0.45rem + var(--safe-bottom))
    calc(0.5rem + var(--safe-left));
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 32%, rgba(74, 112, 62, 0.24), transparent 39%),
    radial-gradient(circle at 12% 88%, rgba(44, 78, 42, 0.22), transparent 34%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 42%, var(--bg-0) 100%);
}

.game-shell {
  position: relative;
  width: min(100%, 27rem);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
}

.stage-stack {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stage-wrap {
  position: relative;
  width: min(100%, calc((100dvh - 5.9rem - var(--safe-top) - var(--safe-bottom)) * 941 / 1673));
  aspect-ratio: 941 / 1673;
  max-height: calc(100dvh - 5.9rem - var(--safe-top) - var(--safe-bottom));
  overflow: visible;
  border-radius: 0;
  background: #120e09;
  box-shadow:
    0 0 0 1px var(--hairline),
    0 22px 54px var(--shadow);
  touch-action: none;
}
#field {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.feedback-layer {
  position: relative;
  z-index: 24;
  width: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.feedback-toast {
  margin: 0 0 0.38rem;
  max-width: 100%;
  padding: 0.5rem 0.78rem;
  border: 1px solid var(--hairline);
  border-radius: 0.95rem;
  background: rgba(8, 15, 10, 0.92);
  box-shadow: 0 10px 24px rgba(0,0,0,0.26);
  color: var(--leaf);
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.25;
  text-align: center;
  animation: toast-in 180ms cubic-bezier(.2,.8,.2,1);
}
.hint-toast { color: #f3e0a4; }
.audio-toast { color: var(--leaf-soft); }
.status-toast { color: var(--leaf); }
.status-toast.status-error {
  color: #ffd8c4;
  border-color: rgba(238, 151, 110, 0.36);
}
.status-toast.status-success {
  color: var(--gold-hi);
  border-color: var(--hairline-hi);
}
.status-toast.status-paused {
  color: var(--leaf-soft);
  border-color: rgba(237,245,229,0.18);
}
.feedback-toast.is-receding {
  animation: toast-out 180ms cubic-bezier(.4,0,.8,.2) forwards;
}

.control-dock {
  width: 100%;
  padding: 0.38rem;
  border: 1px solid var(--hairline);
  border-radius: 1.18rem;
  background: linear-gradient(180deg, rgba(20, 31, 23, 0.88), rgba(9, 16, 11, 0.92));
  box-shadow:
    0 12px 30px rgba(0,0,0,0.28),
    0 1px 0 rgba(255,255,255,0.04) inset;
  backdrop-filter: blur(16px) saturate(115%);
}
.control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 0.36rem;
  align-items: center;
}
.control,
.level-control select,
.utility-menu summary {
  min-height: 48px;
  border-radius: 0.92rem;
  border: 1px solid transparent;
  font-family: var(--ui-font);
  font-size: 0.94rem;
  font-weight: 760;
  line-height: 1;
  letter-spacing: 0.005em;
  transition:
    transform 110ms ease,
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease;
}
.control {
  min-width: 48px;
  padding: 0.68rem 0.86rem;
  cursor: pointer;
}
.control:hover,
.utility-menu summary:hover,
.level-control select:hover {
  border-color: var(--hairline-hi);
}
.control:active,
.utility-menu summary:active {
  transform: translateY(1px) scale(0.985);
}
.control:focus-visible,
.level-control select:focus-visible,
.utility-menu summary:focus-visible,
.panel-action:focus-visible,
.audio-setting-row input:focus-visible,
.audio-mute input:focus-visible {
  outline: 2px solid #f8ecc2;
  outline-offset: 2px;
}

.control-primary {
  grid-column: 1 / -1;
  color: #182114;
  background: linear-gradient(180deg, var(--gold-hi), #dfbb5f);
  border-color: rgba(255,255,255,0.22);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.34) inset,
    0 8px 20px rgba(143,110,45,0.2);
  font-weight: 850;
}
.control-secondary {
  color: var(--leaf);
  background: rgba(237, 245, 229, 0.055);
  border-color: rgba(237,245,229,0.10);
}
.control-secondary:hover { background: rgba(237,245,229,0.09); }
.control:disabled,
.panel-action:disabled,
.level-control select:disabled {
  cursor: default;
  opacity: 0.46;
  transform: none;
  box-shadow: none;
}

.level-control {
  min-width: 0;
  display: block;
}
.level-control select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 0.65rem 2rem 0.65rem 0.82rem;
  appearance: none;
  color: var(--leaf);
  background-color: rgba(5, 11, 7, 0.34);
  border-color: rgba(232,201,111,0.19);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--gold) 50%),
    linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) 50%,
    calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}

.utility-menu {
  position: relative;
  min-width: 48px;
}
.utility-menu summary {
  min-width: 48px;
  padding: 0 0.74rem;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--leaf-soft);
  background: rgba(237,245,229,0.035);
  border-color: rgba(237,245,229,0.08);
  cursor: pointer;
}
.utility-menu summary::-webkit-details-marker { display: none; }
.menu-long { display: none; }
.menu-short {
  transform: translateY(-0.12rem);
  font-size: 1.15rem;
  letter-spacing: 0.08em;
}

.utility-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.55rem);
  z-index: 40;
  width: min(86vw, 18.5rem);
  padding: 0.78rem;
  border: 1px solid var(--hairline);
  border-radius: 1.08rem;
  background: var(--glass-strong);
  box-shadow: 0 18px 44px rgba(0,0,0,0.46);
  transform-origin: right bottom;
  animation: panel-in 180ms cubic-bezier(.2,.8,.2,1);
}
.panel-kicker {
  margin: 0 0 0.38rem;
  color: var(--leaf-dim);
  font-size: 0.95rem;
  font-weight: 850;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.panel-action {
  width: 100%;
  min-height: 46px;
  padding: 0.65rem 0.78rem;
  border: 1px solid rgba(237,245,229,0.10);
  border-radius: 0.82rem;
  color: var(--leaf);
  background: rgba(237,245,229,0.055);
  font-weight: 750;
  text-align: left;
  cursor: pointer;
  transition: transform 110ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.panel-action:hover { border-color: var(--hairline-hi); }
.panel-action:active { transform: translateY(1px) scale(0.99); }
.panel-action[aria-pressed="true"] {
  color: var(--gold-hi);
  border-color: var(--hairline-hi);
  background: rgba(232, 201, 111, 0.10);
}
.panel-action-muted { color: var(--leaf-soft); }
.panel-divider {
  height: 1px;
  margin: 0.7rem 0;
  background: rgba(237,245,229,0.08);
}

.audio-setting-row {
  display: grid;
  grid-template-columns: 3.1rem minmax(6.5rem, 1fr) auto;
  gap: 0.52rem;
  align-items: center;
  margin-top: 0.38rem;
  color: var(--leaf-soft);
  font-size: 0.95rem;
  font-weight: 650;
}
.audio-setting-row input[type="range"] {
  width: 100%;
  min-height: 44px;
  accent-color: var(--gold);
  touch-action: pan-x;
}
.audio-mute {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--leaf-soft);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(4px) scale(0.99); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(3px) scale(0.99); }
}
@keyframes panel-in {
  from { opacity: 0; transform: translateY(5px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 899px) {
  .game-shell.settings-open .feedback-layer,
  .game-shell.settings-open #btn-continue,
  .game-shell.settings-open .level-control,
  .game-shell.settings-open #btn-retry,
  .game-shell.settings-open #btn-hint {
    display: none !important;
  }
  .game-shell.settings-open .stage-wrap {
    width: min(100%, calc((100dvh - 25rem - var(--safe-top) - var(--safe-bottom)) * 941 / 1673));
    max-height: calc(100dvh - 25rem - var(--safe-top) - var(--safe-bottom));
  }
  .game-shell.settings-open .control-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .game-shell.settings-open .utility-menu {
    grid-column: 1 / -1;
    width: 100%;
  }
  .game-shell.settings-open .utility-menu summary {
    width: 100%;
    min-width: 100%;
  }
  .game-shell.settings-open .menu-short { display: none; }
  .game-shell.settings-open .menu-long { display: inline; }
  .game-shell.settings-open .utility-panel {
    position: static;
    width: 100%;
    margin-top: 0.38rem;
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 5rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    animation: none;
  }
}

@media (max-width: 360px) {
  .shell-root { padding-left: 0.32rem; padding-right: 0.32rem; }
  .game-shell { gap: 0.4rem; }
  .control-dock { padding: 0.3rem; border-radius: 1rem; }
  .control-row { gap: 0.25rem; }
  .control,
  .level-control select,
  .utility-menu summary { min-height: 46px; font-size: 0.94rem; }
  .control { min-width: 46px; padding-left: 0.66rem; padding-right: 0.66rem; }
  .utility-menu, .utility-menu summary { min-width: 46px; }
}

@media (min-width: 900px) and (min-height: 680px) {
  .shell-root {
    padding-top: calc(1rem + var(--safe-top));
    padding-bottom: calc(1rem + var(--safe-bottom));
  }
  .game-shell {
    width: min(100%, 47rem);
    height: min(100%, 54rem);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 13.8rem;
    align-items: center;
    justify-content: center;
    gap: 1rem;
  }
  .stage-stack { min-height: 0; }
  .stage-wrap {
    width: min(calc((100dvh - 2rem - var(--safe-top) - var(--safe-bottom)) * 941 / 1673), 30.4rem);
    height: auto;
    max-height: calc(100dvh - 2rem - var(--safe-top) - var(--safe-bottom));
    max-width: 100%;
  }
  .control-dock {
    align-self: center;
    padding: 0.55rem;
    border-radius: 1.28rem;
  }
  .control-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.48rem;
  }
  .control,
  .level-control select,
  .utility-menu summary { width: 100%; min-height: 48px; }
  .control-primary { order: -1; }
  .utility-menu { width: 100%; }
  .utility-menu summary { min-width: 100%; }
  .menu-short { display: none; }
  .menu-long { display: inline; }
  .utility-panel {
    right: 0;
    bottom: calc(100% + 0.55rem);
    width: 13.8rem;
  }
  .game-shell.settings-open .feedback-layer,
  .game-shell.settings-open #btn-continue,
  .game-shell.settings-open .level-control,
  .game-shell.settings-open #btn-retry,
  .game-shell.settings-open #btn-hint {
    display: none !important;
  }
  .game-shell.settings-open .utility-panel {
    position: static;
    width: 100%;
    margin-top: 0.48rem;
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

.splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #140f0a;
  padding:
    var(--safe-top)
    var(--safe-right)
    var(--safe-bottom)
    var(--safe-left);
}
.splash-overlay[hidden] { display: none; }
.splash-frame {
  position: relative;
  width: min(100vw, calc(100dvh * 941 / 1672));
  max-width: 100%;
  max-height: 100dvh;
  aspect-ratio: 941 / 1672;
}
.splash-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
#ricoshet-splash-play.splash-play-target {
  position: absolute;
  left: 28%;
  top: 86.5%;
  width: 48%;
  height: 10%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: transparent;
  opacity: 1;
  cursor: pointer;
  touch-action: manipulation;
}
#ricoshet-splash-play.splash-play-target:disabled { cursor: default; }
#ricoshet-splash-play.splash-play-target:focus-visible {
  outline: 3px solid rgba(255,255,255,0.94);
  outline-offset: 2px;
}
.splash-error {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 2%;
  margin: 0;
  padding: 0.5rem 0.7rem;
  border-radius: 0.7rem;
  background: rgba(20,15,10,0.92);
  color: #fff;
  font: 700 0.95rem/1.3 var(--ui-font);
  text-align: center;
}
