/**
 * White Studio shared design tokens + primitives
 * Cross-site CSS for Games (primary consumer). Tools / main site may migrate later.
 *
 * Runtime theme: html[data-theme="dark"|"light"]
 * Prefer --ws-* tokens. Tools-style aliases (--accent, --bg, --panel, --text, --muted, --border)
 * are provided for prompt / legacy compatibility.
 */

@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root,
html[data-theme="dark"] {
  color-scheme: dark;

  --ws-bg-page: #0f0f10;
  --ws-bg-shell: #141418;
  --ws-bg-surface: #1a1a1b;
  --ws-bg-surface-raised: #1f2024;
  --ws-bg-surface-muted: rgba(255, 255, 255, 0.045);
  --ws-bg-card: rgba(24, 24, 29, 0.9);
  --ws-bg-card-hover: rgba(31, 32, 36, 0.96);
  --ws-bg-input: rgba(20, 20, 24, 0.88);
  --ws-bg-button: rgba(26, 26, 31, 0.9);
  --ws-bg: var(--ws-bg-page);
  --ws-bg-elev: #16161a;
  --ws-panel: var(--ws-bg-surface);
  --ws-panel-soft: #1e1e24;

  --ws-text-primary: #f4f3fb;
  --ws-text-secondary: #e5e7eb;
  --ws-text-muted: #b9b6ce;
  --ws-text-disabled: #7d8490;
  --ws-text-inverse: #ffffff;

  --ws-border-subtle: #2b2a34;
  --ws-border-strong: rgba(138, 43, 226, 0.34);
  --ws-border-focus: rgba(207, 178, 255, 0.48);

  --ws-accent: #8a2be2;
  --ws-accent-hover: #7b1fa2;
  --ws-accent-2: #b46dff;
  --ws-accent-soft: rgba(138, 43, 226, 0.16);
  --ws-accent-text: #f0e7ff;

  --ws-success: #3bd28f;
  --ws-danger: #ff6b7a;
  --ws-warning: #f59e0b;

  --ws-shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.18);
  --ws-shadow-sm: 0 8px 18px rgba(0, 0, 0, 0.22);
  --ws-shadow-md: 0 14px 34px rgba(0, 0, 0, 0.3);
  --ws-shadow-card: 0 18px 45px rgba(0, 0, 0, 0.24);
  --ws-shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.42);
  --ws-shadow-button: 0 12px 28px rgba(138, 43, 226, 0.28);

  --ws-glass-bg: rgba(20, 20, 28, 0.72);
  --ws-glass-border: rgba(138, 43, 226, 0.22);
  --ws-glass-highlight: rgba(255, 255, 255, 0.08);

  --button-gradient: linear-gradient(to right, #8a2be2, #7b1fa2);
}

html[data-theme="light"] {
  color-scheme: light;

  --ws-bg-page: #f4f5f9;
  --ws-bg-shell: #ffffff;
  --ws-bg-surface: #ffffff;
  --ws-bg-surface-raised: #f9fafc;
  --ws-bg-surface-muted: #eef0f6;
  --ws-bg-card: rgba(255, 255, 255, 0.94);
  --ws-bg-card-hover: #ffffff;
  --ws-bg-input: #ffffff;
  --ws-bg-button: #ffffff;
  --ws-bg: var(--ws-bg-page);
  --ws-bg-elev: #eef0f6;
  --ws-panel: var(--ws-bg-surface);
  --ws-panel-soft: #f3f4f8;

  --ws-text-primary: #161827;
  --ws-text-secondary: #3f4254;
  --ws-text-muted: #6f7285;
  --ws-text-disabled: #9ca3af;
  --ws-text-inverse: #ffffff;

  --ws-border-subtle: rgba(22, 24, 39, 0.1);
  --ws-border-strong: rgba(22, 24, 39, 0.16);
  --ws-border-focus: rgba(124, 58, 237, 0.55);

  --ws-accent: #7c3aed;
  --ws-accent-hover: #6d28d9;
  --ws-accent-2: #8b5cf6;
  --ws-accent-soft: rgba(124, 58, 237, 0.12);
  --ws-accent-text: #5b21b6;

  --ws-success: #0f8a53;
  --ws-danger: #c2414f;
  --ws-warning: #c47a00;

  --ws-shadow-soft: 0 12px 30px rgba(17, 24, 39, 0.08);
  --ws-shadow-sm: 0 8px 18px rgba(17, 24, 39, 0.08);
  --ws-shadow-md: 0 14px 34px rgba(17, 24, 39, 0.1);
  --ws-shadow-card: 0 18px 45px rgba(17, 24, 39, 0.1);
  --ws-shadow-lg: 0 24px 60px rgba(17, 24, 39, 0.14);
  --ws-shadow-button: 0 12px 28px rgba(124, 58, 237, 0.22);

  --ws-glass-bg: rgba(255, 255, 255, 0.78);
  --ws-glass-border: rgba(124, 58, 237, 0.16);
  --ws-glass-highlight: rgba(255, 255, 255, 0.92);

  --button-gradient: linear-gradient(to right, #5b21b6, #6d28d9);
}

:root {
  /* Tools-compatible aliases */
  --bg: var(--ws-bg-page);
  --bg-elev: var(--ws-bg-elev);
  --panel: var(--ws-panel);
  --panel-soft: var(--ws-panel-soft);
  --text: var(--ws-text-primary);
  --muted: var(--ws-text-muted);
  --border: var(--ws-border-subtle);
  --accent: var(--ws-accent);
  --accent-2: var(--ws-accent-2);
  --ok: var(--ws-success);
  --danger: var(--ws-danger);
  --radius-sm: var(--ws-radius-sm);
  --radius-md: var(--ws-radius-md);
  --radius-lg: var(--ws-radius-lg);
  --shadow-sm: var(--ws-shadow-sm);
  --shadow-md: var(--ws-shadow-md);
  --shadow-lg: var(--ws-shadow-lg);
  --dur-fast: var(--ws-duration-fast);
  --dur-mid: var(--ws-duration-mid);
  --ease-out: var(--ws-ease-out);

  --ws-font-body: "Space Grotesk", "Noto Sans TC", "Noto Sans", ui-sans-serif, system-ui, sans-serif;
  --ws-content-max: 76rem;
  --ws-nav-height: 4.25rem;

  --ws-space-1: 0.25rem;
  --ws-space-2: 0.5rem;
  --ws-space-3: 0.75rem;
  --ws-space-4: 1rem;
  --ws-space-5: 1.25rem;
  --ws-space-6: 1.5rem;
  --ws-space-8: 2rem;
  --ws-space-10: 2.5rem;
  --ws-space-12: 3rem;
  --ws-page-inline: clamp(1rem, 2.6vw, 1.75rem);
  --ws-section-space: clamp(2.5rem, 6vw, 4.5rem);

  --ws-radius-sm: 10px;
  --ws-radius-md: 14px;
  --ws-radius-lg: 18px;
  --ws-radius-xl: 24px;
  --ws-radius-pill: 999px;

  --ws-text-xs: 0.78rem;
  --ws-text-sm: 0.9rem;
  --ws-text-md: 1rem;
  --ws-text-lg: 1.2rem;
  --ws-text-xl: 1.55rem;
  --ws-text-hero: clamp(2rem, 4.5vw, 3.1rem);

  --ws-duration-fast: 160ms;
  --ws-duration-mid: 260ms;
  --ws-ease-out: cubic-bezier(0.2, 0, 0, 1);
  --ws-transition-standard: color var(--ws-duration-fast) var(--ws-ease-out),
    background-color var(--ws-duration-fast) var(--ws-ease-out),
    border-color var(--ws-duration-fast) var(--ws-ease-out),
    box-shadow var(--ws-duration-mid) var(--ws-ease-out),
    transform var(--ws-duration-mid) var(--ws-ease-out);

  --ws-focus-ring-shadow: 0 0 0 3px var(--ws-border-focus);
  --ws-z-sticky: 60;
  --ws-z-overlay: 110;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--ws-font-body);
  font-size: var(--ws-text-md);
  line-height: 1.55;
  color: var(--ws-text-primary);
  background:
    radial-gradient(1200px 480px at 12% -10%, rgba(138, 43, 226, 0.18), transparent 55%),
    radial-gradient(900px 420px at 88% 0%, rgba(180, 109, 255, 0.1), transparent 50%),
    var(--ws-bg-page);
}

img,
svg,
canvas {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--ws-focus-ring-shadow);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ws-container {
  width: min(100% - (var(--ws-page-inline) * 2), var(--ws-content-max));
  margin-inline: auto;
}

.ws-site-header {
  position: sticky;
  top: 0;
  z-index: var(--ws-z-sticky);
  min-height: var(--ws-nav-height);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--ws-border-subtle);
  background: color-mix(in srgb, var(--ws-glass-bg) 92%, transparent);
  backdrop-filter: blur(14px);
}

.ws-site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ws-space-4);
  width: min(100% - (var(--ws-page-inline) * 2), var(--ws-content-max));
  margin-inline: auto;
  padding-block: var(--ws-space-3);
}

.ws-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--ws-space-3);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.ws-brand__mark {
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  background: var(--button-gradient);
  box-shadow: var(--ws-shadow-button);
}

.ws-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ws-space-2);
}

.ws-nav a {
  padding: 0.45rem 0.8rem;
  border-radius: var(--ws-radius-pill);
  color: var(--ws-text-muted);
  transition: var(--ws-transition-standard);
}

.ws-nav a[aria-current="page"],
.ws-nav a:hover {
  color: var(--ws-text-primary);
  background: var(--ws-accent-soft);
}

.ws-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ws-space-2);
  min-height: 2.5rem;
  padding: 0.55rem 1.05rem;
  border: 1px solid transparent;
  border-radius: var(--ws-radius-pill);
  background: var(--ws-bg-button);
  color: var(--ws-text-primary);
  cursor: pointer;
  transition: var(--ws-transition-standard);
}

.ws-button:hover {
  background: var(--ws-bg-card-hover);
}

.ws-button--primary {
  background: var(--button-gradient);
  color: var(--ws-text-inverse);
  box-shadow: var(--ws-shadow-button);
}

.ws-button--primary:hover {
  filter: brightness(1.05);
}

.ws-button--ghost {
  border-color: var(--ws-border-subtle);
  background: transparent;
}

.ws-button--ghost:hover {
  border-color: var(--ws-border-strong);
  background: var(--ws-accent-soft);
}

.ws-card {
  display: flex;
  flex-direction: column;
  gap: var(--ws-space-3);
  padding: var(--ws-space-5);
  border: 1px solid var(--ws-border-subtle);
  border-radius: var(--ws-radius-md);
  background: var(--ws-bg-card);
  box-shadow: var(--ws-shadow-sm);
  transition: var(--ws-transition-standard);
}

a.ws-card:hover,
.ws-card:hover {
  border-color: var(--ws-border-strong);
  background: var(--ws-bg-card-hover);
  box-shadow: var(--ws-shadow-card);
  transform: translateY(-2px);
}

.ws-card__eyebrow {
  margin: 0;
  color: var(--ws-accent-2);
  font-size: var(--ws-text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ws-card__title {
  margin: 0;
  font-size: var(--ws-text-lg);
  font-weight: 700;
}

.ws-card__body {
  margin: 0;
  color: var(--ws-text-muted);
  font-size: var(--ws-text-sm);
}

.ws-hero {
  padding-block: var(--ws-section-space) var(--ws-space-8);
}

.ws-hero__title {
  margin: 0 0 var(--ws-space-4);
  font-size: var(--ws-text-hero);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.ws-hero__lede {
  margin: 0;
  max-width: 38rem;
  color: var(--ws-text-muted);
  font-size: var(--ws-text-lg);
}

.ws-section {
  padding-block: var(--ws-space-8) var(--ws-section-space);
}

.ws-section__title {
  margin: 0 0 var(--ws-space-2);
  font-size: var(--ws-text-xl);
}

.ws-section__lede {
  margin: 0 0 var(--ws-space-6);
  color: var(--ws-text-muted);
}

.ws-grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--ws-space-4);
}

.ws-field {
  display: flex;
  flex-direction: column;
  gap: var(--ws-space-2);
}

.ws-field label {
  font-size: var(--ws-text-sm);
  color: var(--ws-text-muted);
}

.ws-input {
  min-height: 2.6rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--ws-border-subtle);
  border-radius: var(--ws-radius-sm);
  background: var(--ws-bg-input);
  transition: var(--ws-transition-standard);
}

.ws-input:focus-visible {
  border-color: var(--ws-accent);
}

.ws-leaderboard {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--ws-text-sm);
}

.ws-leaderboard th,
.ws-leaderboard td {
  padding: 0.7rem 0.55rem;
  text-align: left;
  border-bottom: 1px solid var(--ws-border-subtle);
}

.ws-leaderboard th {
  color: var(--ws-text-muted);
  font-weight: 600;
}

.ws-leaderboard tr:first-child td:first-child {
  color: var(--ws-accent-2);
  font-weight: 700;
}

.ws-status {
  margin: 0;
  color: var(--ws-text-muted);
  font-size: var(--ws-text-sm);
}

.ws-status--error {
  color: var(--ws-danger);
}

.ws-status--ok {
  color: var(--ws-success);
}

.ws-site-footer {
  margin-top: auto;
  padding: var(--ws-space-8) 0 var(--ws-space-10);
  border-top: 1px solid var(--ws-border-subtle);
  color: var(--ws-text-muted);
  font-size: var(--ws-text-sm);
}

.ws-site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ws-space-4);
  justify-content: space-between;
  align-items: center;
}

.ws-game-shell {
  display: grid;
  gap: var(--ws-space-4);
}

.ws-game-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--ws-border-subtle);
  border-radius: var(--ws-radius-lg);
  background: #0a0a0d;
  box-shadow: var(--ws-shadow-md);
  min-height: min(70vh, 520px);
}

.ws-game-hud {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ws-space-3);
  align-items: center;
  justify-content: space-between;
}

@media (max-width: 640px) {
  .ws-site-header__inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .ws-hero__title {
    font-size: clamp(1.7rem, 9vw, 2.2rem);
  }
}

@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;
  }
}
