/* ==========================================================================
   GAME SCREEN
   ========================================================================== */

.game-screen {
  --game-header-height: 44px;
  position: relative;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.game-header {
  min-height: var(--game-header-height);
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 18px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--arrow);
  background: var(--panel);
}
.game-header > div:first-child { display: flex; align-items: baseline; gap: 9px; }
.game-header .eyebrow { margin: 0; }
.game-header strong { font-size: 12px; letter-spacing: 2px; }
.header-score { color: var(--wire); font-size: 11px; }
.header-score output { color: var(--ink); }


/* ==========================================================================
   GAME SHELL — PLAYFIELD + HUD + VERTICAL LOGO
   ========================================================================== */

.game-stage {
  --game-stage-reserved-height: 0px;
  width: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  align-items: start;
  justify-items: center;
  overflow: hidden;
  background: #171914;
  box-shadow: inset 0 0 48px #0006;
}

.game-shell-frame {
  position: relative;
  width: 576px;
  height: calc(var(--field-height) + var(--drop-guide-height));
  max-width: 100%;
  max-height: 100%;
}
.game-shell-frame::before,
.game-shell-frame::after {
  content: "";
  position: absolute;
  z-index: 9;
  inset: -2px;
  border: 2px solid transparent;
  pointer-events: none;
}
.game-shell-frame::after {
  border-color: transparent;
  box-shadow: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.game-shell-frame.is-danger::after {
  border-color: #d86b43;
  box-shadow: 0 0 10px #d86b4330, inset 0 0 12px #d86b4318;
}
.game-shell-frame.is-line-clear::before {
  animation: line-clear-frame-flash 320ms ease-out both;
}

.game-shell {
  position: relative;
  width: 576px;
  display: grid;
  grid-template-columns: 320px 230px 26px;
  background: var(--panel);
  transform: scale(var(--game-shell-scale, 1));
  transform-origin: top left;
  will-change: transform;
}

.playfield-panel { position: relative; border-right: 1px solid var(--arrow); }
.playfield-panel.is-hard-drop { animation: hard-drop-kick 160ms ease-out both; }
.playfield-panel.is-line-clear { animation: line-clear-field-flash 260ms ease-out both; }

#field {
  display: block;
  width: 320px;
  height: auto;
  background: #080a07;
}

.drop-guide {
  position: relative;
  height: var(--drop-guide-height);
  border-bottom: 1px solid var(--line);
  background: #080a07;
}

.cursor-label {
  position: absolute;
  z-index: 4;
  top: 5px;
  left: 0;
  width: 32px;
  color: #f0b35d;
  font-weight: 700;
  font-size: 9px;
  line-height: 1;
  text-align: center;
  text-shadow: 0 0 8px #f0b35d66;
  transform: translateX(-50%);
  transition: left 120ms linear;
  pointer-events: none;
}
.cursor-label span {
  position: absolute;
  top: 0;
  left: 50%;
  width: 104px;
  letter-spacing: 1px;
  transform: translateX(calc(-50% + var(--cursor-label-shift, 0px)));
}
.cursor-label b {
  display: block;
  margin-top: 15px;
  font-size: 20px;
  line-height: 1;
}


/* ── HUD ── */

.hud {
  min-height: calc(var(--field-height) + var(--drop-guide-height));
  background: var(--panel-2);
}

.hud-section {
  padding: 13px 15px;
  border-bottom: 1px solid var(--arrow);
}

.hud-section h2 {
  margin: 0 0 8px;
  color: var(--moss);
  font-size: 13px;
  letter-spacing: 2px;
}

#next,
#focus {
  display: block;
  max-width: 100%;
  margin-inline: auto;
  border: 1px solid var(--arrow);
  background: #080a07;
}
#next { width: 180px; height: auto; aspect-ratio: 12 / 7; }

#score {
  display: block;
  font-size: 22px;
  letter-spacing: 4px;
  text-align: right;
  color: var(--ink);
}

.minor-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--wire);
  font-size: 12px;
}

#focus { width: 198px; height: auto; aspect-ratio: 1; cursor: default; }

.focus-section { position: relative; }

.resource-row {
  display: flex;
  justify-content: space-between;
  padding-top: 8px;
  font-size: 12px;
}
.resource-row > span {
  color: var(--wire);
  font-size: .9em;
  letter-spacing: .05em;
}

#scrap,
#level,
#lines { display: inline-block; }
#scrap.is-gaining { animation: scrap-gain 780ms ease-out both; }
#scrap.is-spending { animation: scrap-spend 520ms ease-out both; }
#level.is-leveling { animation: level-stat-pulse 1150ms ease-out both; }
#lines.is-counting { animation: line-stat-pulse 400ms ease-out both; }

.focus-nav {
  margin-top: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  font-size: 11px;
}
.focus-nav-single { justify-content: center; }

kbd {
  display: inline-block;
  padding: 5px 7px;
  border: 1px solid var(--arrow);
  border-bottom: 2px solid var(--arrow);
  border-radius: 2px;
  background: var(--olive);
  color: var(--moss);
  font: inherit;
  font-size: 12px;
  line-height: 1;
}


/* ── Focus connector line ── */

.focus-connector {
  position: absolute;
  z-index: 3;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.focus-connector path {
  fill: none;
  stroke: #9aa592a0;
  stroke-width: .75;
  stroke-linecap: round;
  stroke-dasharray: 4 3;
  vector-effect: non-scaling-stroke;
}


/* ── Event feedback ── */

.game-feedback-layer {
  position: absolute;
  z-index: 8;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.material-chip,
.sculpt-cell-effect,
.hard-drop-streak,
.hard-drop-impact,
.line-clear-sweep {
  position: absolute;
  display: block;
  pointer-events: none;
}

.material-chip {
  z-index: 3;
  border: 1px solid color-mix(in srgb, var(--chip-color) 72%, #f1f5e6);
  border-radius: 1px 2px 1px 0;
  background: var(--chip-color);
  box-shadow: 0 1px 0 #080a077a, 0 0 5px color-mix(in srgb, var(--chip-color) 42%, transparent);
  opacity: 0;
  transform: translate(-50%, -50%);
  animation: material-chip-flight 460ms cubic-bezier(.2, .68, .24, 1) var(--chip-delay, 0ms) both;
}
.material-chip.is-to-fill {
  box-shadow: 0 0 6px color-mix(in srgb, var(--chip-color) 58%, transparent);
}

.sculpt-cell-effect {
  z-index: 2;
  margin: 0;
  transform: translate(-50%, -50%);
  transform-origin: center;
}

.sculpt-cell-effect.is-cut {
  animation: cut-cell-lifecycle 560ms linear both;
}

.cut-fragment {
  position: absolute;
  width: 56%;
  height: 56%;
  border: 1px solid #080a078f;
  background: var(--cell-material);
  box-shadow: inset 0 0 0 1px #f1f5e618;
  animation: cut-fragment-break 510ms cubic-bezier(.18, .7, .26, 1) both;
}
.cut-fragment.is-nw {
  --cut-x: -8px; --cut-y: -7px; --cut-end-x: -12px; --cut-end-y: -11px; --cut-r: -13deg;
  top: 0; left: 0;
  clip-path: polygon(0 0, 100% 0, 82% 54%, 100% 100%, 0 88%);
}
.cut-fragment.is-ne {
  --cut-x: 9px; --cut-y: -6px; --cut-end-x: 14px; --cut-end-y: -9px; --cut-r: 11deg;
  top: 0; right: 0;
  clip-path: polygon(0 0, 100% 0, 100% 91%, 8% 100%, 22% 55%);
}
.cut-fragment.is-sw {
  --cut-x: -7px; --cut-y: 9px; --cut-end-x: -11px; --cut-end-y: 14px; --cut-r: 9deg;
  bottom: 0; left: 0;
  clip-path: polygon(0 8%, 100% 0, 83% 45%, 100% 100%, 0 100%);
}
.cut-fragment.is-se {
  --cut-x: 9px; --cut-y: 8px; --cut-end-x: 14px; --cut-end-y: 12px; --cut-r: -10deg;
  right: 0; bottom: 0;
  clip-path: polygon(8% 0, 100% 10%, 100% 100%, 0 100%, 18% 44%);
}

.cut-crack {
  position: absolute;
  z-index: 2;
  inset: -1px;
  background:
    linear-gradient(112deg, transparent 0 46%, #f1f5e6cc 47% 49%, #080a07 50% 52%, transparent 53%) center / 52% 100% no-repeat,
    linear-gradient(28deg, transparent 0 46%, #080a07 47% 52%, transparent 53%) center / 100% 46% no-repeat;
  opacity: 0;
  animation: cut-crack-reveal 240ms ease-out both;
}

.sculpt-cell-effect.is-fill {
  overflow: hidden;
  border: 1px solid #abb6a239;
  background: #080a07;
  box-shadow: 0 0 0 1px #080a07;
  animation: fill-cell-lifecycle 760ms linear both;
}

.fill-framework,
.fill-material {
  position: absolute;
  display: block;
}

.fill-framework {
  z-index: 1;
  inset: 2px;
  border: 2px solid color-mix(in srgb, var(--cell-material) 72%, #d5dacd);
  background:
    linear-gradient(45deg, transparent 46%, color-mix(in srgb, var(--cell-material) 68%, #f1f5e6) 47% 53%, transparent 54%),
    linear-gradient(-45deg, transparent 46%, color-mix(in srgb, var(--cell-material) 68%, #f1f5e6) 47% 53%, transparent 54%);
  box-shadow: 0 0 7px color-mix(in srgb, var(--cell-material) 38%, transparent);
  opacity: 0;
  transform: scale(.72);
  animation: fill-framework-place 680ms cubic-bezier(.2, .72, .25, 1) both;
}

.fill-material {
  z-index: 2;
  inset: 1px;
  border: 1px solid #bdc8b4;
  background: var(--cell-material);
  box-shadow: inset 0 0 0 1px #f1f5e618, 0 0 8px color-mix(in srgb, var(--cell-material) 45%, transparent);
  opacity: 0;
  clip-path: polygon(47% 43%, 54% 43%, 58% 49%, 56% 57%, 49% 59%, 43% 55%, 42% 48%, 45% 45%);
  animation: fill-material-build 760ms cubic-bezier(.22, .72, .22, 1) both;
}
.hard-drop-streak {
  width: 3px;
  margin-left: -1.5px;
  background: linear-gradient(to bottom, #f0b35d00, #f0b35daa 34%, #f0b35d22 100%);
  filter: drop-shadow(0 0 3px #f0b35d55);
  transform-origin: top center;
  animation: hard-drop-streak 220ms ease-out both;
}

.hard-drop-impact {
  width: 48px;
  height: 12px;
  margin: -6px 0 0 -24px;
  border: 1px solid #f0b35d99;
  border-radius: 50%;
  box-shadow: 0 0 8px #f0b35d33;
  opacity: 0;
  transform: scale(.4, .7);
  animation: hard-drop-impact 300ms cubic-bezier(.18, .75, .28, 1) both;
}

.line-clear-sweep {
  background: linear-gradient(90deg, #d5dacd00 0%, #d5dacd7d 28%, #f0b35d9c 50%, #d5dacd7d 72%, #d5dacd00 100%);
  mix-blend-mode: screen;
  opacity: 0;
  transform: scaleX(.18);
  animation: line-clear-sweep 300ms ease-out both;
}

.level-up-warning {
  position: absolute;
  min-width: 236px;
  padding: 10px 16px;
  border-block: 2px solid #f0b35daa;
  background: #0d0f0bea;
  color: #f0b35d;
  box-shadow: 0 0 18px #080a07aa, inset 0 0 14px #f0b35d14;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 2px;
  text-align: center;
  text-shadow: 0 0 8px #f0b35d77;
  opacity: 0;
  transform: translate(-50%, -10px) scale(.96);
  animation: level-up-warning 1800ms ease-out both;
}

@keyframes material-chip-flight {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(0) scale(.55); }
  8% { opacity: .96; transform: translate(-50%, -50%) rotate(0) scale(1); }
  58% { opacity: .94; transform: translate(calc(-50% + var(--chip-mid-x)), calc(-50% + var(--chip-mid-y))) rotate(var(--chip-mid-rotation)) scale(.92); }
  90% { opacity: .9; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--chip-end-x)), calc(-50% + var(--chip-end-y))) rotate(var(--chip-rotation)) scale(.35); }
}

@keyframes cut-cell-lifecycle {
  0%, 92% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes cut-fragment-break {
  0%, 25% { opacity: 1; transform: translate(0, 0) rotate(0) scale(1); filter: brightness(1); }
  36% { opacity: 1; filter: brightness(1.34); }
  72% { opacity: .88; transform: translate(var(--cut-x), var(--cut-y)) rotate(var(--cut-r)) scale(.84); }
  100% { opacity: 0; transform: translate(var(--cut-end-x), var(--cut-end-y)) rotate(var(--cut-r)) scale(.45); }
}

@keyframes cut-crack-reveal {
  0%, 15% { opacity: 0; transform: scale(.45); }
  32%, 68% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.12); }
}

@keyframes fill-cell-lifecycle {
  0%, 94% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes fill-framework-place {
  0% { opacity: 0; transform: scale(.65) rotate(-3deg); }
  12%, 55% { opacity: 1; transform: scale(1) rotate(0); }
  78% { opacity: .72; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

@keyframes fill-material-build {
  0%, 43% {
    opacity: 0;
    clip-path: polygon(47% 43%, 54% 43%, 58% 49%, 56% 57%, 49% 59%, 43% 55%, 42% 48%, 45% 45%);
  }
  52% {
    opacity: .9;
    clip-path: polygon(38% 27%, 65% 31%, 76% 47%, 66% 70%, 48% 78%, 25% 65%, 23% 41%, 34% 34%);
  }
  84%, 100% {
    opacity: 1;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 100% 100%, 0 100%, 0 100%, 0 0, 0 0);
  }
}

@keyframes scrap-gain {
  0%, 62% { color: inherit; text-shadow: none; transform: scale(1); }
  72%, 84% { color: #f0b35d; text-shadow: 0 0 7px #f0b35d66; transform: scale(1.14); }
  100% { color: inherit; text-shadow: none; transform: scale(1); }
}

@keyframes scrap-spend {
  0%, 45% { color: #78bd7f; opacity: .7; transform: scale(.92); }
  100% { color: inherit; opacity: 1; transform: scale(1); }
}

@keyframes hard-drop-streak {
  0%, 32% { opacity: .9; transform: scaleY(.2); }
  100% { opacity: 0; transform: scaleY(1); }
}

@keyframes hard-drop-impact {
  0%, 26% { opacity: .95; transform: scale(.4, .7); }
  100% { opacity: 0; transform: scale(1.35, 1); }
}

@keyframes hard-drop-kick {
  0%, 38% { transform: translateY(var(--hard-drop-kick, 2px)); filter: brightness(1.2); }
  100% { transform: translateY(0); filter: brightness(1); }
}

@keyframes line-clear-sweep {
  0% { opacity: 0; transform: scaleX(.18); }
  36% { opacity: .92; transform: scaleX(1); }
  100% { opacity: 0; transform: scaleX(1); }
}

@keyframes line-clear-field-flash {
  0% { filter: brightness(1); }
  36% { filter: brightness(1.28); }
  100% { filter: brightness(1); }
}

@keyframes line-clear-frame-flash {
  0% { border-color: transparent; box-shadow: none; }
  38% { border-color: #d5dacd99; box-shadow: 0 0 12px #d5dacd44; }
  100% { border-color: transparent; box-shadow: none; }
}

@keyframes line-stat-pulse {
  0% { color: inherit; transform: scale(1); }
  42% { color: #d5dacd; text-shadow: 0 0 7px #d5dacd55; transform: scale(1.14); }
  100% { color: inherit; text-shadow: none; transform: scale(1); }
}

@keyframes level-stat-pulse {
  0%, 100% { color: inherit; text-shadow: none; transform: scale(1); }
  28%, 52% { color: #f0b35d; text-shadow: 0 0 8px #f0b35d55; transform: scale(1.12); }
}

@keyframes level-up-warning {
  0% { opacity: 0; transform: translate(-50%, -10px) scale(.96); }
  12%, 72% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, 5px) scale(1); }
}


/* ── Vertical logo ── */

.vertical-logo {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12px;
  border-left: 1px solid var(--arrow);
  color: var(--arrow);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  writing-mode: vertical-rl;
  text-orientation: upright;
}


/* ==========================================================================
   GAME OVER OVERLAY
   ========================================================================== */

.game-over {
  position: absolute;
  z-index: 11;
  inset: var(--game-header-height) 0 0;
  display: grid;
  place-items: center;
  background: #080a07f2;
  text-align: center;
}
.game-over[hidden] { display: none; }
.game-over-panel { width: min(330px, calc(100% - 40px)); }
.game-over-panel > h2 {
  margin-bottom: 24px;
  color: var(--moss);
  font-size: 22px;
  letter-spacing: 6px;
  text-shadow: 0 0 12px #9aa59244;
}
.final-score {
  margin-bottom: 26px;
  padding: 18px 16px 16px;
  border-block: 1px solid var(--arrow);
  background: #11130f;
}
.final-score span {
  display: block;
  margin-bottom: 9px;
  color: var(--wire);
  font-size: 10px;
  letter-spacing: 2px;
}
.final-score output {
  display: block;
  color: var(--ink);
  font-size: 28px;
  letter-spacing: 5px;
  text-shadow: 0 0 10px #9aa59235;
}
.game-over-menu { gap: 4px; }
.game-over-menu .menu-button { min-height: 50px; }




/* ==========================================================================
   PAUSE OVERLAY
   ========================================================================== */

.pause-overlay {
  position: absolute;
  z-index: 10;
  inset: var(--game-header-height) 0 0;
  display: grid;
  place-items: center;
  background: #080a07f0;
}

.pause-panel { width: 270px; }
.pause-panel > h2 {
  margin-bottom: 24px;
  font-size: 18px;
  letter-spacing: 4px;
  text-shadow: 0 0 8px #9aa59233;
}

.pause-menu .menu-button { min-height: 46px; }

.pause-hint {
  margin: 18px 0 0;
  color: var(--wire);
  font-size: 10px;
  letter-spacing: 1px;
  text-align: center;
}


/* Responsive / input-mode adjustments owned by this role. */

@media (max-height: 820px) {
  .game-screen { --game-header-height: 38px; }
  .game-header { padding-block: 5px; }
}

@media (max-width: 700px) {
  .game-screen { overflow: hidden; }
}

@media (max-width: 699px) {
  .game-shell { grid-template-columns: minmax(0, 57%) minmax(0, 43%); }
  .vertical-logo { display: none; }
  .hud { min-height: 0; }
  #field { width: 100%; }
  .drop-guide { height: 32px; }
  .hud-section { padding: 8px 10px; }
  .hud-section h2 { margin-bottom: 5px; font-size: 12px; }
  #next { width: min(100%, 150px); }
  #focus { width: min(100%, 150px); }
  #score { font-size: 20px; letter-spacing: 3px; }
  .minor-stats,
  .resource-row { font-size: 11px; }
  .resource-row { padding-top: 5px; }
  .focus-nav { margin-top: 8px; font-size: 10px; }
}

@media (max-width: 699px), (pointer: coarse) and (orientation: portrait) {
  .game-header { position: sticky; top: 0; z-index: 12; }
}

@media (hover: none) and (pointer: coarse) {
  .pause-hint[data-input-hint="touch"] { display: block; }
}

@media (hover: none) and (pointer: coarse) and (orientation: portrait) {
  .focus-nav[data-input-hint="handheld"] { display: flex; }
  .console-layout[data-active-screen="game"] .game-stage { --game-stage-reserved-height: var(--control-deck-reserve); }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-width: 899px) {
  .focus-nav[data-input-hint="handheld"] { display: flex; }
  .console-layout[data-active-screen="game"] .game-stage { --game-stage-reserved-height: var(--control-deck-reserve); }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 599px) {
  .focus-nav[data-input-hint="handheld"] { display: flex; }
  .console-layout[data-active-screen="game"] .game-stage {
    --game-stage-reserved-height: var(--control-deck-reserve);
    --game-shell-preferred-width: 320px;
  }
  .game-shell { grid-template-columns: minmax(0, 57%) minmax(0, 43%); }
  .vertical-logo { display: none; }
  #field { width: 100%; }
  .drop-guide { height: 26px; }
  .hud { min-height: 0; }
  .hud-section { padding: 4px 6px; }
  .hud-section h2 { margin-bottom: 3px; font-size: 11px; }
  #next,
  #focus { width: min(100%, 122px); }
  #score { font-size: 18px; letter-spacing: 2px; }
  .minor-stats,
  .resource-row { font-size: 10px; }
  .resource-row { padding-top: 3px; }
  .focus-nav { margin-top: 5px; font-size: 9px; }
  .pause-panel,
  .game-over-panel { width: min(250px, calc(100% - 24px)); }
  .pause-panel .eyebrow,
  .game-over-panel .eyebrow { font-size: 8px; }
  .pause-panel > h2,
  .game-over-panel > h2 {
    margin: 4px 0 8px;
    font-size: 14px;
    letter-spacing: 3px;
  }
  .pause-menu .menu-button,
  .game-over-menu .menu-button {
    min-height: 34px;
    padding: 5px 10px 5px 30px;
  }
  .pause-menu .menu-button > span,
  .game-over-menu .menu-button > span {
    font-size: 11px;
    letter-spacing: 1px;
  }
  .pause-menu .menu-button::after,
  .game-over-menu .menu-button::after { left: 30px; right: 10px; }
  .pause-menu .menu-button:focus::before,
  .pause-menu .menu-button:hover::before,
  .game-over-menu .menu-button:focus::before,
  .game-over-menu .menu-button:hover::before { left: 9px; }
  .pause-hint {
    margin-top: 6px;
    font-size: 8px;
  }
  .final-score {
    margin-bottom: 8px;
    padding: 7px 10px 6px;
  }
  .final-score span {
    margin-bottom: 4px;
    font-size: 8px;
  }
  .final-score output {
    font-size: 18px;
    letter-spacing: 3px;
  }
}

@media (hover: none) and (pointer: coarse) and (orientation: portrait) and (min-width: 700px) {
  .onboarding-dialog {
    bottom: calc(202px + env(safe-area-inset-bottom, 0));
    max-height: calc(100dvh - 226px);
  }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (min-width: 900px) and (min-height: 600px) {
  .focus-nav[data-input-hint="tablet-rail"] { display: flex; }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 700px) {
  .game-screen { --game-header-height: 34px; }
}

/* First-run onboarding and in-game tutorial guidance. */
.onboarding-dialog {
  position: fixed;
  z-index: 100;
  inset: 0;
  width: min(480px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid #7c7964;
  border-radius: 4px;
  overflow: auto;
  background:
    linear-gradient(180deg, #1b1d18 0, var(--panel) 54px),
    var(--panel);
  color: var(--ink);
  box-shadow:
    0 24px 70px #000e,
    inset 0 0 0 1px #25271f;
}
.console-layout[data-onboarding] .arcade-cabinet {
  filter: brightness(.22) saturate(.55);
  pointer-events: none;
}
.onboarding-dialog::backdrop {
  background: transparent;
}
.onboarding-panel {
  position: relative;
  padding: 28px;
}
.onboarding-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 28px;
  right: 28px;
  height: 2px;
  background: var(--moss);
  box-shadow: 0 0 14px var(--glow);
}
.onboarding-panel .eyebrow {
  margin-bottom: 8px;
  color: var(--moss);
  font-size: 10px;
  letter-spacing: 2px;
}
.onboarding-panel h2 {
  margin: 0 0 10px;
  font-size: clamp(20px, 5vw, 24px);
  line-height: 1.2;
  letter-spacing: 2px;
}
.onboarding-panel p { line-height: 1.55; }
.onboarding-input-copy { margin: 0 0 16px; }
.onboarding-control-list {
  gap: 1px;
  padding: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}
.onboarding-control-row {
  min-height: 52px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: minmax(96px, auto) 1fr;
  align-items: center;
  gap: 12px;
  background: #0d0f0c;
  font-size: 12px;
  line-height: 1.35;
}
.onboarding-key-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.onboarding-key-cluster kbd {
  padding: 5px 6px;
  border-color: #7c7964;
  background: #28281c;
  color: var(--ink);
  font-size: 10px;
  white-space: nowrap;
  box-shadow: inset 0 -2px 0 #11120f;
}
.onboarding-primary {
  width: 100%;
  margin-top: 16px;
}
.onboarding-panel .menu-button {
  min-height: 48px;
  font-size: 12px;
}
.onboarding-choice { gap: 8px; }
.onboarding-choice .onboarding-primary { margin-top: 0; }
#tutorial-offer-dialog { width: min(380px, calc(100vw - 24px)); }
.onboarding-tutorial-panel h2 {
  margin-bottom: 20px;
  text-align: center;
}
:root[data-input-mode="keyboard"] .onboarding-input-copy[data-input-hint="keyboard"],
:root[data-input-mode="touch"] .onboarding-input-copy[data-input-hint="touch"],
:root[data-input-mode="controller"] .onboarding-input-copy[data-input-hint="controller"] { display: grid; }

.tutorial-guide {
  position: absolute;
  z-index: 22;
  top: calc(var(--game-header-height) + 10px);
  left: 10px;
  width: min(318px, calc(100% - 20px));
  padding: 10px 11px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: 7px;
  border: 1px solid #7c7964;
  background:
    linear-gradient(110deg, #151712f5, #090b08f5),
    #090b08;
  box-shadow: 0 7px 22px #000b, inset 0 0 0 1px #25271f;
  pointer-events: none;
}
.tutorial-guide[hidden] { display: none; }
.tutorial-guide-heading {
  display: flex;
  align-items: baseline;
}
.tutorial-guide-heading .eyebrow {
  margin: 0;
  color: var(--arrow);
  font-size: 9px;
  letter-spacing: 1.6px;
}
.tutorial-guide p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}
.tutorial-guide-control {
  min-width: 0;
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  background: #070806;
}
.tutorial-guide-control strong {
  color: var(--moss);
  font-size: 9px;
  letter-spacing: 1px;
  white-space: nowrap;
}
.tutorial-keyboard-keys {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
}
.tutorial-keyboard-keys kbd {
  min-width: 28px;
  padding: 5px 6px;
  border-color: var(--moss);
  background: #34351f;
  color: var(--ink);
  font-size: 11px;
  text-align: center;
  box-shadow: 0 0 0 1px #abb6a22b, 0 0 10px #abb6a224;
}
.tutorial-guide-control-copy {
  color: var(--ink);
  font-size: 11px;
  line-height: 1.4;
  text-align: left;
}
:root[data-input-mode="keyboard"] .tutorial-guide-control[data-input-hint="keyboard"],
:root[data-input-mode="touch"] .tutorial-guide-control[data-input-hint="touch"],
:root[data-input-mode="controller"] .tutorial-guide-control[data-input-hint="controller"] { display: flex; }
.tutorial-guide[data-has-control="false"] .tutorial-guide-control { display: none !important; }
.game-screen[data-tutorial-step="move"] .focus-section,
.game-screen[data-tutorial-step="move-second"] .focus-section,
.game-screen[data-tutorial-step="move-fill"] .focus-section,
.game-screen[data-tutorial-step="cut"] .focus-section,
.game-screen[data-tutorial-step="cut-again"] .focus-section,
.game-screen[data-tutorial-step="fill"] .focus-section,
.game-screen[data-tutorial-step="fill"] #scrap,
.game-screen[data-tutorial-step="drop"] .playfield-panel {
  outline: 2px solid var(--arrow);
  outline-offset: 2px;
}
.game-screen[data-tutorial-step="move"] .focus-section,
.game-screen[data-tutorial-step="move-second"] .focus-section,
.game-screen[data-tutorial-step="move-fill"] .focus-section,
.game-screen[data-tutorial-step="cut"] .focus-section,
.game-screen[data-tutorial-step="cut-again"] .focus-section,
.game-screen[data-tutorial-step="fill"] .focus-section {
  animation: tutorial-focus-pulse 880ms ease-in-out infinite;
}
.game-screen[data-tutorial-step="move"] .focus-connector path,
.game-screen[data-tutorial-step="move-second"] .focus-connector path,
.game-screen[data-tutorial-step="move-fill"] .focus-connector path,
.game-screen[data-tutorial-step="cut"] .focus-connector path,
.game-screen[data-tutorial-step="cut-again"] .focus-connector path,
.game-screen[data-tutorial-step="fill"] .focus-connector path {
  stroke: var(--arrow);
  stroke-width: 1.4;
  animation: tutorial-connector-flow 650ms linear infinite;
}
.game-screen[data-tutorial-step="fill"] #scrap { box-shadow: 0 0 12px var(--arrow); }
.console-layout[data-tutorial-step="move"] .touch-dpad,
.console-layout[data-tutorial-step="move"] .rail-dpad,
.console-layout[data-tutorial-step="move-second"] .touch-dpad,
.console-layout[data-tutorial-step="move-second"] .rail-dpad,
.console-layout[data-tutorial-step="move-fill"] .touch-dpad,
.console-layout[data-tutorial-step="move-fill"] .rail-dpad,
.console-layout[data-tutorial-step="drop"] .drop-button,
.console-layout[data-tutorial-step="drop"] .rail-drop-button,
.console-layout[data-tutorial-step="cut"] .sculpt-button,
.console-layout[data-tutorial-step="cut"] .rail-sculpt-button,
.console-layout[data-tutorial-step="cut-again"] .sculpt-button,
.console-layout[data-tutorial-step="cut-again"] .rail-sculpt-button,
.console-layout[data-tutorial-step="fill"] .sculpt-button,
.console-layout[data-tutorial-step="fill"] .rail-sculpt-button { box-shadow: 0 0 0 2px var(--arrow); }

@keyframes tutorial-focus-pulse {
  0%, 100% { outline-color: #f0b35d99; box-shadow: 0 0 0 #f0b35d00; }
  50% { outline-color: #f0b35d; box-shadow: 0 0 14px #f0b35d55; }
}

@keyframes tutorial-connector-flow {
  to { stroke-dashoffset: -14; }
}

@media (max-width: 520px) {
  .onboarding-panel { padding: 22px 18px; }
  .onboarding-panel::before { left: 18px; right: 18px; }
  .onboarding-panel h2 { font-size: 20px; }
  .onboarding-control-row {
    min-height: 48px;
    grid-template-columns: minmax(88px, auto) 1fr;
    gap: 8px;
  }

  .tutorial-guide {
    top: calc(var(--game-header-height) + 6px);
    left: 6px;
    width: min(292px, calc(100% - 12px));
    padding: 8px 10px 9px;
    row-gap: 5px;
  }
  .tutorial-guide p {
    font-size: clamp(13px, 3.8vw, 14px);
    line-height: 1.35;
  }
  .tutorial-guide-control {
    min-width: 0;
    width: 100%;
    min-height: 34px;
    padding: 5px 7px;
    justify-content: space-between;
  }
  .tutorial-guide-control-copy {
    justify-content: flex-start;
    text-align: left;
  }
  .tutorial-keyboard-keys { justify-content: flex-end; }
  .tutorial-keyboard-keys kbd { padding: 4px 5px; font-size: 10px; }
}

@media (hover: none) and (pointer: coarse) and (orientation: portrait) {
  .onboarding-dialog {
    bottom: calc(var(--control-deck-height, 164px) + 6px + env(safe-area-inset-bottom, 0));
    max-height: calc(100dvh - var(--control-deck-height, 164px) - 30px);
  }
}

@media (hover: none) and (pointer: coarse) and (orientation: portrait) and (max-width: 374px) and (max-height: 650px) {
  .tutorial-guide {
    top: calc(var(--game-header-height) + 4px);
    left: 4px;
    width: min(238px, calc(100% - 8px));
    padding: 8px 9px;
  }
  .tutorial-guide p { font-size: 12px; }
  .tutorial-guide-control { padding: 5px 7px; }
  .game-screen[data-tutorial-step="drop"] .tutorial-guide {
    right: 0;
    left: auto;
    width: min(220px, calc(100% - 8px));
    box-shadow: -4px 5px 16px #000b;
  }
}
