:root {
  --bg: #0f1226;
  --bg2: #171b38;
  --card: #1f2448;
  --card2: #282e5a;
  --line: #3a4180;
  --text: #f3f4ff;
  --muted: #a9aed8;
  --accent: #7c5cff;
  --accent2: #22d3ee;
  --good: #22c55e;
  --bad: #f43f5e;
  --warn: #f59e0b;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 10% -10%, #2a1f6e 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 110%, #0e4a5c 0%, transparent 60%), var(--bg);
  color: var(--text);
  font-size: 20px;
  line-height: 1.45;
  -webkit-user-select: none;
  user-select: none;
  overflow-x: hidden;
}
input, textarea { -webkit-user-select: text; user-select: text; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: 2.4rem; }
h2 { font-size: 1.8rem; }
a { color: var(--accent2); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 24px; }

.btn {
  appearance: none; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font: inherit; font-weight: 700;
  padding: 14px 26px; border-radius: 14px; box-shadow: var(--shadow);
  transition: transform .08s ease, filter .15s ease;
  min-height: 56px;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.5); }
.btn.big { font-size: 1.5rem; padding: 18px 40px; min-height: 72px; }
.btn.ghost { background: transparent; border: 2px solid var(--line); box-shadow: none; }
.btn.good { background: var(--good); }
.btn.bad { background: var(--bad); }
.btn.warn { background: var(--warn); color: #1b1300; }
.btn.cyan { background: var(--accent2); color: #062a33; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 12px 24px;
  background: rgba(10, 12, 30, .6); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; backdrop-filter: blur(6px);
}
.topbar .title { font-weight: 800; font-size: 1.2rem; }
.topbar .player { background: var(--card2); padding: 6px 14px; border-radius: 999px; font-weight: 700; }
.topbar .timer { font-variant-numeric: tabular-nums; font-weight: 800; background: var(--card2); padding: 6px 14px; border-radius: 999px; }
.topbar .score { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--accent2); }

/* ---------- Meny ---------- */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.game-tile {
  display: block; text-decoration: none; color: var(--text);
  background: linear-gradient(160deg, var(--c1, #3b2a9a), var(--c2, #1f2448));
  border-radius: 22px; padding: 22px; min-height: 200px; box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.12); transition: transform .12s ease;
}
.game-tile:hover { transform: translateY(-4px); }
.game-tile .emoji { font-size: 3rem; }
.game-tile h3 { margin-top: 8px; font-size: 1.4rem; }
.game-tile p { margin: 0; color: rgba(255,255,255,.85); font-size: 1rem; }

/* ---------- Intro / namn / resultat ---------- */
.screen { min-height: calc(100vh - 70px); display: flex; align-items: center; justify-content: center; padding: 24px; }
.hero { max-width: 900px; width: 100%; text-align: center; }
.hero .emoji { font-size: 6rem; line-height: 1; animation: bob 3s ease-in-out infinite; }
.hero h1 { font-size: 3.2rem; margin-top: 12px; }
.hero p.lead { font-size: 1.35rem; color: var(--muted); max-width: 720px; margin: 0 auto 28px; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-3deg); } }

.name-box { max-width: 560px; margin: 0 auto; text-align: left; }
.name-box input {
  width: 100%; font: inherit; font-size: 1.8rem; padding: 16px 20px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--bg2); color: var(--text); outline: none;
}
.name-box input:focus { border-color: var(--accent); }
.suggestions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; min-height: 46px; }
.chip {
  background: var(--card2); border: 1px solid var(--line); color: var(--text); font: inherit; font-size: 1rem;
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
}
.chip:hover { border-color: var(--accent2); }
.error { color: var(--bad); font-weight: 700; min-height: 1.5em; }

.result-score { font-size: 6rem; font-weight: 900; color: var(--accent2); font-variant-numeric: tabular-nums; line-height: 1; }
.stamps { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 12px 0; }
.stamp { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; background: var(--card2); opacity: .3; border: 2px dashed var(--line); }
.stamp.on { opacity: 1; border: 2px solid var(--accent2); background: #12304a; }
.lesson { text-align: left; background: var(--card2); border-left: 6px solid var(--accent2); border-radius: 12px; padding: 16px 20px; margin: 20px auto; max-width: 760px; }
.lesson h3 { margin-bottom: 6px; }

/* ---------- Spelyta ---------- */
.game-area { max-width: 1200px; margin: 0 auto; padding: 20px 24px 40px; }
.progress { height: 10px; background: var(--card2); border-radius: 99px; overflow: hidden; margin-bottom: 18px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .3s ease; }
.feedback { border-radius: 14px; padding: 14px 18px; margin-top: 16px; font-size: 1.1rem; }
.feedback.good { background: rgba(34,197,94,.15); border: 1px solid var(--good); }
.feedback.bad { background: rgba(244,63,94,.13); border: 1px solid var(--bad); }
.feedback.info { background: rgba(34,211,238,.1); border: 1px solid var(--accent2); }
.pop { animation: pop .25s ease; }
@keyframes pop { from { transform: scale(.94); opacity: .2; } to { transform: scale(1); opacity: 1; } }
.shake { animation: shake .35s ease; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

.bar { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.bar .lbl { width: 160px; flex: none; text-align: right; font-weight: 700; }
.bar .track { flex: 1; height: 30px; background: var(--bg2); border-radius: 8px; overflow: hidden; position: relative; }
.bar .fill { height: 100%; background: var(--accent); transition: width .4s ease; }
.bar .val { width: 70px; flex: none; font-variant-numeric: tabular-nums; }

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 16px; }
.choice {
  background: var(--card2); color: var(--text); border: 2px solid var(--line); border-radius: 16px;
  font: inherit; font-size: 1.25rem; font-weight: 700; padding: 18px; cursor: pointer; min-height: 70px;
  transition: transform .08s ease, border-color .15s ease;
}
.choice:hover:not(:disabled) { border-color: var(--accent2); }
.choice:active:not(:disabled) { transform: scale(.98); }
.choice.correct { border-color: var(--good); background: rgba(34,197,94,.2); }
.choice.wrong { border-color: var(--bad); background: rgba(244,63,94,.18); }
.choice:disabled { cursor: default; }

.toast {
  position: fixed; left: 50%; top: 90px; transform: translateX(-50%); z-index: 50;
  background: var(--card2); border: 2px solid var(--accent2); padding: 12px 24px; border-radius: 14px;
  font-weight: 800; font-size: 1.3rem; box-shadow: var(--shadow); animation: pop .2s ease;
}

.idle-warning {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 100;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } h1 { font-size: 2rem; } .hero h1 { font-size: 2.4rem; } }

table.simple { width: 100%; border-collapse: collapse; }
table.simple th, table.simple td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
