:root {
  --paper: #f5ead7;
  --paper-2: #f0dcc0;
  --paper-3: #fbf5ea;
  --ink: #1f1a14;
  --muted: #5f564a;
  --accent: #1aa3a2;
  --accent-2: #f2b54a;
  --accent-3: #e16a52;
  --panel: rgba(255, 255, 255, 0.78);
  --board: #0f1420;
  --grid: rgba(255, 255, 255, 0.08);
  --glow: rgba(26, 163, 162, 0.25);
  --border: rgba(31, 26, 20, 0.14);
  --shadow: 0 16px 30px -24px rgba(31, 26, 20, 0.35);
  --font-ui: "Space Grotesk", sans-serif;
  --font-display: "Fraunces", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--ink);
  background: radial-gradient(circle at top, #fff7e2 0%, var(--paper) 40%, var(--paper-2) 100%);
}

.bg-orb {
  position: fixed;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  filter: blur(0px);
  opacity: 0.45;
  z-index: -1;
  animation: float 14s ease-in-out infinite;
}

.orb-a {
  top: -80px;
  left: -60px;
  background: radial-gradient(circle, rgba(26, 163, 162, 0.7), transparent 65%);
}

.orb-b {
  bottom: -120px;
  right: -80px;
  background: radial-gradient(circle, rgba(242, 181, 74, 0.6), transparent 65%);
  animation-delay: -4s;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  display: grid;
  gap: 24px;
  animation: fadeInUp 0.8s ease;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.mobile-hud {
  display: none;
  gap: 12px;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.mobile-hud canvas {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(27, 27, 31, 0.08);
}

.mobile-stats {
  display: grid;
  grid-auto-flow: column;
  gap: 10px;
}

.mobile-actions {
  display: inline-flex;
  gap: 6px;
}

.mobile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  text-align: center;
}

.mobile-stat span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.4px;
}

.mobile-stat strong {
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: grid;
  gap: 6px;
}

.logo {
  font-size: 32px;
  letter-spacing: 0.12em;
  font-weight: 600;
  text-transform: uppercase;
  font-family: var(--font-display);
}

.tagline {
  color: var(--muted);
  font-size: 15px;
}

.ghost {
  border: 1px solid var(--border);
  background: var(--ink);
  color: var(--paper-3);
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.portal-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.ghost:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

[data-pause] {
  min-width: 44px;
  text-align: center;
}

[data-restart] {
  min-width: 44px;
  text-align: center;
}

.ghost-compact {
  padding: 6px 12px;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.arena {
  display: grid;
  grid-template-columns: minmax(360px, 720px) minmax(220px, 320px);
  gap: 24px;
  align-items: start;
  justify-content: center;
}

.board-wrap {
  position: relative;
  background: linear-gradient(160deg, #121a2b, #0c101b);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(31, 26, 20, 0.18);
  display: grid;
  gap: 16px;
  width: fit-content;
  max-width: 100%;
  justify-self: start;
  margin: 0 auto;
}

#game {
  display: block;
  width: 100%;
  aspect-ratio: 10 / 20;
  border-radius: 16px;
  background: var(--board);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  max-height: min(80vh, 860px);
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 18px 18px 8px 18px;
  display: grid;
  place-items: center;
  background: rgba(12, 16, 27, 0.65);
  border-radius: 16px;
  backdrop-filter: blur(6px);
  transition: opacity 0.2s ease;
  z-index: 3;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-card {
  background: var(--paper-3);
  color: var(--ink);
  padding: 24px 28px;
  border-radius: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.overlay-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.overlay-sub {
  font-size: 14px;
  color: var(--muted);
}

.side {
  display: grid;
  gap: 16px;
  align-self: start;
}


.panel {
  background: var(--panel);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.panel-title {
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: 1px;
  color: var(--muted);
}

#next {
  width: 100%;
  aspect-ratio: 1;
  background: #fff;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(27, 27, 31, 0.08);
}

.stats {
  display: grid;
  gap: 12px;
}

.stat {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
}

.stat-label {
  color: var(--muted);
  font-weight: 600;
}

.stat-value {
  font-weight: 700;
}

.tips .tip {
  font-size: 14px;
  color: var(--muted);
  padding: 4px 0;
}

.site-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.95rem;
  color: var(--muted);
}

.site-footer a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.site-footer a:hover {
  text-decoration: underline;
}

.footer-copy {
  font-weight: 600;
  letter-spacing: 0.02em;
}

@media (max-width: 900px) {
  .top {
    display: none;
  }

  .brand {
    display: none;
  }

  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app {
    min-height: 100%;
    padding: calc(env(safe-area-inset-top, 0px) + 8px) 16px 16px;
    gap: 0;
  }

  .logo {
    font-size: 22px;
    letter-spacing: 1px;
  }

  .mobile-hud {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    column-gap: 8px;
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 4px 8px;
    border-radius: 10px;
    height: 52px;
    margin-bottom: 0;
  }

  .mobile-hud canvas {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .mobile-stats {
    gap: 8px;
  }

  .mobile-stat {
    font-size: 11px;
    gap: 1px;
  }

  .mobile-stat span {
    font-size: 9px;
  }

  .mobile-stat strong {
    font-size: 12px;
  }

  .mobile-actions {
    justify-self: end;
    gap: 4px;
  }

  .ghost-compact {
    padding: 4px 8px;
    font-size: 11px;
  }

  .side {
    display: none;
  }

  .arena {
    grid-template-columns: 1fr;
    justify-content: start;
    justify-items: center;
  }

  .board-wrap {
    margin: 0;
    justify-self: center;
    align-self: start;
  }

  .overlay {
    inset: 13px 18px 8px 18px;
  }

  .actions .pause-btn {
    display: none;
  }

  .actions #btn-restart {
    display: none;
  }

  .portal-link {
    display: none;
  }

  .site-footer {
    font-size: 0.9rem;
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg-orb {
    animation: none;
  }

  .app {
    animation: none;
  }
}

@keyframes float {
  0% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(18px);
  }
  100% {
    transform: translateY(0px);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
