.arcade-page {
  background:
    linear-gradient(90deg, rgba(34, 49, 43, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(34, 49, 43, 0.045) 1px, transparent 1px),
    linear-gradient(135deg, #fbf7ed 0%, #eef5ec 54%, #f7efe4 100%);
  background-size: 34px 34px, 34px 34px, auto;
}

.arcade-shell {
  width: min(1160px, calc(100% - 32px));
  min-height: calc(100svh - 62px);
  padding-bottom: 28px;
}

.arcade-titlebar {
  display: grid;
  grid-template-columns: max-content minmax(280px, 540px);
  justify-content: start;
  gap: 22px;
  align-items: end;
  padding: 2px 0 14px;
}

.arcade-titlebar h1 {
  margin: 0;
  font-size: clamp(2.35rem, 4vw, 3.35rem);
  line-height: 1;
}

.arcade-titlebar p:not(.eyebrow) {
  margin: 0;
  color: #4d5c55;
  line-height: 1.55;
}

.arcade-layout {
  display: grid;
  grid-template-columns: max-content minmax(320px, 360px);
  justify-content: center;
  gap: clamp(18px, 2.6vw, 28px);
  align-items: start;
  min-width: 0;
}

.arcade-board-panel,
.arcade-control-panel {
  box-sizing: border-box;
  min-width: 0;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.96), rgba(250, 245, 234, 0.94));
  box-shadow: 8px 8px 0 var(--ink);
  animation: arcade-panel-in 420ms var(--ease-out-quint) both;
}

.arcade-board-panel {
  position: relative;
  display: grid;
  gap: 10px;
  width: fit-content;
  padding: 12px;
  max-width: 100%;
  overflow: auto;
}

.arcade-control-panel {
  animation-delay: 80ms;
}

.arcade-stage {
  box-sizing: border-box;
  display: block;
  width: min(var(--stage-width, 420px), calc(100vw - 64px));
  max-width: 100%;
  aspect-ratio: var(--stage-ratio, 1);
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: #d8cbb8;
  box-shadow: inset 0 0 0 1px rgba(255, 253, 247, 0.45);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.arcade-message {
  min-height: 24px;
  margin: 0;
  color: #4d5c55;
  font-weight: 800;
  transition: color 160ms var(--ease-out-quart), transform 160ms var(--ease-out-quart);
}

.arcade-message.is-hot {
  color: var(--leaf-dark);
  transform: translateY(-1px);
}

.arcade-control-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.arcade-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.arcade-stats span {
  display: grid;
  gap: 4px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 10px;
  background: #fffdf7;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 160ms var(--ease-out-quart), box-shadow 160ms var(--ease-out-quart);
}

.arcade-stats span:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}

.arcade-stats strong {
  font-size: 1.28rem;
  line-height: 1;
}

.arcade-stats small,
.hint-text {
  color: var(--muted);
  font-weight: 800;
}

.arcade-actions {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.control-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 0;
  gap: 7px;
}

.control-pad button {
  min-width: 0;
  display: grid;
  place-items: center;
  gap: 1px;
  min-height: 40px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: #fffdf7;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(34, 49, 43, 0.88);
  transition:
    transform 130ms var(--ease-out-quart),
    box-shadow 130ms var(--ease-out-quart),
    background 130ms var(--ease-out-quart);
}

.control-pad button:has(.control-key) {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
}

.control-pad button span {
  display: inline-block;
  min-height: 0;
  line-height: 1;
}

.control-pad button:has(.control-key) span {
  position: static;
  transform: none;
}

.control-key {
  color: var(--muted);
  font-size: 0.5em;
  font-weight: 800;
  line-height: 1;
}

.control-pad button:has(.control-key) .control-key {
  position: static;
  transform: translateY(0.16em) scale(0.7);
  transform-origin: left center;
  white-space: nowrap;
}

.control-pad button[data-action="hard"] {
  gap: 0.16rem;
}

.tool-button:has(.control-key) {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
}

.tool-button:has(.control-key) span {
  position: static;
  min-height: 0;
  line-height: 1;
  transform: none;
}

.tool-button:has(.control-key) .control-key {
  position: static;
  transform: translateY(0.16em) scale(0.7);
  transform-origin: left center;
  white-space: nowrap;
}

.tool-button#flappy-flap {
  gap: 0.16rem;
}

.hold-button.is-charging {
  background: var(--sun);
  color: var(--ink);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(34, 49, 43, 0.88);
}

.control-pad button:hover {
  transform: translate(-1px, -1px);
  background: #fff7e6;
  box-shadow: 3px 3px 0 rgba(34, 49, 43, 0.88);
}

.control-pad button:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(34, 49, 43, 0.88);
}

.control-pad > span {
  min-height: 40px;
}

.control-pad .wide {
  grid-column: span 3;
}

.game-rules {
  padding-top: 40px;
}

@media (max-width: 1100px) {
  .arcade-titlebar,
  .arcade-layout {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .arcade-board-panel,
  .arcade-control-panel {
    justify-self: center;
  }

  .arcade-control-panel {
    width: min(100%, 520px);
  }
}

@media (max-width: 760px) {
  .arcade-shell,
  .compact-header {
    width: min(100% - 28px, 1160px);
  }

  .arcade-shell {
    min-height: auto;
    padding-bottom: 20px;
  }

  .compact-header {
    position: sticky;
    z-index: 30;
    top: 0;
    padding: 10px 0 6px;
    background:
      linear-gradient(90deg, rgba(34, 49, 43, 0.045) 1px, transparent 1px),
      linear-gradient(0deg, rgba(34, 49, 43, 0.045) 1px, transparent 1px),
      linear-gradient(135deg, rgba(251, 247, 237, 0.96), rgba(238, 245, 236, 0.96));
    background-size: 34px 34px, 34px 34px, auto;
  }

  .compact-header .brand-mark {
    width: 32px;
    height: 32px;
  }

  .compact-header .brand strong {
    font-size: 0.9rem;
  }

  .compact-header .brand small {
    display: block;
    font-size: 0.62rem;
    line-height: 1.15;
  }

  .arcade-titlebar {
    gap: 4px;
    padding: 4px 0 10px;
  }

  .arcade-titlebar p:not(.eyebrow) {
    display: none;
  }

  .arcade-titlebar .eyebrow {
    margin-bottom: 6px;
    font-size: 0.68rem;
  }

  .arcade-titlebar h1 {
    font-size: clamp(1.85rem, 9vw, 2.2rem);
  }

  .arcade-stage {
    width: min(var(--stage-mobile-width, 340px), calc(100vw - 84px));
  }

  .arcade-board-panel,
  .arcade-control-panel {
    justify-self: stretch;
    width: 100%;
    max-width: 100%;
  }

  .arcade-board-panel {
    justify-items: center;
    gap: 7px;
    padding: 7px;
    overflow: hidden;
  }

  .arcade-board-panel,
  .arcade-control-panel {
    box-shadow: 4px 4px 0 var(--ink);
  }

  .arcade-message {
    min-height: 20px;
    font-size: 0.85rem;
    line-height: 1.35;
  }

  .arcade-control-panel {
    gap: 9px;
    padding: 10px;
    overflow: hidden;
  }

  .arcade-stats {
    gap: 6px;
  }

  .arcade-stats span {
    min-height: 52px;
    padding: 8px;
    box-shadow: 2px 2px 0 var(--ink);
  }

  .arcade-stats strong {
    font-size: 1.08rem;
  }

  .arcade-stats small,
  .hint-text {
    font-size: 0.78rem;
  }

  .arcade-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .arcade-actions > :first-child,
  .arcade-actions > .segmented,
  .arcade-actions > .control-pad {
    grid-column: 1 / -1;
  }

  .control-pad {
    gap: 6px;
  }

  .control-pad {
    border: 2px solid var(--ink);
    border-radius: 8px;
    padding: 8px;
    background: rgba(255, 253, 247, 0.74);
    box-shadow: 2px 2px 0 rgba(34, 49, 43, 0.9);
  }

  .control-pad button,
  .tool-button,
  .segmented button {
    min-height: 44px;
  }

  .control-pad button {
    min-height: 46px;
    font-size: 1rem;
  }

  .leaderboard-card {
    gap: 7px;
    padding-top: 10px;
  }

  .leaderboard-row-head {
    align-items: center;
  }

  .leaderboard-row-head h2 {
    font-size: 1.12rem;
  }

  .player-rank {
    padding: 7px 8px;
  }

  .leaderboard-list.compact {
    max-height: 128px;
  }

  .leaderboard-list.compact li {
    gap: 7px;
    padding: 6px;
  }

  .game-rules {
    padding-top: 28px;
  }

  .tetris-page .arcade-stage {
    --stage-mobile-width: 220px;
  }

  .flappy-page .arcade-stage,
  .white-tiles-page .arcade-stage,
  .tower-page .arcade-stage {
    --stage-mobile-width: 292px;
  }

  .jump-page .arcade-stage {
    --stage-mobile-width: 302px;
  }

  .block-puzzle-page .arcade-stage,
  .sheep-match-page .arcade-stage {
    --stage-mobile-width: 318px;
  }

  .match3-page .arcade-stage,
  .sokoban-page .arcade-stage,
  .water-drops-page .arcade-stage,
  .snake-page .arcade-stage {
    --stage-mobile-width: 318px;
  }

  .breakout-page .arcade-stage {
    --stage-mobile-width: 322px;
  }
}

@media (max-width: 380px) {
  .arcade-stage {
    width: min(var(--stage-mobile-width, 318px), calc(100vw - 76px));
  }

  .tetris-page .arcade-stage {
    --stage-mobile-width: 204px;
  }

  .flappy-page .arcade-stage,
  .white-tiles-page .arcade-stage,
  .tower-page .arcade-stage {
    --stage-mobile-width: 276px;
  }

  .arcade-stats span {
    padding: 7px 6px;
  }

  .control-pad button {
    min-height: 44px;
    font-size: 0.92rem;
  }
}

.tetris-page .arcade-stage {
  background: #1f2e2a;
}

.snake-page .arcade-stage {
  background: #dfe9d5;
}

.flappy-page .arcade-stage {
  background: #edf5ec;
}

.white-tiles-page .arcade-stage {
  background: #fffdf7;
}

.water-drops-page .arcade-stage {
  background: #dff1f5;
}

.sokoban-page .arcade-stage {
  background: #eef5ec;
}

.jump-page .arcade-stage {
  background: #edf5ec;
}

.breakout-page .arcade-stage {
  background: #eff6ef;
}

.tower-page .arcade-stage {
  background: #a8c8f0;
}

.block-puzzle-page .arcade-stage {
  background: #e9f1e4;
}

.match3-page .arcade-stage {
  background: #f4ecf3;
}

.sheep-match-page .arcade-stage {
  background: #edf5ec;
}

@keyframes arcade-panel-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
