:root {
  --bg: #8ec5ec;
  --panel: rgba(12, 24, 36, 0.62);
  --panel-ink: #fff;
  --card: #ffffff;
  --ink: #15202b;
  --muted: #5b6b7a;
  --line: #dfe6ec;
  --soft: #f2f6f9;
  --accent: #2f7fd6;
  --accent-ink: #fff;
  --good: #1a8a4a;
  --good-bg: #e3f5ea;
  --ok: #b36b00;
  --ok-bg: #fdf1dc;
  --bad: #c83a3a;
  --bad-bg: #fbe7e7;
  --badge: #ffd23f;
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --card: #17222d; --ink: #e8eef3; --muted: #9aabba; --line: #2b3a48; --soft: #1f2d3a;
    --good: #5fd08f; --good-bg: #15321f; --ok: #f2b457; --ok-bg: #3a2c12; --bad: #f08080; --bad-bg: #3a1919;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --card: #17222d; --ink: #e8eef3; --muted: #9aabba; --line: #2b3a48; --soft: #1f2d3a;
  --good: #5fd08f; --good-bg: #15321f; --ok: #f2b457; --ok-bg: #3a2c12; --bad: #f08080; --bad-bg: #3a1919;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); font-family: "Nunito", system-ui, sans-serif; color: var(--ink); }
canvas { display: block; }
.hidden { display: none !important; }
kbd { font: 700 0.8em/1 "Nunito", system-ui, sans-serif; padding: 3px 6px; border-radius: 5px; background: rgba(127, 127, 127, 0.22); }

.flag { display: inline-block; width: 30px; height: 20px; border-radius: 3px; overflow: hidden; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); }
.flag svg { width: 100%; height: 100%; display: block; }

/* ---------- HUD ---------- */
.panel { position: fixed; background: var(--panel); color: var(--panel-ink); border-radius: 12px; padding: 8px 14px; backdrop-filter: blur(6px); pointer-events: none; }
.stats { top: 16px; left: 16px; display: flex; align-items: center; gap: 10px; font-size: 15px; }
.stats .sep { width: 1px; height: 18px; background: rgba(255, 255, 255, 0.3); }
#compass { top: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; font-weight: 700; }
#arrow { display: inline-block; color: var(--badge); font-size: 18px; transition: transform 0.1s linear; }
#prompt { bottom: 90px; left: 50%; transform: translateX(-50%); font-size: 18px; padding: 12px 20px; white-space: nowrap; }
#help { bottom: 16px; left: 16px; font-size: 13px; opacity: 0.9; }
#crosshair { position: fixed; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: rgba(255, 255, 255, 0.8); pointer-events: none; }
.badge { display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; border-radius: 50%; background: var(--badge); color: #1b1b1b; font-weight: 800; }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(8, 18, 28, 0.35); overflow-y: auto; }
.card { background: var(--card); color: var(--ink); border-radius: var(--radius); padding: 28px; width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
.menu-card { max-width: 560px; }
.small-card { max-width: 440px; text-align: center; }
.quiz-card { max-width: 520px; }
.list-card { max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
h1 { margin: 0 0 6px; font-size: 34px; font-weight: 800; letter-spacing: -0.5px; }
h2 { margin: 22px 0 10px; font-size: 16px; font-weight: 800; }
.small-card h2, .list-head h2 { margin-top: 0; font-size: 22px; }
.lead { margin: 0; color: var(--muted); line-height: 1.5; }
.note { margin: 14px 0 0; font-size: 13px; color: var(--muted); text-align: center; }

button {
  font: 700 15px "Nunito", system-ui, sans-serif; color: var(--ink); background: var(--soft);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; cursor: pointer;
}
button:hover { filter: brightness(0.97); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.big { width: 100%; margin-top: 24px; padding: 14px; font-size: 18px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }
.row.end { justify-content: flex-end; }

.langs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.modes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.opt { position: relative; cursor: pointer; }
.opt input { position: absolute; opacity: 0; }
.opt > span { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; height: 100%; }
.opt small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.opt .best { margin-left: auto; font-size: 12px; color: var(--muted); }
.opt input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.opt input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.modes .opt > span { display: block; }

/* ---------- Quiz ---------- */
.quiz-word { display: flex; align-items: center; gap: 12px; font-size: 30px; font-weight: 800; }
.quiz-text { margin: 6px 0 18px; color: var(--muted); font-size: 17px; }
.quiz-text b { color: var(--ink); }
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.choices button { text-align: left; padding: 14px; font-size: 17px; display: flex; gap: 10px; align-items: center; }
.choices button kbd { flex: none; }
.choices button.right { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.choices button.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.choices button:disabled { cursor: default; }
.write-row { display: flex; gap: 10px; }
.write input { flex: 1; min-width: 0; font: 600 20px "Nunito", system-ui, sans-serif; padding: 10px 14px; border-radius: 10px; border: 2px solid var(--line); background: var(--soft); color: var(--ink); }
.chars { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chars button { padding: 6px 10px; min-width: 38px; font-size: 17px; }
.feedback { margin-top: 16px; padding: 12px 14px; border-radius: 12px; line-height: 1.5; font-size: 16px; }
.feedback.good { background: var(--good-bg); color: var(--good); }
.feedback.ok { background: var(--ok-bg); color: var(--ok); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }
.feedback b { font-size: 1.1em; }

/* ---------- Ordlista ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.list-rows { overflow-y: auto; }
.list-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 10px; align-items: center; padding: 8px 4px; border-top: 1px solid var(--line); min-height: 48px; }
.list-row .sv { color: var(--muted); }
.list-row .t { font-weight: 800; }
.list-row .t.unknown { color: var(--muted); font-weight: 400; letter-spacing: 3px; }
.list-row button { padding: 6px 10px; }

@media (max-width: 560px) {
  .card { padding: 20px; }
  .langs, .modes, .choices { grid-template-columns: 1fr; }
  #help { display: none; }
  #prompt { white-space: normal; width: calc(100% - 32px); text-align: center; }
}

/* ---------- Otto ---------- */
#ottoSay {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 10;
  width: max-content; max-width: min(560px, calc(100% - 32px));
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); color: var(--ink); border-radius: 14px; padding: 10px 16px 10px 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25); pointer-events: none;
}
#ottoSay .who { font-size: 28px; line-height: 1.2; }
#ottoSay .name { display: block; font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
#ottoSay .line { display: block; font-size: 18px; font-weight: 800; }
#ottoSay .sv { display: block; font-size: 14px; color: var(--muted); }
#ottoSay .sv:empty { display: none; }

/* ---------- Vattenstämpel ---------- */
#watermark {
  position: fixed; right: 16px; bottom: 16px; z-index: 5;
  font-size: 13px; font-weight: 600; color: #fff; opacity: 0.8;
  background: var(--panel); padding: 6px 12px; border-radius: 10px;
  pointer-events: none; user-select: none;
}
@media (max-width: 900px) { #help { bottom: 56px; } }
