/* ==========================================================================
   Guessquatch — Global Weathered Woodgrain Trail-Sign Theme System
   Warm parchment (#EAE6DF) in Day Mode and deep forest-charcoal (#121715)
   in Night Mode, with weathered cedar woodgrain sign slats, solid dark
   bottom lips, recessed dark-wood troughs & badges, and warm off-white text.
   ========================================================================== */

:root,
html[data-theme="night"] {
  color-scheme: dark;

  /* Typography */
  --font-sans: 'Overpass', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Overpass', ui-monospace, SFMono-Regular, Consolas, monospace;

  /* Night Canvas — Deep Forest-Charcoal */
  --bg-canvas: #121715;

  /* Weathered Woodgrain Signpost & Slat Tokens (Night — Darker Weathered Cedar) */
  --wood-bg: #5D442F;
  --wood-slat-overlay: rgba(15, 11, 8, 0.38);
  --wood-post-overlay: rgba(12, 9, 6, 0.44);
  --wood-border: #281D14;
  --wood-bevel-top: rgba(255, 228, 192, 0.14);
  --wood-bevel-bottom: rgba(16, 9, 4, 0.42);
  --wood-lip: #130D08;
  --wood-shadow: rgba(0, 0, 0, 0.56);
  --wood-text: #F4F1EA;
  --wood-text-sub: #DDD4C6;
  --wood-text-muted: #CFC3B0;
  --wood-divider: rgba(255, 224, 184, 0.15);

  /* Recessed Dark-Wood Badges & Input Troughs (Night) */
  --wood-streak-bg: rgba(15, 10, 6, 0.76);
  --wood-streak-border: rgba(255, 224, 184, 0.14);
  --wood-trough-bg: rgba(14, 9, 5, 0.80);
  --wood-trough-solid: #1A110A;
  --wood-trough-border: rgba(235, 205, 165, 0.22);
  --wood-trough-border-focus: #E6BC6A;
  --wood-focus: #E6BC6A;

  /* Tactile Woodgrain Buttons (Night) */
  --wood-btn-bg: #6B5038;
  --wood-btn-bg-hover: #76593F;
  --wood-btn-tint: rgba(18, 12, 7, 0.24);
  --wood-btn-tint-hover: rgba(255, 236, 208, 0.10);
  --wood-btn-border: rgba(220, 194, 160, 0.28);
  --wood-btn-lip: #120B06;
  --blaze-grain-opacity: 0.40;

  /* Chunky Wooden Letter Tiles & Keyboard Keys (Night) */
  --wood-tile-bg: #5B422D;
  --wood-tile-overlay: rgba(16, 10, 6, 0.36);
  --wood-tile-border: rgba(228, 202, 168, 0.32);
  --wood-tile-filled-border: #E8C56E;
  --wood-tile-lip: #160F08;
  --wood-kb-bg: #614731;
  --wood-kb-overlay: rgba(16, 10, 6, 0.34);
  --wood-kb-wide-overlay: rgba(14, 9, 5, 0.52);
  --wood-kb-border: rgba(228, 202, 168, 0.30);
  --wood-kb-lip: #140D07;
  --wood-kb-absent-bg: #261A11;
  --wood-kb-absent-border: #3B291B;
  --wood-kb-absent-lip: #100A05;
  --wood-kb-absent-text: #8C7A68;

  /* Semantic Surface Aliases Mapped to Woodgrain System (Zero Dark-Gray) */
  --surface-plate: var(--wood-bg);
  --surface-elevated: var(--wood-btn-bg);
  --surface-inset: var(--wood-trough-bg);
  --surface-highway: var(--wood-bg);

  /* Masthead Logo & Minimal Topbar (Night) */
  --logo-stroke: #7EC8F2;
  --topbar-btn-bg: transparent;
  --topbar-btn-bg-hover: rgba(244, 241, 234, 0.09);
  --topbar-btn-border: transparent;
  --topbar-btn-lip: transparent;
  --topbar-btn-text: #EAE4D8;
  --home-rule: rgba(235, 208, 172, 0.16);

  /* Borders & Lips */
  --border-plate: var(--wood-divider);
  --border-strong: var(--wood-trough-border);
  --border-divider: rgba(235, 208, 172, 0.16);
  --border-highway: var(--wood-border);
  --lip-plate: var(--wood-lip);
  --lip-inset: var(--wood-lip);

  /* Canvas Typography (Night — Warm Off-White) */
  --text-primary: #F4F1EA;
  --text-secondary: #D4CABB;
  --text-muted: #A99C8B;
  --text-highway: #F4F1EA;

  /* Trail-Sign Sky Accent (Matches Home CREATE ROOM) */
  --accent: #7EC1EB;
  --accent-strong: #8FCCF2;
  --accent-border: #A4D7F6;
  --accent-lip: #36739C;
  --on-accent: #18232B;

  /* Painted Enamel Trail-Blaze Accents (4 Games) */
  --blaze-tracks: #E2691C;
  --blaze-tracks-hover: #ED772B;
  --blaze-tracks-border: #F28C4A;
  --blaze-tracks-lip: #8A3908;

  --blaze-footprints: #3288D4;
  --blaze-footprints-hover: #4096E0;
  --blaze-footprints-border: #62ACEB;
  --blaze-footprints-lip: #184E82;

  --blaze-forage: #F0C424;
  --blaze-forage-hover: #F7CF3B;
  --blaze-forage-border: #F9DC6B;
  --blaze-forage-lip: #967308;

  --blaze-campfire: #D43D34;
  --blaze-campfire-hover: #E04B42;
  --blaze-campfire-border: #EE6C64;
  --blaze-campfire-lip: #7F1D17;

  /* High-Contrast Evaluated Letter Tile States */
  --tile-empty-bg: var(--wood-tile-bg);
  --tile-empty-border: var(--wood-tile-border);
  --tile-empty-lip: var(--wood-tile-lip);
  --tile-filled-border: var(--wood-tile-filled-border);

  --tile-correct-bg: #268E52;
  --tile-correct-border: #44BF78;
  --tile-correct-lip: #114D2A;
  --tile-correct-text: #F6F2EA;

  --tile-present-bg: #E8B923;
  --tile-present-border: #F6D565;
  --tile-present-lip: #8D6B08;
  --tile-present-text: #1B1610;

  --tile-absent-bg: #3D352E;
  --tile-absent-border: #594D43;
  --tile-absent-lip: #1E1813;
  --tile-absent-text: #CFC5B9;

  /* Keyboard Keys */
  --kb-bg: var(--wood-kb-bg);
  --kb-border: var(--wood-kb-border);
  --kb-lip: var(--wood-kb-lip);
  --kb-text: var(--wood-text);

  --kb-wide-bg: #4A3524;
  --kb-wide-border: var(--wood-kb-border);
  --kb-wide-lip: var(--wood-kb-lip);
  --kb-wide-text: var(--wood-text);

  --kb-absent-bg: var(--wood-kb-absent-bg);
  --kb-absent-border: var(--wood-kb-absent-border);
  --kb-absent-lip: var(--wood-kb-absent-lip);
  --kb-absent-text: var(--wood-kb-absent-text);

  /* Semantic Status */
  --status-success: #38B46E;
  --status-success-lip: #195E36;
  --status-warning: #F0C424;
  --status-warning-lip: #8F6D08;
  --status-error: #D9483F;
  --status-error-lip: #7F1D17;
  --status-info: #7EC1EB;
  --status-info-lip: #36739C;

  /* Overlay */
  --backdrop-color: rgba(10, 13, 11, 0.80);

  /* Trail-Sign Radii */
  --radius-sm: 5px;
  --radius-md: 7px;
  --radius-lg: 8px;
}

html[data-theme="day"] {
  color-scheme: light;

  /* Day Canvas — Warm Textured Parchment */
  --bg-canvas: #EAE6DF;

  /* Weathered Woodgrain Signpost & Slat Tokens (Day — Warm Rustic Cedar) */
  --wood-bg: #5D442F;
  --wood-slat-overlay: rgba(34, 21, 10, 0.14);
  --wood-post-overlay: rgba(30, 18, 9, 0.22);
  --wood-border: #3B2717;
  --wood-bevel-top: rgba(255, 236, 206, 0.24);
  --wood-bevel-bottom: rgba(16, 9, 4, 0.42);
  --wood-lip: #2C1D11;
  --wood-shadow: rgba(26, 16, 8, 0.30);
  --wood-text: #F5F1E8;
  --wood-text-sub: #E9E0D2;
  --wood-text-muted: #DDD2C1;
  --wood-divider: rgba(255, 228, 192, 0.18);

  /* Recessed Dark-Wood Badges & Input Troughs (Day) */
  --wood-streak-bg: rgba(28, 18, 11, 0.72);
  --wood-streak-border: rgba(255, 224, 184, 0.16);
  --wood-trough-bg: rgba(28, 18, 10, 0.74);
  --wood-trough-solid: #2C1D12;
  --wood-trough-border: rgba(242, 216, 182, 0.26);
  --wood-trough-border-focus: #F0C424;
  --wood-focus: #D99B26;

  /* Tactile Woodgrain Buttons (Day) */
  --wood-btn-bg: #6B5038;
  --wood-btn-bg-hover: #765A40;
  --wood-btn-tint: rgba(255, 238, 212, 0.10);
  --wood-btn-tint-hover: rgba(255, 242, 220, 0.22);
  --wood-btn-border: rgba(235, 208, 172, 0.36);
  --wood-btn-lip: #26180D;
  --blaze-grain-opacity: 0.36;

  /* Chunky Wooden Letter Tiles & Keyboard Keys (Day) */
  --wood-tile-bg: #654A33;
  --wood-tile-overlay: rgba(30, 18, 9, 0.12);
  --wood-tile-border: rgba(240, 216, 184, 0.38);
  --wood-tile-filled-border: #F4CE5A;
  --wood-tile-lip: #2A1B0F;
  --wood-kb-bg: #6A4F37;
  --wood-kb-overlay: rgba(28, 17, 9, 0.12);
  --wood-kb-wide-overlay: rgba(26, 16, 8, 0.34);
  --wood-kb-border: rgba(240, 216, 184, 0.36);
  --wood-kb-lip: #26180D;
  --wood-kb-absent-bg: #3D2C1F;
  --wood-kb-absent-border: #543D2C;
  --wood-kb-absent-lip: #22160D;
  --wood-kb-absent-text: #B09D8A;

  /* Masthead Logo & Minimal Topbar (Day) */
  --logo-stroke: #6FA9D2;
  --topbar-btn-bg: transparent;
  --topbar-btn-bg-hover: rgba(59, 39, 23, 0.09);
  --topbar-btn-border: transparent;
  --topbar-btn-lip: transparent;
  --topbar-btn-text: #2B2118;
  --home-rule: rgba(59, 39, 23, 0.22);

  /* Borders & Section Dividers on Parchment */
  --border-plate: rgba(59, 39, 23, 0.26);
  --border-strong: rgba(59, 39, 23, 0.42);
  --border-divider: rgba(59, 39, 23, 0.24);
  --border-highway: var(--wood-border);
  --lip-plate: var(--wood-lip);
  --lip-inset: var(--wood-lip);

  /* Bold Dark-Ink Typography on Warm Parchment */
  --text-primary: #2B2118;
  --text-secondary: #4D3D2E;
  --text-muted: #6E5B49;
  --text-highway: #F5F1E8;

  /* High-Contrast Evaluated Tile States (Day) */
  --tile-correct-bg: #268A4F;
  --tile-correct-border: #3EB56E;
  --tile-correct-lip: #124B29;
  --tile-correct-text: #F6F2EA;

  --tile-present-bg: #E8B923;
  --tile-present-border: #F5D25B;
  --tile-present-lip: #8D6B08;
  --tile-present-text: #1B1610;

  --tile-absent-bg: #4B433B;
  --tile-absent-border: #665B50;
  --tile-absent-lip: #2A231E;
  --tile-absent-text: #EAE2D8;

  /* Overlay */
  --backdrop-color: rgba(24, 17, 11, 0.68);
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url('../assets/parchment-day.jpg');
  background-repeat: repeat;
  background-size: 480px 480px;
}

html[data-theme="day"] body::before {
  opacity: 0.72;
  mix-blend-mode: multiply;
}

html[data-theme="night"] body::before {
  opacity: 0.05;
  mix-blend-mode: screen;
}

button,
input,
textarea {
  font-family: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--wood-focus);
  outline-offset: 2px;
}

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

[hidden] {
  display: none !important;
}
