:root {
  --bg: #eef3f6;
  --panel: #ffffff;
  --panel-border: #cfd9e0;
  --text-main: #243746;
  --text-dim: #617585;
  --accent: #4f9cc2;
  --accent-soft: #d9ecf5;
  --success: #6cbf7d;
  --danger: #d97979;
  --shadow: 0 8px 24px rgba(31, 55, 72, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
}

body {
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  color: var(--text-main);
  background: var(--bg);
  overflow: hidden;
}

body::before,
body::after {
  display: none;
}

.app-shell {
  width: min(1400px, calc(100% - 24px));
  margin: 0 auto;
  height: 100dvh;
  padding: 12px 0;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
}

h1,
h2 {
  font-family: "Avenir Next Condensed", "Trebuchet MS", sans-serif;
  letter-spacing: 0.03em;
}

.hero-copy,
.panel-head p,
.status-bar p {
  margin: 0;
  color: var(--text-dim);
  line-height: 1.5;
}

.game-layout {
  display: block;
}

.scene-panel,
.control-panel {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.scene-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: calc(100dvh - 24px);
  padding: 12px;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(220px, 270px) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  flex: 0 0 auto;
}

.info-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.board-column {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
}

.board-stage-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.hud-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.hud-card {
  background: #f8fbfd;
  border: 1px solid #d8e3ea;
  border-radius: 14px;
  padding: 9px 12px;
}

.hud-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}

.hud-card strong {
  font-size: 1.12rem;
}

.scene-actions {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 10px;
  margin-top: 0;
}

.scene-wrap {
  position: relative;
  width: 100%;
  max-width: 720px;
  min-height: 500px;
  height: 500px;
  border-radius: 18px;
  overflow: hidden;
  background: #cfd8de;
  border: 2px solid #b8c7d0;
}

.scene-wrap::after {
  display: none;
}

.scene-toolbar,
.scene-glow {
  display: none;
}

.board-scene {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 500px;
  isolation: isolate;
  overflow: hidden;
  background: #e8f0f4;
}

.board-scene::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 12px;
  background:
    linear-gradient(rgba(79, 156, 194, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 156, 194, 0.12) 1px, transparent 1px);
  background-size: 56px 56px;
  background-color: #edf4f7;
  border: 1px solid #d1dde5;
}

.scene-stage {
  position: absolute;
  left: 50%;
  top: 12px;
  transform-origin: top center;
}

.floating-pad {
  position: static;
  pointer-events: auto;
}

.control-dock {
  display: flex;
  align-items: center;
  justify-content: center;
}

.floating-pad-shell {
  display: grid;
  grid-template-columns: 56px 56px 56px;
  grid-template-rows: 56px 56px 56px;
  gap: 6px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #cfd9e0;
  box-shadow: 0 8px 24px rgba(31, 55, 72, 0.12);
  pointer-events: auto;
}

.floating-pad .control-button {
  min-height: 0;
  width: 56px;
  height: 56px;
  padding: 6px;
  border-radius: 12px;
  font-size: 1.35rem;
  line-height: 1;
  box-shadow: 0 4px 10px rgba(31, 55, 72, 0.08);
}

.floating-pad .control-button span {
  font-size: 0.58rem;
}

.floating-pad .control-button.up {
  grid-column: 2;
  grid-row: 1;
}

.floating-pad .control-button.left {
  grid-column: 1;
  grid-row: 2;
}

.floating-pad .control-button.right {
  grid-column: 3;
  grid-row: 2;
}

.floating-pad .control-button.down {
  grid-column: 2;
  grid-row: 3;
}

.pad-core {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pad-core span {
  font-size: 0.52rem;
}

.board-cell,
.number-token,
.player-token {
  position: absolute;
}

.board-cell {
  border-radius: 8px;
  border: 1px solid #d9e4ea;
  background: rgba(255, 255, 255, 0.7);
}

.board-cell::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  border: 1px solid rgba(79, 156, 194, 0.06);
}

.number-token {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #fff3cf;
  border: 2px solid #f0ca73;
  color: #7a5a12;
  font-weight: 800;
  font-size: 1.05rem;
  box-shadow: 0 4px 10px rgba(76, 98, 112, 0.1);
  transition:
    transform 0.18s ease,
    opacity 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

.number-token span {
  position: relative;
  z-index: 1;
}

.number-token.current {
  background: #ffe28c;
  border-color: #eba93e;
  transform: scale(1.08);
}

.number-token.done {
  background: #d8f2dd;
  border-color: #8ec59b;
  color: #245735;
  opacity: 0.88;
}

.player-token {
  width: 46px;
  height: 46px;
  pointer-events: none;
  transition:
    left 0.18s ease,
    top 0.18s ease,
    transform 0.18s ease;
}

.player-shadow {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 2px;
  height: 10px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(22, 52, 67, 0.28), transparent 70%);
  filter: blur(4px);
}

.player-core {
  position: absolute;
  inset: 3px;
  border-radius: 12px;
  background: #5ca8d0;
  border: 2px solid #ffffff;
  box-shadow: 0 4px 10px rgba(31, 55, 72, 0.12);
}

.player-head {
  position: absolute;
  left: 12px;
  top: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffe5c0, #f5be82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.player-book {
  position: absolute;
  left: 9px;
  bottom: 6px;
  width: 24px;
  height: 14px;
  border-radius: 6px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.9) 0 44%, rgba(255, 213, 140, 0.94) 44% 100%);
  border: 1px solid rgba(19, 63, 77, 0.12);
  transform: rotate(-8deg);
}

.player-token.bump {
  animation: player-bump 0.26s ease;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f8fbfd;
  border: 1px solid #d8e3ea;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(255, 143, 90, 0.65);
}

.bottom-dock {
  display: block;
  margin-top: 16px;
}

.control-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-block {
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(33, 94, 126, 0.08);
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0 0 6px;
  font-size: 1.28rem;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.control-button,
.primary-button,
.ghost-button,
.secondary-button,
.small-button {
  border-radius: 14px;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    opacity 0.18s ease;
}

.control-button:hover,
.primary-button:hover,
.ghost-button:hover,
.secondary-button:hover,
.small-button:hover {
  transform: translateY(-1px);
}

.control-button:active,
.primary-button:active,
.ghost-button:active,
.secondary-button:active,
.small-button:active {
  transform: translateY(1px);
}

.control-button {
  min-height: 108px;
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 16px;
  font-size: 2rem;
  font-weight: 800;
  background: #ffffff;
  border: 1px solid #cfd9e0;
  box-shadow: 0 4px 10px rgba(31, 55, 72, 0.08);
}

.control-button span {
  font-size: 0.95rem;
  font-weight: 600;
}

.control-button.up {
  background: #eef7fb;
}

.control-button.left,
.control-button.right {
  background: #eef7fb;
}

.control-button.down {
  background: #eef7fb;
}

.small-button,
.ghost-button,
.secondary-button {
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid #cfd9e0;
}

.primary-button {
  padding: 13px 16px;
  color: #fff;
  font-weight: 800;
  background: var(--accent);
}

.secondary-button {
  flex: 1 1 150px;
}

.scene-actions .primary-button,
.scene-actions .ghost-button {
  flex: 1 1 0;
  min-width: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(36, 55, 70, 0.2);
  z-index: 40;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(460px, 100%);
  padding: 28px;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid #cfd9e0;
  box-shadow: var(--shadow);
}

.overlay-card h2 {
  margin: 0 0 10px;
  font-size: 2rem;
}

.overlay-card p:last-of-type {
  color: var(--text-dim);
  line-height: 1.55;
}

.overlay-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

@keyframes player-bump {
  0%,
  100% {
    transform: translateX(0);
  }
  30% {
    transform: translateX(-6px);
  }
  60% {
    transform: translateX(6px);
  }
}

@media (max-width: 1120px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
  }

  .scene-panel {
    min-height: auto;
  }

  .play-layout {
    grid-template-columns: 1fr;
  }

  .info-sidebar {
    gap: 12px;
  }

  .hud-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .board-stage-layout {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .scene-wrap,
  .board-scene {
    min-height: 460px;
    height: 460px;
  }

  .floating-pad-shell {
    grid-template-columns: 54px 54px 54px;
    grid-template-rows: 54px 54px 54px;
  }

  .floating-pad .control-button {
    width: 54px;
    height: 54px;
    font-size: 1.2rem;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1400px);
    padding-top: 10px;
  }

  .hud-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scene-actions {
    flex-wrap: wrap;
  }

  .board-stage-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .scene-wrap,
  .board-scene {
    width: 100%;
    min-height: 380px;
    height: 380px;
  }

  .control-dock {
    width: 100%;
  }

  .floating-pad-shell {
    grid-template-columns: 48px 48px 48px;
    grid-template-rows: 48px 48px 48px;
    gap: 6px;
    padding: 8px;
    border-radius: 14px;
  }

  .floating-pad .control-button {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    font-size: 1.05rem;
  }

  .floating-pad .control-button span,
  .pad-core span {
    font-size: 0.48rem;
  }
}
