/* Luplus game-kit: brand tokens, themes and the shared page shell.
   See docs/brand.md for the palette description. */

:root {
  color-scheme: light dark;
  --gk-bg: #f6f4ff;
  --gk-surface: #ffffff;
  --gk-ink: #17132e;
  --gk-muted: #625e80;
  --gk-line: #dcd6f6;
  --gk-primary: #5b3df5;
  --gk-on-primary: #ffffff;
  --gk-accent: #ffb020;
  --gk-on-accent: #17132e;
  --gk-danger: #d93a40;
  --gk-good: #17936a;
  --gk-snow: #ffffff;
  --gk-glow: none;
  --gk-radius: 14px;
  --gk-font: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --gk-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --gk-bg: #110e24;
    --gk-surface: #1c1838;
    --gk-ink: #eeeafe;
    --gk-muted: #a59fc8;
    --gk-line: #342d5e;
    --gk-primary: #8e78ff;
    --gk-on-primary: #110e24;
    --gk-accent: #ffc247;
    --gk-on-accent: #17132e;
    --gk-danger: #ff6b70;
    --gk-good: #3fd39c;
  }
}

/* Winter: icy blues, berry red accent, falling snow (theme.js). */
:root[data-theme="winter"] {
  --gk-bg: #dfeef9;
  --gk-surface: #f8fcff;
  --gk-ink: #0e2a40;
  --gk-muted: #4a6a82;
  --gk-line: #b5d3e8;
  --gk-primary: #1273b8;
  --gk-on-primary: #ffffff;
  --gk-accent: #c8372b;
  --gk-on-accent: #ffffff;
  --gk-danger: #a3271d;
  --gk-good: #177a5b;
  --gk-snow: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="winter"] {
    --gk-bg: #061727;
    --gk-surface: #0e2a43;
    --gk-ink: #e6f3fc;
    --gk-muted: #93b6cf;
    --gk-line: #1f4666;
    --gk-primary: #6cc4f5;
    --gk-on-primary: #061727;
    --gk-accent: #ff7a6b;
    --gk-on-accent: #2a0b07;
    --gk-danger: #ff9d92;
    --gk-good: #5fd8ae;
  }
}

/* Neon: always dark, magenta and cyan with glow. */
:root[data-theme="neon"] {
  color-scheme: dark;
  --gk-bg: #05030d;
  --gk-surface: #120a26;
  --gk-ink: #f4f0ff;
  --gk-muted: #9a90c4;
  --gk-line: #3a1f6b;
  --gk-primary: #ff2bd6;
  --gk-on-primary: #05030d;
  --gk-accent: #19f5e1;
  --gk-on-accent: #05030d;
  --gk-danger: #ff5470;
  --gk-good: #7dff6b;
  --gk-glow: 0 0 12px color-mix(in srgb, var(--gk-primary) 70%, transparent);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--gk-bg);
  color: var(--gk-ink);
  font: 16px/1.45 var(--gk-font);
}

:root[data-theme="winter"] body {
  background: linear-gradient(180deg, var(--gk-bg), var(--gk-surface) 85%) fixed;
}

:root[data-theme="neon"] body {
  background:
    linear-gradient(color-mix(in srgb, var(--gk-accent) 9%, transparent) 1px, transparent 1px) 0 0 / 100% 32px,
    linear-gradient(90deg, color-mix(in srgb, var(--gk-primary) 9%, transparent) 1px, transparent 1px) 0 0 / 32px 100%,
    var(--gk-bg);
}

a {
  color: var(--gk-primary);
}

:focus-visible {
  outline: 3px solid var(--gk-accent);
  outline-offset: 2px;
}

/* Event banner */
.gk-banner {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--gk-accent);
  color: var(--gk-on-accent);
  font-weight: 700;
  font-size: 1.02rem;
  text-align: center;
  overflow-wrap: anywhere;
}

.gk-banner-mark {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  animation: gk-pulse 1.4s ease-in-out infinite;
}

:root[data-theme="neon"] .gk-banner {
  box-shadow: 0 0 24px color-mix(in srgb, var(--gk-accent) 70%, transparent);
}

/* Header */
.gk-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--gk-surface);
  border-bottom: 1px solid var(--gk-line);
}

:root[data-theme="winter"] .gk-header {
  border-bottom: 0;
  margin-bottom: 10px;
}

/* Snow drift under the header */
:root[data-theme="winter"] .gk-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 10px;
  background: radial-gradient(circle at 12px 0, var(--gk-surface) 10px, transparent 11px) 0 0 / 24px 10px repeat-x;
}

:root[data-theme="neon"] .gk-header {
  border-bottom-color: var(--gk-primary);
  box-shadow: var(--gk-glow);
}

.gk-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--gk-ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.gk-logo {
  display: block;
  flex: none;
}

.gk-title {
  padding-left: 12px;
  border-left: 1px solid var(--gk-line);
  color: var(--gk-muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gk-nav {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex: none;
}

:root[data-theme="neon"] .gk-wordmark,
:root[data-theme="neon"] h1 {
  text-shadow: var(--gk-glow);
}

/* Controls */
.gk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--gk-line);
  border-radius: 999px;
  background: var(--gk-surface);
  color: var(--gk-ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.gk-btn:hover {
  border-color: var(--gk-primary);
}

.gk-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.gk-btn-primary {
  background: var(--gk-primary);
  border-color: var(--gk-primary);
  color: var(--gk-on-primary);
  box-shadow: var(--gk-glow);
}

.gk-input {
  min-height: 40px;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--gk-line);
  border-radius: 10px;
  background: var(--gk-bg);
  color: var(--gk-ink);
  font: inherit;
}

/* Page body */
.gk-main {
  flex: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
}

.gk-card {
  background: var(--gk-surface);
  border: 1px solid var(--gk-line);
  border-radius: var(--gk-radius);
}

/* HUD */
.gk-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gk-stat {
  flex: 1 1 0;
  min-width: 76px;
  padding: 6px 10px;
  background: var(--gk-surface);
  border: 1px solid var(--gk-line);
  border-radius: 10px;
}

.gk-stat-label {
  display: block;
  color: var(--gk-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.gk-stat-value {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

.gk-mult {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--gk-accent);
  color: var(--gk-on-accent);
  font-size: 0.95rem;
  font-weight: 800;
  animation: gk-pulse 1.4s ease-in-out infinite;
}

.gk-mult[hidden] {
  display: none;
}

.gk-hint {
  margin: 8px 0 0;
  color: var(--gk-muted);
  font-size: 0.85rem;
}

/* Leaderboard */
.gk-lb {
  flex: 1 1 240px;
  max-width: 420px;
  padding: 14px 16px;
  background: var(--gk-surface);
  border: 1px solid var(--gk-line);
  border-radius: var(--gk-radius);
}

.gk-lb[hidden] {
  display: none;
}

.gk-lb-title {
  margin: 0 0 8px;
  font-size: 1rem;
}

.gk-lb-status {
  margin: 0;
  color: var(--gk-muted);
  font-size: 0.9rem;
}

.gk-lb-list {
  margin: 0;
  padding: 0 0 0 1.6em;
}

.gk-lb-row {
  padding: 3px 0;
}

.gk-lb-row::marker {
  color: var(--gk-muted);
  font-variant-numeric: tabular-nums;
}

.gk-lb-player {
  overflow-wrap: anywhere;
}

.gk-lb-score {
  float: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.gk-lb-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--gk-line);
}

.gk-lb-form[hidden] {
  display: none;
}

.gk-lb-result {
  flex: 1 0 100%;
  margin: 0;
  font-weight: 700;
}

.gk-lb-form .gk-input {
  flex: 1 1 120px;
}

/* Footer */
.gk-footer {
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  color: var(--gk-muted);
  font: 0.7rem/1.4 var(--gk-mono);
  text-align: center;
  overflow-wrap: anywhere;
}

/* Snow overlay (winter theme) */
.gk-snow {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 40;
  pointer-events: none;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="winter"] {
    --gk-snow: #7fb4d8;
  }
}

@keyframes gk-pulse {
  50% {
    transform: scale(1.12);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gk-mult,
  .gk-banner-mark {
    animation: none;
  }
}

@media (max-width: 480px) {
  .gk-header {
    padding: 8px 12px;
    gap: 8px;
  }

  .gk-main {
    padding: 12px;
  }

  .gk-btn {
    padding: 8px 12px;
  }
}
