/* ============================================================
   Daily Games — Shared Stylesheet
   Compatible with all modern browsers; no build step required.
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --radius:       12px;
  --radius-sm:    8px;

  /* Game accent colours (shared across all themes) */
  --heist-log:       #f59e0b;
  --semantic-steps:  #10b981;
  --synapse:         #8b5cf6;
  --plot-mash:       #ef4444;
  --etymology-tree:  #3b82f6;
  --vibe-check:      #ec4899;
  --red-thread:      #dc2626;
  --lost-translation:#06b6d4;
  --nesting-grounds:  #84cc16;
  --script-swap:      #f97316;
  --before-or-after:  #e879f9;
  --the-connection:   #f59e0b;
  --cipher:           #a855f7;
  --dice-duel:        #14b8a6;
}

/* ── Dark theme (default) ────────────────────────────────── */
:root, [data-theme="dark"] {
  --bg-primary:   #0f172a;
  --bg-card:      #1e293b;
  --bg-card-h:    #263348;
  --bg-input:     #0f172a;
  --text-primary: #e2e8f0;
  --text-sec:     #94a3b8;
  --text-muted:   #64748b;
  --border:       #334155;
  --border-focus: #60a5fa;
  --shadow:       0 4px 24px rgba(0,0,0,.45);
  --border-width: 1px;
  --settings-backdrop: rgba(0,0,0,.6);
}

/* ── Light theme ─────────────────────────────────────────── */
[data-theme="light"] {
  --bg-primary:   #f8fafc;
  --bg-card:      #ffffff;
  --bg-card-h:    #f1f5f9;
  --bg-input:     #ffffff;
  --text-primary: #1e293b;
  --text-sec:     #475569;
  --text-muted:   #94a3b8;
  --border:       #e2e8f0;
  --border-focus: #3b82f6;
  --shadow:       0 4px 24px rgba(0,0,0,.08);
  --border-width: 1px;
  --settings-backdrop: rgba(0,0,0,.35);
}

/* ── High-contrast theme ─────────────────────────────────── */
[data-theme="high-contrast"] {
  --bg-primary:   #000000;
  --bg-card:      #1a1a1a;
  --bg-card-h:    #2a2a2a;
  --bg-input:     #000000;
  --text-primary: #ffffff;
  --text-sec:     #e0e0e0;
  --text-muted:   #b0b0b0;
  --border:       #555555;
  --border-focus: #60a5fa;
  --shadow:       0 4px 24px rgba(0,0,0,.7);
  --border-width: 2px;
  --settings-backdrop: rgba(0,0,0,.8);
}
[data-theme="high-contrast"] .game-card,
[data-theme="high-contrast"] .panel,
[data-theme="high-contrast"] .share-box,
[data-theme="high-contrast"] .word-tile,
[data-theme="high-contrast"] .input-field,
[data-theme="high-contrast"] .result-banner {
  border-width: 2px;
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input  { font-family: inherit; }

/* ── Layout helpers ───────────────────────────────────────── */
.container { max-width: 960px; margin: 0 auto; padding: 0 1.25rem; }
.page-wrap  { max-width: 680px; margin: 0 auto; padding: 0 1.25rem; }

/* ── Site header ──────────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  margin-bottom: 2.5rem;
}
.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-logo {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}
.site-logo span { color: var(--accent, #60a5fa); }
.back-link {
  font-size: .85rem;
  color: var(--text-sec);
  display: flex;
  align-items: center;
  gap: .35rem;
  transition: color .15s;
}
.back-link:hover { color: var(--text-primary); }

/* ── Game page header ─────────────────────────────────────── */
.game-header {
  margin-bottom: 2rem;
  text-align: center;
}
.game-header .badge {
  display: inline-block;
  padding: .25rem .75rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
  margin-bottom: .75rem;
}
.game-header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: .5rem;
}
.game-header p {
  color: var(--text-sec);
  font-size: 1rem;
  max-width: 520px;
  margin: 0 auto;
}

/* ── Cards (landing page) ─────────────────────────────────── */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  padding-bottom: 3rem;
}
.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.35rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  transition: transform .15s, border-color .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
}
.game-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-accent, #60a5fa);
}
.game-card:hover {
  transform: translateY(-2px);
  border-color: var(--card-accent, #60a5fa);
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.game-card .tag {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--card-accent, #60a5fa);
}
.game-card h2 { font-size: 1.05rem; font-weight: 700; }
.game-card p  { font-size: .85rem; color: var(--text-sec); flex: 1; }
.game-card .card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .25rem;
}
.game-card .status-pill {
  font-size: .7rem;
  padding: .2rem .6rem;
  border-radius: 99px;
  font-weight: 600;
}
.status-pill.live    { background: rgba(16,185,129,.15); color: #10b981; }
.status-pill.soon    { background: rgba(100,116,139,.15); color: var(--text-muted); }
.btn-play {
  background: var(--card-accent, #60a5fa);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: .4rem .9rem;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  transition: opacity .15s;
}
.btn-play:hover { opacity: .85; }
.btn-play.disabled {
  background: var(--border);
  color: var(--text-muted);
  pointer-events: none;
}

/* ── Generic button styles ────────────────────────────────── */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: .65rem 1.5rem;
  font-size: .9rem;
  font-weight: 700;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--accent, #60a5fa);
  color: #fff;
}
.btn-primary:hover { opacity: .88; }
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-sec);
  border: 1px solid var(--border);
}
.btn-secondary:hover { color: var(--text-primary); border-color: var(--text-sec); }
.btn-ghost {
  background: transparent;
  color: var(--accent, #60a5fa);
  border: 1.5px solid var(--accent, #60a5fa);
}
.btn-ghost:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.btn-row {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 1.25rem;
}

/* ── Input ────────────────────────────────────────────────── */
.input-field {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: .65rem 1rem;
  font-size: 1rem;
  width: 100%;
  transition: border-color .15s;
  outline: none;
}
.input-field:focus { border-color: var(--accent, var(--border-focus)); }
.input-field::placeholder { color: var(--text-muted); }
.input-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-sec);
  margin-bottom: .4rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ── Game panels / boxes ──────────────────────────────────── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

/* ── Result overlays ──────────────────────────────────────── */
.result-banner {
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  text-align: center;
  display: none;
  margin-top: 1.25rem;
}
.result-banner.win  { background: rgba(16,185,129,.12); border: 1px solid #10b981; }
.result-banner.lose { background: rgba(239,68,68,.12);  border: 1px solid #ef4444; }
.result-banner.show { display: block; }
.result-banner h2   { font-size: 1.4rem; margin-bottom: .35rem; }
.result-banner p    { font-size: .9rem; color: var(--text-sec); }

/* ── Word tile (Red Thread) ───────────────────────────────── */
.word-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .6rem;
  margin: 1.5rem 0;
}
.word-tile {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem .5rem;
  text-align: center;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
  user-select: none;
}
.word-tile:hover:not(.disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-card));
  transform: scale(1.03);
}
.word-tile.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--bg-card)); }
.word-tile.correct  { border-color: #10b981; background: rgba(16,185,129,.15); color: #10b981; }
.word-tile.wrong    { border-color: #ef4444; background: rgba(239,68,68,.12);  color: #ef4444; animation: shake .3s ease; }
.word-tile.theme    { border-color: var(--border); background: rgba(100,116,139,.1); color: var(--text-muted); }
.word-tile.disabled { cursor: default; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}

/* ── Progress / guesses tracker ──────────────────────────── */
.guesses-row {
  display: flex;
  gap: .4rem;
  justify-content: center;
  margin: .75rem 0;
}
.guess-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
}
.guess-dot.used  { background: var(--text-muted); }
.guess-dot.wrong { background: #ef4444; }
.guess-dot.right { background: #10b981; }

/* ── Coming Soon page ─────────────────────────────────────── */
.coming-soon {
  text-align: center;
  padding: 3rem 1.5rem;
}
.coming-soon .big-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  filter: grayscale(0);
}
.coming-soon h2 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: .5rem;
}
.coming-soon .subtitle {
  color: var(--text-sec);
  margin-bottom: 2rem;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}
.mechanic-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  max-width: 420px;
  margin: 0 auto 2rem;
  text-align: left;
}
.mechanic-list li {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .65rem 1rem;
  font-size: .9rem;
  color: var(--text-sec);
  display: flex;
  align-items: flex-start;
  gap: .6rem;
}
.mechanic-list li::before {
  content: '→';
  color: var(--accent);
  flex-shrink: 0;
  margin-top: .05rem;
}

/* ── Share box ────────────────────────────────────────────── */
.share-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  display: none;
  margin-top: 1rem;
}
.share-box.show { display: block; }
.share-text {
  font-family: monospace;
  font-size: .85rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
  margin: .75rem 0;
  line-height: 1.5;
}
.share-copied { color: #10b981; font-size: .8rem; display: none; margin-top: .4rem; }
.share-copied.show { display: block; }

/* ── Give Up button ───────────────────────────────────────── */
.btn-give-up {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem 1.2rem;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.btn-give-up:hover {
  color: #ef4444;
  border-color: #ef4444;
}

/* ── Back to games link (bottom of each game) ────────────── */
.back-to-games {
  display: block;
  text-align: center;
  margin: 3.5rem auto 0;
  padding: .75rem 1.5rem;
  font-size: .9rem;
  font-weight: 700;
  color: var(--accent, #60a5fa);
  background: transparent;
  border: 1.5px solid var(--accent, #60a5fa);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background .15s, color .15s;
  max-width: 240px;
}
.back-to-games:hover {
  background: color-mix(in srgb, var(--accent, #60a5fa) 12%, transparent);
  color: #fff;
}

/* ── Settings gear button ─────────────────────────────────── */
.btn-settings {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  padding: .35rem;
  cursor: pointer;
  transition: color .15s, transform .15s;
  line-height: 1;
  display: flex;
  align-items: center;
}
.btn-settings:hover {
  color: var(--text-primary);
  transform: rotate(30deg);
}

/* ── Settings overlay ────────────────────────────────────── */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: var(--settings-backdrop);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.settings-overlay.open { display: flex; }

.settings-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow);
}
.settings-panel h2 {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.settings-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: .2rem;
  line-height: 1;
  transition: color .15s;
}
.settings-close:hover { color: var(--text-primary); }

.theme-options {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}
.theme-option {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .85rem 1rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, opacity .15s;
}
.theme-option:hover { opacity: .85; }
.theme-option.active {
  border-color: var(--accent, #60a5fa);
}
/* Each option card previews its own theme colours */
.theme-option[data-theme="dark"] {
  background: #0f172a;
  color: #e2e8f0;
}
.theme-option[data-theme="dark"] .theme-desc { color: #94a3b8; }
.theme-option[data-theme="light"] {
  background: #f8fafc;
  color: #1e293b;
}
.theme-option[data-theme="light"] .theme-desc { color: #475569; }
.theme-option[data-theme="high-contrast"] {
  background: #000000;
  color: #ffffff;
}
.theme-option[data-theme="high-contrast"] .theme-desc { color: #e0e0e0; }
.theme-swatch {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid rgba(128,128,128,.3);
  flex-shrink: 0;
}
.theme-swatch-dark   { background: #1e293b; border-color: #334155; }
.theme-swatch-light  { background: #ffffff; border-color: #e2e8f0; }
.theme-swatch-hc     { background: #1a1a1a; border-color: #555555; }
.theme-label {
  font-size: .9rem;
  font-weight: 700;
}
.theme-desc {
  font-size: .75rem;
  margin-top: .15rem;
}

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: .8rem;
  margin-top: 3rem;
}

/* ── Responsive — 3-tier: phone / tablet / desktop ───────── */

/* Tablet (481px – 1024px) */
@media (max-width: 1024px) {
  .container { max-width: 720px; }
  .site-header { margin-bottom: 2rem; }
  .games-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .game-header { margin-bottom: 1.5rem; }
  .game-header h1 { font-size: 1.75rem; }
  .panel { padding: 1.25rem; }
  .result-banner { padding: 1rem 1.25rem; }
}

/* Phone (up to 480px) */
@media (max-width: 480px) {
  .container { padding: 0 1rem; }
  .page-wrap { padding: 0 1rem; }
  .site-header { padding: .75rem 0; margin-bottom: 1.5rem; }
  .site-logo { font-size: 1.15rem; }
  .back-link { font-size: .8rem; }

  .game-header { margin-bottom: 1.25rem; }
  .game-header h1 { font-size: 1.4rem; letter-spacing: -.5px; }
  .game-header p { font-size: .9rem; }
  .game-header .badge { font-size: .7rem; padding: .2rem .6rem; }

  .games-grid {
    grid-template-columns: 1fr;
    gap: .75rem;
    padding-bottom: 2rem;
  }
  .game-card { padding: 1.1rem 1.1rem .9rem; }

  .word-grid { gap: .4rem; margin: 1rem 0; }
  .word-tile {
    font-size: .8rem;
    padding: .7rem .3rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .btn { padding: .6rem 1.2rem; font-size: .85rem; min-height: 44px; }
  .btn-play { padding: .45rem .8rem; min-height: 44px; }
  .btn-give-up { min-height: 44px; }
  .btn-row { gap: .5rem; }

  .input-field { padding: .7rem .85rem; font-size: 1rem; min-height: 44px; }

  .panel { padding: 1rem; margin-bottom: 1rem; }
  .result-banner { padding: 1rem; }
  .result-banner h2 { font-size: 1.2rem; }
  .result-banner p { font-size: .85rem; }

  .share-box { padding: 1rem; }
  .share-text { font-size: .75rem; }

  .coming-soon { padding: 2rem 1rem; }
  .coming-soon h2 { font-size: 1.4rem; }
}
