:root {
  --bg: #0b0d12;
  --ink: #f0eef6;
  --ink-dim: #9aa0b4;
  --line: #23262f;
  --card: #14161d;
  --wr: #ff5d8f;        /* wordrush hot pink */
  --wr-2: #ffb14d;      /* warm accent */
  --good: #4dff9e;
  --bad: #ff5470;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none;
}
body {
  background:
    radial-gradient(60% 50% at 80% 0%, rgba(255,93,143,.16), transparent 60%),
    radial-gradient(50% 45% at 10% 10%, rgba(255,177,77,.10), transparent 60%),
    var(--bg);
  min-height: 100dvh;
}
.hidden { display: none !important; }

#wrap { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 10px) 16px calc(var(--safe-bot) + 16px); }

/* ---------- Overlays (menu + recap) ---------- */
.overlay { flex: 1; display: flex; align-items: center; justify-content: center; }
.panel { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 28px 22px; text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.logo { font-family: "Futura", "Trebuchet MS", system-ui, sans-serif; font-weight: 900;
  letter-spacing: .16em; font-size: clamp(2.4rem, 11vw, 3.6rem); margin: 4px 0 8px;
  background: linear-gradient(100deg, var(--wr), var(--wr-2)); -webkit-background-clip: text;
  background-clip: text; color: transparent; }
.sub { color: var(--ink-dim); font-size: 1.05rem; line-height: 1.5; max-width: 440px; margin: 0 auto 18px; }
.howto { text-align: left; display: flex; flex-direction: column; gap: 10px; margin: 0 auto 22px; max-width: 460px; }
.ht { background: #0e1016; border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px;
  font-size: .92rem; color: var(--ink-dim); line-height: 1.45; }
.ht b { color: var(--ink); }
.kbd { display: inline-block; background: #1b1e27; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 6px; padding: 1px 7px; font-size: .82rem; color: var(--ink); font-weight: 700; }

.btn { font-weight: 800; border: none; border-radius: 14px; padding: 15px 20px; cursor: pointer;
  font-size: 1rem; transition: filter .15s, transform .06s; font-family: inherit; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary { color: #11131a; background: linear-gradient(100deg, var(--wr), var(--wr-2)); width: 100%; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: #1b1e27; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--wr); color: #fff; }
.best { color: var(--ink-dim); font-size: .9rem; margin: 14px 0 0; min-height: 1.2em; }
.best b { color: var(--wr-2); }

/* ---------- Spel ---------- */
#game { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.topbar { display: flex; gap: 10px; }
.stat { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 6px; text-align: center; }
.s-label { display: block; font-size: .64rem; letter-spacing: .14em; color: var(--ink-dim); font-weight: 700; }
.s-val { display: block; font-size: 1.5rem; font-weight: 900; font-variant-numeric: tabular-nums; margin-top: 2px; }
#tTime.warn { color: var(--bad); animation: pulse .6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

#timerbar { height: 7px; background: #1b1e27; border-radius: 999px; overflow: hidden; }
#timerfill { height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--wr), var(--wr-2)); transition: width 1s linear; }

.current { min-height: 56px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.cur { font-size: clamp(1.8rem, 9vw, 2.6rem); font-weight: 900; letter-spacing: .12em; text-transform: uppercase;
  min-height: 1.1em; }
.cur:empty::before { content: "_ _ _"; color: #2a2e3a; letter-spacing: .3em; }
.curpts { font-size: 1.1rem; font-weight: 800; color: var(--wr-2); font-variant-numeric: tabular-nums; min-width: 3ch; }

.flash { text-align: center; min-height: 22px; font-weight: 800; font-size: .95rem; opacity: 0;
  transition: opacity .2s; }
.flash.show { opacity: 1; }
.flash.ok { color: var(--good); }
.flash.no { color: var(--bad); }
.flash.dup { color: var(--wr-2); }

.rack { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 4px 0; }
.tile { width: 62px; height: 70px; border-radius: 14px; background: linear-gradient(180deg, #232733, #171a22);
  border: 1px solid #313646; box-shadow: 0 6px 0 #0c0e14, 0 8px 16px rgba(0,0,0,.4);
  font-size: 2rem; font-weight: 900; text-transform: uppercase; color: var(--ink);
  display: flex; align-items: center; justify-content: center; cursor: pointer; user-select: none;
  transition: transform .08s, opacity .12s; position: relative; }
.tile:active { transform: translateY(2px); }
.tile.used { opacity: .28; transform: translateY(2px); pointer-events: none; box-shadow: 0 2px 0 #0c0e14; }
.tile.bump { animation: bump .18s ease; }
@keyframes bump { 50% { transform: translateY(-6px) scale(1.06); } }
@media (max-width: 380px) { .tile { width: 52px; height: 60px; font-size: 1.7rem; } }

.controls { display: grid; grid-template-columns: 1fr 1fr 1.6fr; gap: 10px; }
.controls .btn { padding: 14px 8px; }

.found-wrap { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 14px; display: flex; flex-direction: column; min-height: 96px; }
.found-head { font-size: .68rem; letter-spacing: .14em; color: var(--ink-dim); font-weight: 700; margin-bottom: 8px; }
.found { display: flex; flex-wrap: wrap; gap: 7px; align-content: flex-start; overflow-y: auto; }
.fw { background: #0e1016; border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px;
  font-size: .9rem; font-weight: 700; }
.fw b { color: var(--wr-2); font-variant-numeric: tabular-nums; margin-left: 5px; font-size: .8rem; }
.fw.new { animation: pop .25s ease; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.12); } }

/* ---------- Recap ---------- */
.rank-badge { display: inline-block; font-family: "Futura", "Trebuchet MS", system-ui, sans-serif;
  font-weight: 900; letter-spacing: .06em; font-size: 1.7rem; padding: 8px 20px; border-radius: 999px;
  color: #11131a; background: linear-gradient(100deg, var(--wr), var(--wr-2)); margin-bottom: 10px; }
.r-text { color: var(--ink-dim); line-height: 1.5; margin: 0 auto 16px; max-width: 420px; }
.bigscore { display: flex; flex-direction: column; align-items: center; margin: 6px 0 14px; }
.bigscore span:first-child { font-size: 3.4rem; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums;
  background: linear-gradient(100deg, var(--wr), var(--wr-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.bs-label { font-size: .8rem; letter-spacing: .14em; color: var(--ink-dim); font-weight: 700; margin-top: 4px; }
.bonus { background: #0e1016; border: 1px solid var(--wr); border-radius: 14px; padding: 12px 14px;
  margin: 0 0 14px; font-size: .95rem; line-height: 1.45; }
.bonus b { color: var(--wr); }
.r-stats { display: flex; gap: 10px; justify-content: center; margin-bottom: 14px; flex-wrap: wrap; }
.r-stats .rs { background: #0e1016; border: 1px solid var(--line); border-radius: 12px; padding: 9px 14px; min-width: 92px; }
.rs .v { font-size: 1.4rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.rs .l { font-size: .66rem; letter-spacing: .1em; color: var(--ink-dim); font-weight: 700; }
.missed { font-size: .9rem; color: var(--ink-dim); margin: 0 0 16px; line-height: 1.5; }
.missed b { color: var(--ink); }
.back { display: inline-block; margin-top: 14px; color: var(--ink-dim); text-decoration: none; font-size: .9rem; }
.back:hover { color: var(--wr); }
