@font-face {
  font-family: "Space Grotesk";
  src: url("../fonts/space-grotesk.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-display: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --bg: #080809;
  --bg-elevated: #0e0e10;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-raised: rgba(255, 255, 255, 0.065);
  --surface-solid: #111113;
  --glass: rgba(12, 12, 14, 0.82);
  --header-bg: rgba(8, 8, 9, 0.72);
  --text: #f2f2ef;
  --text-soft: #c7c7c2;
  --muted: #8b8b90;
  --faint: #5c5c62;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.22);
  --inverse: #f2f2ef;
  --inverse-text: #0a0a0b;
  --shadow: rgba(0, 0, 0, 0.4);
  --shadow-strong: rgba(0, 0, 0, 0.65);
  --scrim: rgba(3, 3, 4, 0.74);
  --grid-line: rgba(255, 255, 255, 0.034);
  --spotlight: rgba(255, 255, 255, 0.055);
  --winner-glow: rgba(255, 255, 255, 0.1);
  --noise-opacity: 0.048;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --header-h: 74px;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f2f2ef;
  --bg-elevated: #e9e9e5;
  --surface: rgba(255, 255, 255, 0.57);
  --surface-raised: rgba(255, 255, 255, 0.92);
  --surface-solid: #fafaf8;
  --glass: rgba(246, 246, 242, 0.86);
  --header-bg: rgba(242, 242, 239, 0.74);
  --text: #121214;
  --text-soft: #303033;
  --muted: #6a6a6e;
  --faint: #9a9a96;
  --line: rgba(0, 0, 0, 0.1);
  --line-strong: rgba(0, 0, 0, 0.26);
  --inverse: #121214;
  --inverse-text: #f7f7f4;
  --shadow: rgba(20, 20, 20, 0.09);
  --shadow-strong: rgba(20, 20, 20, 0.17);
  --scrim: rgba(224, 224, 218, 0.7);
  --grid-line: rgba(0, 0, 0, 0.042);
  --spotlight: rgba(255, 255, 255, 0.65);
  --winner-glow: rgba(0, 0, 0, 0.055);
  --noise-opacity: 0.025;
  color-scheme: light;
}

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

* {
  margin: 0;
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 73% 12%, var(--spotlight), transparent 31%),
    radial-gradient(circle at 15% 84%, var(--spotlight), transparent 25%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.45s ease, color 0.35s ease;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(circle at 50% 22%, #000 0%, transparent 82%);
  mask-image: radial-gradient(circle at 50% 22%, #000 0%, transparent 82%);
}

body::after {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  content: "";
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.86' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

body.layer-open {
  overflow: hidden;
}

body.theme-switching *,
body.theme-switching *::before,
body.theme-switching *::after {
  transition-duration: 0.45s !important;
  transition-property: background-color, border-color, color, box-shadow, fill, stroke !important;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 3px;
}

::selection {
  background: var(--text);
  color: var(--bg);
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--line-strong);
  background-clip: content-box;
}

[hidden] {
  display: none !important;
}

.sr-only {
  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;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 500;
  padding: 9px 14px;
  transform: translateY(-160%);
  border-radius: 6px;
  background: var(--inverse);
  color: var(--inverse-text);
  font-family: var(--font-mono);
  font-size: 11px;
  text-decoration: none;
  transition: transform 0.2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

.main-content {
  flex: 1;
  width: 100%;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  padding: 0 clamp(18px, 3.8vw, 58px);
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(22px) saturate(100%);
  backdrop-filter: blur(22px) saturate(100%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 5px 0;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), border-color 0.3s ease;
}

.brand-mark svg {
  width: 27px;
  height: 27px;
}

.brand:hover .brand-mark {
  transform: rotate(180deg);
  border-color: var(--text);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-copy strong {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.19em;
  line-height: 1.1;
}

.brand-copy small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.21em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 11px;
  border-radius: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.nav-button svg {
  width: 16px;
  height: 16px;
}

.nav-button:hover {
  background: var(--surface);
  color: var(--text);
}

.header-rule {
  width: 1px;
  height: 17px;
  margin: 0 6px;
  background: var(--line);
}

.icon-button {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
  transform: translateY(-1px);
}

.icon-button:active {
  transform: translateY(0) scale(0.96);
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.theme-icon {
  position: absolute;
  transition: opacity 0.25s ease, transform 0.35s ease;
}

html[data-theme="dark"] .theme-icon-sun,
html[data-theme="light"] .theme-icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

html[data-theme="dark"] .theme-icon-moon,
html[data-theme="light"] .theme-icon-sun {
  opacity: 0;
  transform: rotate(-55deg) scale(0.4);
}

.sound-off {
  display: none;
}

#soundToggle[aria-pressed="true"] .sound-on {
  display: none;
}

#soundToggle[aria-pressed="true"] .sound-off {
  display: block;
}

.section-kicker {
  display: block;
  margin-bottom: 7px;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.17em;
  line-height: 1.2;
  text-transform: uppercase;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  min-height: 54px;
  padding: 0 18px;
  border: 1px solid var(--inverse);
  border-radius: 8px;
  background: var(--inverse);
  color: var(--inverse-text);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.11em;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.primary-button svg {
  width: 17px;
  height: 17px;
  transition: transform 0.25s ease;
}

.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px var(--shadow);
}

.primary-button:hover svg {
  transform: translateX(4px);
}

.primary-button:active {
  transform: translateY(0);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
  transform: none;
  box-shadow: none;
}

.primary-button.compact {
  width: auto;
  min-height: 42px;
  padding: 0 22px;
  font-size: 8px;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 20px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.secondary-button:hover {
  background: var(--surface-raised);
  border-color: var(--text);
  transform: translateY(-1px);
}

.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.mini-button svg {
  width: 12px;
  height: 12px;
}

.mini-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-raised);
  color: var(--text);
}

.chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 19px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px clamp(20px, 4vw, 58px);
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.1em;
}

body.in-game .site-footer {
  display: none;
}

.glyph {
  display: block;
  overflow: visible;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes text-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slow-spin {
  to { transform: rotate(360deg); }
}

@keyframes soft-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

@keyframes think-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@keyframes score-bump {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-6px) scale(1.15); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes card-reveal {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes winner-pulse {
  0% { transform: scale(0.985); }
  45% { transform: scale(1.012); }
  100% { transform: scale(1); }
}

@keyframes count-punch {
  from { opacity: 0; transform: scale(1.28); filter: blur(4px); }
  55% { opacity: 1; transform: scale(1); filter: blur(0); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes countdown-progress {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes unlock-card {
  0% { border-color: var(--line); opacity: 0.35; transform: translateY(8px) scale(0.94); }
  35% { border-color: var(--text); opacity: 1; transform: translateY(-4px) scale(1.02); box-shadow: 0 0 0 1px var(--text), 0 12px 34px var(--shadow); }
  100% { border-color: var(--line); opacity: 1; transform: translateY(0) scale(1); box-shadow: none; }
}

@keyframes drawer-in {
  from { opacity: 0; transform: translateX(38px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes end-in {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-7px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-5px); }
}

@media (max-width: 900px) {
  :root { --header-h: 66px; }
  .site-footer .footer-center { display: none; }
}

@media (max-width: 680px) {
  :root { --header-h: 60px; }
  .site-header { padding-right: 13px; padding-left: 15px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-mark svg { width: 24px; height: 24px; }
  .brand-copy strong { font-size: 13px; }
  .brand-copy small { font-size: 6px; }
  .header-actions { gap: 3px; }
  .nav-button { width: 34px; min-height: 34px; padding: 0; justify-content: center; }
  .nav-button svg { width: 17px; height: 17px; }
  .nav-label {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
  }
  .icon-button { width: 34px; height: 34px; }
  .icon-button svg { width: 16px; height: 16px; }
  .header-rule { margin: 0 3px; }
  .primary-button { min-height: 49px; }
  .site-footer { font-size: 6px; padding: 15px; }
}

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