/* Werge — dark open-space board, glassy chunk pills, neon accents.
   Fonts: Space Grotesk (UI/chunks), Archivo Black (heavy sans for the title,
   matching the chunk-tile sans in spirit — cf. SN Pro Bold), Fraunces
   (display serif kept for score numerals and panel headlines). */

:root {
  --ink: #0a0e18;
  --ink-2: #101627;
  --line: #232c45;
  --text: #e8ecf6;
  --text-dim: #8a93ad;
  --mint: #7ef0c8;
  --cyan: #6fd3ff;
  --gold: #ffd166;
  --rose: #ff6f91;
  --chunk-bg: #161d33;
  --chunk-edge: #2a3557;
  --radius: 14px;
  --font-ui: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  --font-title: 'Archivo Black', 'Space Grotesk', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background:
    radial-gradient(1200px 700px at 70% -10%, #131b33 0%, transparent 60%),
    radial-gradient(900px 600px at 10% 110%, #12203a 0%, transparent 55%),
    var(--ink);
  color: var(--text);
  font-family: var(--font-ui);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.hidden { display: none !important; }

.screen { position: fixed; inset: 0; }
.overlay { background: rgba(6, 9, 18, 0.82); backdrop-filter: blur(6px); z-index: 40; display: grid; place-items: center; overflow-y: auto; padding: 4vh 16px; }

/* ---------- buttons & shared ---------- */

.btn {
  font-family: var(--font-ui);
  font-weight: 500;
  letter-spacing: 0.06em;
  font-size: 14px;
  color: var(--text);
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--mint); transform: translateY(-1px); box-shadow: 0 4px 20px rgba(126, 240, 200, 0.12); }
.btn-primary { border-color: var(--mint); color: var(--mint); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); padding: 8px 10px; }
.btn-ghost:hover { color: var(--text); box-shadow: none; }
.btn-sub { font-size: 11px; color: var(--text-dim); letter-spacing: 0.04em; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }

.eyebrow {
  font-variant: all-small-caps;
  letter-spacing: 0.35em;
  font-size: 15px;
  color: var(--mint);
  margin-bottom: 10px;
}

.panel {
  max-width: 640px;
  width: 100%;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px 36px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.panel h2 { font-family: var(--font-display); font-weight: 800; font-size: 27px; line-height: 1.2; margin-bottom: 18px; }

/* ---------- start screen ---------- */

#start { display: grid; place-items: center; }
.start-inner { text-align: center; }
/* tiled WERGE lockup — the same treatment the onboarding reveal lands on
   (ref: Werge_mark.png — gradient text inside rounded gradient-border tiles) */
.logo-tiles {
  display: flex; gap: 12px; justify-content: center; align-items: stretch;
  filter: drop-shadow(0 0 30px rgba(111, 211, 255, 0.22));
}
.wtile {
  border-radius: 22px;
  padding: 8px 24px;
  border: 3px solid transparent;
  background:
    linear-gradient(var(--ink), var(--ink)) padding-box,
    linear-gradient(100deg, var(--mint), var(--cyan), #c9a6ff, #ff9ad5) border-box;
}
.wtile b {
  font-family: var(--font-title);
  font-weight: 400; /* Archivo Black is a single ultra-heavy weight */
  font-size: clamp(42px, 10.5vw, 112px);
  line-height: 1.12;
  letter-spacing: 0.01em;
  background: linear-gradient(100deg, var(--mint), var(--cyan), #c9a6ff, #ff9ad5);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
/* continuous gradient across the lockup: W = mint->cyan, ERGE = cyan->pink.
   Borders take the same slice as their text, so the color at the seam
   between tiles matches on both sides — one wordmark, not two badges. */
.logo-tiles .wtile:first-child {
  background:
    linear-gradient(var(--ink), var(--ink)) padding-box,
    linear-gradient(100deg, var(--mint), var(--cyan)) border-box;
}
.logo-tiles .wtile:last-child {
  background:
    linear-gradient(var(--ink), var(--ink)) padding-box,
    linear-gradient(100deg, var(--cyan), #c9a6ff, #ff9ad5) border-box;
}
.logo-tiles .wtile:first-child b { background-image: linear-gradient(100deg, var(--mint), var(--cyan)); -webkit-background-clip: text; background-clip: text; }
.logo-tiles .wtile:last-child b { background-image: linear-gradient(100deg, var(--cyan), #c9a6ff, #ff9ad5); -webkit-background-clip: text; background-clip: text; }
.tagline { color: var(--text-dim); font-size: 17px; margin: 10px 0 34px; letter-spacing: 0.02em; }
.mode-row { display: flex; gap: 14px; justify-content: center; }
.mode-row .btn { min-width: 170px; padding: 16px 22px; font-size: 17px; font-weight: 700; }
.diff-row { margin-top: 18px; display: flex; gap: 8px; justify-content: center; }
.diff-btn {
  font-family: var(--font-ui); font-size: 13px; letter-spacing: .08em;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 16px; cursor: pointer;
}
.diff-btn.selected { color: var(--ink); background: var(--mint); border-color: var(--mint); font-weight: 700; }
.start-links { margin-top: 34px; display: flex; gap: 26px; justify-content: center; }
.start-links a { color: var(--text-dim); text-decoration: none; font-size: 14px; letter-spacing: .04em; border-bottom: 1px dotted var(--line); padding-bottom: 2px; }
.start-links a:hover { color: var(--mint); border-color: var(--mint); }

/* ---------- HUD ---------- */

#game { display: flex; flex-direction: column; }
#hud {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; z-index: 10;
}
.hud-label { font-variant: all-small-caps; letter-spacing: .25em; color: var(--text-dim); font-size: 13px; margin-right: 10px; }
.hud-score { font-family: var(--font-display); font-weight: 800; font-size: 34px; color: var(--mint); min-width: 54px; display: inline-block; }
.hud-score.bad { color: var(--rose); }
.hud-par { color: var(--text-dim); font-size: 12px; margin-left: 8px; }
.hud-clock { font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: .04em; }
.hud-clock.urgent { color: var(--rose); animation: pulse 1s infinite; }
.hud-mode { color: var(--text-dim); font-variant: all-small-caps; letter-spacing: .3em; font-size: 14px; margin-left: 14px; }
.hud-right { display: flex; gap: 4px; }

@keyframes pulse { 50% { opacity: .5; } }

/* ---------- board & chunks ---------- */

#board { position: relative; flex: 1; overflow: hidden; touch-action: none; }

.chunk {
  position: absolute;
  left: 0; top: 0;
  padding: 11px 16px;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--text);
  background: linear-gradient(180deg, #1a2340, var(--chunk-bg));
  border: 1px solid var(--chunk-edge);
  border-radius: var(--radius);
  cursor: grab;
  will-change: transform;
  box-shadow: 0 6px 18px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.05);
  touch-action: none;
  transition: box-shadow .2s, border-color .2s, opacity .3s;
}
.chunk.dragging { cursor: grabbing; z-index: 20; border-color: var(--cyan); box-shadow: 0 14px 34px rgba(0,0,0,.5), 0 0 24px rgba(111,211,255,.25); }
.chunk.snap-target { border-color: var(--mint); box-shadow: 0 0 22px rgba(126,240,200,.35); }
.chunk.in-cluster { border-color: var(--cyan); background: linear-gradient(180deg, #1c2a4d, #182241); }
.chunk.orphan-risk { border-color: var(--gold); box-shadow: 0 0 18px rgba(255, 209, 102, .25); animation: pulse 1.6s infinite; }
.chunk.hint-glow { border-color: var(--cyan); box-shadow: 0 0 26px rgba(111, 211, 255, .55); animation: pulse 1s infinite; }
.chunk.banked-out { opacity: 0; transform: scale(.2) !important; transition: opacity .45s, transform .45s; }
.chunk.spawn { animation: spawn .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes spawn { from { opacity: 0; scale: .3; } to { opacity: 1; scale: 1; } }
.chunk.spin { animation: spintile .4s linear infinite; }
@keyframes spintile { to { rotate: 360deg; } }

/* cluster HUD (countdown ring + bank button) */
.cluster-hud {
  position: absolute; left: 0; top: 0;
  display: flex; align-items: center; gap: 8px;
  z-index: 15;
  will-change: transform;
}
.cluster-hud .ring { width: 30px; height: 30px; transform: rotate(-90deg); }
.cluster-hud .ring circle { fill: none; stroke-width: 3; }
.cluster-hud .ring .track { stroke: var(--line); }
.cluster-hud .ring .arc { stroke: var(--gold); stroke-linecap: round; }
.cluster-hud .ring.urgent .arc { stroke: var(--rose); }
.bank-btn {
  font-family: var(--font-ui); font-weight: 700; font-size: 13px; letter-spacing: .1em;
  color: var(--ink); background: var(--mint);
  border: none; border-radius: 999px; padding: 7px 14px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(126,240,200,.35);
}
.bank-btn:hover { transform: scale(1.06); }

.cluster-shake { animation: shake .4s; }
@keyframes shake {
  20% { translate: -7px 0; } 40% { translate: 6px 0; }
  60% { translate: -4px 0; } 80% { translate: 3px 0; }
}

/* score float */
.score-float {
  position: absolute; z-index: 30; pointer-events: none;
  font-family: var(--font-display); font-weight: 800; font-size: 26px;
  animation: floatup 1.1s ease-out forwards;
}
.score-float.good { color: var(--mint); }
.score-float.meh { color: var(--gold); }
@keyframes floatup { to { transform: translateY(-60px); opacity: 0; } }

/* toast */
.toast {
  position: fixed; top: 76px; left: 50%; translate: -50% 0;
  z-index: 35; max-width: 90vw;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 22px; font-size: 15px; letter-spacing: .02em;
  box-shadow: 0 10px 40px rgba(0,0,0,.45);
  animation: toastin .25s cubic-bezier(.2,1.4,.4,1);
}
.toast.success { border-color: var(--mint); }
.toast.reject { border-color: var(--rose); }
@keyframes toastin { from { opacity: 0; translate: -50% -12px; } }

/* word log */
#wordlog {
  position: fixed; right: 16px; top: 76px; z-index: 12;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
  max-height: 60vh; overflow: hidden;
  pointer-events: none;
}
.logentry {
  display: flex; gap: 8px; align-items: center;
  background: rgba(16,22,39,.85); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 10px; font-size: 13px; letter-spacing: .06em;
  animation: toastin .3s;
}
.logentry .cost { font-weight: 700; }
.logentry .cost.good { color: var(--mint); }
.logentry .cost.meh { color: var(--gold); }

/* ---------- round end ---------- */

.score-table { width: 100%; margin: 6px 0 14px; border-collapse: collapse; font-size: 16px; }
.score-table td { padding: 7px 2px; border-bottom: 1px solid var(--line); color: var(--text-dim); }
.score-table td:last-child { text-align: right; color: var(--text); font-weight: 700; }
.score-table tr.total td { border-bottom: none; font-family: var(--font-display); font-size: 22px; color: var(--text); }
.score-table tr.total td:last-child { color: var(--mint); }
.re-wordlist { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.re-wordlist span { font-size: 13px; letter-spacing: .08em; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; color: var(--text-dim); }
.re-solution {
  margin-top: 12px; padding: 12px 14px;
  border: 1px dashed var(--line); border-radius: 10px;
  font-size: 14px; letter-spacing: .05em; color: var(--mint); line-height: 1.7;
}
.re-solution .sol-label { display: block; font-variant: all-small-caps; letter-spacing: .22em; color: var(--text-dim); font-size: 13px; }

/* ---------- how to ---------- */

.rules { list-style: none; display: flex; flex-direction: column; gap: 12px; font-size: 15px; line-height: 1.5; color: var(--text-dim); }
.rules b { color: var(--text); }
.rules-sub {
  font-variant: all-small-caps; letter-spacing: .22em; font-size: 15px;
  color: var(--mint); margin: 20px 0 10px;
}

/* ---------- about ---------- */

.about-panel { max-width: 720px; }
.about-headline { font-size: 32px; }
.about-panel > p { color: var(--text-dim); line-height: 1.6; font-size: 15px; margin-bottom: 14px; }
.bio-box {
  display: flex; gap: 20px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; margin-top: 20px; background: rgba(10,14,24,.5);
}
.bio-avatar {
  width: 92px; height: 92px; border-radius: 12px; flex-shrink: 0; object-fit: cover;
  /* recolor the off-white neon source into Werge's mint palette */
  filter: sepia(1) saturate(2.4) hue-rotate(112deg) brightness(1.04);
}
.bio-text p { color: var(--text-dim); font-size: 14px; line-height: 1.6; }
.bio-text p + p { margin-top: 10px; }

/* ---------- onboarding ---------- */

#onboarding { background: var(--ink); z-index: 50; cursor: pointer; transition: opacity .7s ease; }
#onboarding-stage { position: absolute; inset: 0; }
.ob-tile {
  position: absolute; left: 0; top: 0;
  /* tight horizontal padding so letters of joined fragments read as one word */
  padding: 12px 7px; font-size: 21px; font-weight: 500; letter-spacing: .06em;
  color: var(--text);
  background: linear-gradient(180deg, #1a2340, var(--chunk-bg));
  border: 1px solid var(--chunk-edge); border-radius: var(--radius);
  will-change: transform, opacity;
  transition: transform .8s cubic-bezier(.25,1.4,.35,1), opacity .5s;
  white-space: nowrap;
}
.ob-tile.title {
  font-family: var(--font-title); font-weight: 400;
  font-size: clamp(44px, 9vw, 100px); padding: 8px 20px;
  color: var(--mint); border: 3px solid var(--mint); border-radius: 22px;
  box-shadow: 0 0 40px rgba(126,240,200,.25);
  line-height: 1.12;
}
.ob-tile.title b { font-weight: 400; }
/* post-lock color shift: mint tile -> gradient-tiled treatment (persistent) */
.ob-tile.title.wtile-grad {
  border-color: transparent;
  background:
    linear-gradient(var(--ink), var(--ink)) padding-box,
    linear-gradient(100deg, var(--mint), var(--cyan), #c9a6ff, #ff9ad5) border-box;
  animation: gradglow 1.3s ease;
  filter: drop-shadow(0 0 26px rgba(111, 211, 255, 0.28));
}
.ob-tile.title.wtile-grad b {
  background: linear-gradient(100deg, var(--mint), var(--cyan), #c9a6ff, #ff9ad5);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: gradsweep 1.3s ease;
  background-size: 100% 100%;
}
.ob-tile.title.wtile-grad.grad-w {
  background:
    linear-gradient(var(--ink), var(--ink)) padding-box,
    linear-gradient(100deg, var(--mint), var(--cyan)) border-box;
}
.ob-tile.title.wtile-grad.grad-erge {
  background:
    linear-gradient(var(--ink), var(--ink)) padding-box,
    linear-gradient(100deg, var(--cyan), #c9a6ff, #ff9ad5) border-box;
}
.ob-tile.title.wtile-grad.grad-w b { background-image: linear-gradient(100deg, var(--mint), var(--cyan)); -webkit-background-clip: text; background-clip: text; }
.ob-tile.title.wtile-grad.grad-erge b { background-image: linear-gradient(100deg, var(--cyan), #c9a6ff, #ff9ad5); -webkit-background-clip: text; background-clip: text; }
@keyframes gradsweep { from { background-size: 900% 100%; } to { background-size: 100% 100%; } }
@keyframes gradglow { from { filter: drop-shadow(0 0 8px rgba(126,240,200,.4)); } }
.ob-tile.ob-drop {
  transition: transform 1.1s cubic-bezier(.5,-.3,.8,.6), opacity .9s;
  opacity: 0;
}
.ob-tagline {
  position: absolute; left: 0; right: 0; text-align: center;
  color: var(--text-dim); font-size: 19px; letter-spacing: .03em;
  opacity: 0; transition: opacity 1.2s ease;
}
.ob-tagline.show { opacity: 1; }
.skip-hint {
  position: absolute; bottom: 26px; left: 50%; translate: -50%;
  color: var(--text-dim); font-size: 13px; letter-spacing: .2em; font-variant: all-small-caps;
  animation: pulse 2.4s infinite;
}

.sc-detail { color: var(--text-dim); font-size: 15px; line-height: 1.5; }

/* ---------- settings ---------- */

.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 2px; border-bottom: 1px solid var(--line);
  font-size: 15px; color: var(--text-dim);
}
.toggle {
  font-family: var(--font-ui); font-weight: 700; font-size: 13px;
  letter-spacing: .12em; min-width: 84px;
  color: var(--mint); background: transparent;
  border: 1px solid var(--mint); border-radius: 999px;
  padding: 7px 16px; cursor: pointer;
}
.toggle.off { color: var(--text-dim); border-color: var(--line); }
.setting-note { display: block; font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.cluster-hud.no-countdown .ring { display: none; }

/* ---------- light theme ---------- */

body.light {
  --ink: #eef1f8;
  --ink-2: #ffffff;
  --line: #d3dae8;
  --text: #1b2333;
  --text-dim: #5c6579;
  --mint: #0b9d76;
  --cyan: #0e7fb8;
  --gold: #a97e00;
  --rose: #cf3f63;
  --chunk-bg: #ffffff;
  --chunk-edge: #c4cfe2;
  background:
    radial-gradient(1200px 700px at 70% -10%, #e2e9f7 0%, transparent 60%),
    radial-gradient(900px 600px at 10% 110%, #e5eef7 0%, transparent 55%),
    var(--ink);
}
body.light .chunk,
body.light .ob-tile {
  background: linear-gradient(180deg, #ffffff, #f0f3fa);
  box-shadow: 0 6px 18px rgba(30, 44, 80, .12), inset 0 1px 0 rgba(255,255,255,.7);
}
body.light .overlay { background: rgba(230, 235, 246, .82); }
body.light .bio-box { background: rgba(240, 243, 250, .6); }
body.light .logo { filter: drop-shadow(0 0 24px rgba(14, 127, 184, 0.18)); }
body.light .logentry { background: rgba(255,255,255,.85); }
body.light .bio-avatar { filter: sepia(1) saturate(2.6) hue-rotate(112deg) brightness(.82); }

/* ---------- mobile (WERGE_FIXES_3.md item 12) ---------- */

@media (max-width: 640px) {
  .panel { padding: 24px 18px; }
  .panel h2 { font-size: 22px; }
  .mode-row { flex-direction: column; align-items: stretch; }
  .mode-row .btn { min-width: 0; }
  #wordlog { display: none; }

  /* HUD compression — keep every control tappable, drop the label noise */
  #hud { padding: 8px 8px; }
  .hud-label { font-size: 11px; margin-right: 6px; }
  .hud-score { font-size: 24px; min-width: 36px; }
  .hud-clock { font-size: 20px; }
  .hud-mode { display: none; }
  .hud-right { gap: 0; }
  .btn-ghost { padding: 8px 7px; font-size: 12px; letter-spacing: .03em; }

  /* chunks: smaller type but still comfortable touch targets (~42px tall) */
  .chunk { font-size: 15px; padding: 12px 12px; letter-spacing: .08em; }
  .cluster-hud .ring { width: 24px; height: 24px; }
  .bank-btn { padding: 8px 12px; font-size: 12px; }
  .score-float { font-size: 20px; }
  .toast { top: 58px; font-size: 13px; padding: 8px 16px; max-width: 94vw; }

  /* onboarding: fragment lines and the title beat must fit narrow widths */
  .ob-tile { font-size: 14px; padding: 9px 5px; }
  .ob-tile.title { font-size: clamp(24px, 8.5vw, 100px); padding: 6px 12px; }
  .ob-tagline { font-size: 15px; padding: 0 16px; }

  .start-links { flex-wrap: wrap; gap: 14px 20px; }
  .score-table { font-size: 14px; }
  .rules { font-size: 14px; }
  .setting-row { font-size: 14px; }
  .about-headline { font-size: 24px; }
  .bio-box { flex-direction: column; }
  .bio-avatar { width: 72px; height: 72px; }
}
