:root {
  --bg: #0f1c2e; --card: #18293f; --card2: #21385a; --text: #f3f6fb; --muted: #9db0c9;
  --accent: #ffc83d; --good: #2ecc8f; --bad: #ff5d6c; --radius: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif; min-height: 100%; }
body { display: flex; justify-content: center; }
#app { width: 100%; max-width: 520px; min-height: 100vh; padding: max(16px, env(safe-area-inset-top)) 16px 32px; }
.hidden { display: none !important; }
button { font-family: inherit; border: 0; cursor: pointer; color: inherit; }
button:disabled { opacity: .5; }
input { font-family: inherit; }
h1 { font-size: 34px; font-weight: 900; margin: 8px 0 2px; letter-spacing: -.5px; }
h1 span { color: var(--accent); }
h2 { font-size: 22px; margin: 0; font-weight: 900; }
.sub { color: var(--muted); margin: 0 0 14px; font-weight: 600; }
.label { font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); font-weight: 800; margin: 18px 0 8px; }
.muted { color: var(--muted); font-weight: 700; font-size: 13px; text-align: center; margin: 6px 0; }

/* Flaggor */
img.flag { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.35); background: #fff; }
img.flag.big { width: min(78vw, 300px); border-radius: 12px; box-shadow: 0 8px 22px rgba(0,0,0,.45); }
img.flag.mini { width: 40px; flex: none; border-radius: 4px; }

/* Startsida */
.aliasrow { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 14px; padding: 4px 6px 4px 14px; border: 2px solid var(--card2); }
.aliasrow:focus-within { border-color: var(--accent); }
.aliasrow input { flex: 1; min-width: 0; font-weight: 800; font-size: 17px; padding: 10px 0; background: none; border: 0; color: var(--text); outline: none; }
.daily { width: 100%; text-align: left; margin-top: 12px; padding: 14px 16px; border-radius: var(--radius); background: linear-gradient(135deg, #2b5ca8, #1c3d73); border: 2px solid #4d86d9; }
.daily.played { background: linear-gradient(135deg, #1f6b52, #14473a); border-color: var(--good); }
.dc-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 17px; }
.dc-top span { font-size: 13px; color: #cfe0ff; font-weight: 800; }
.dc-sub { color: #cfe0ff; font-weight: 700; font-size: 13.5px; margin-top: 2px; }
.dc-status { margin-top: 8px; font-weight: 900; color: var(--accent); }
.codeform, .savebox, .typebox { display: flex; gap: 8px; margin-top: 10px; }
.codeform input, .savebox input, .typebox input { flex: 1; min-width: 0; font-weight: 800; font-size: 17px; padding: 13px; border-radius: 14px; border: 2px solid var(--card2); background: var(--card); color: var(--text); outline: none; }
.codeform input { text-transform: uppercase; letter-spacing: 2px; }
.codeform input::placeholder { text-transform: none; letter-spacing: 0; }
.codeform input:focus, .savebox input:focus, .typebox input:focus { border-color: var(--accent); }
.codeform button, .typebox button { background: var(--accent); color: #1b1400; font-weight: 900; padding: 0 18px; border-radius: 14px; font-size: 16px; }
.savebox button { background: var(--good); color: #04281a; font-weight: 900; padding: 0 16px; border-radius: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card); padding: 9px 14px; border-radius: 999px; font-weight: 800; font-size: 14px; border: 2px solid transparent; }
.chip.on { border-color: var(--accent); background: var(--card2); }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode { background: var(--card); border-radius: var(--radius); padding: 14px; text-align: left; border: 2px solid transparent; position: relative; min-height: 104px; }
.mode.on { border-color: var(--accent); background: var(--card2); }
.mode .ic { font-size: 26px; }
.mode b { display: block; font-size: 16px; margin-top: 4px; }
.mode small { display: block; color: var(--muted); font-weight: 600; font-size: 12.5px; margin-top: 2px; line-height: 1.3; }
.mode .best { position: absolute; top: 10px; right: 12px; font-size: 12px; color: var(--accent); font-weight: 900; }
.big { width: 100%; background: var(--accent); color: #1b1400; font-weight: 900; font-size: 19px; padding: 17px; border-radius: var(--radius); margin-top: 18px; box-shadow: 0 6px 0 #c9971c; }
.big:active { transform: translateY(3px); box-shadow: 0 3px 0 #c9971c; }
.ghost { background: var(--card); font-weight: 800; padding: 13px; border-radius: 14px; width: 100%; margin-top: 10px; font-size: 16px; }
.ghost.accent { border: 2px solid var(--accent); }
.row2 { display: flex; gap: 8px; }
.row2 .ghost { flex: 1; }

/* Spel */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.back { background: var(--card); width: 42px; height: 42px; border-radius: 12px; font-size: 20px; font-weight: 900; flex: none; }
.grow { flex: 1; min-width: 0; }
.gtitle { font-weight: 900; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat { background: var(--card); border-radius: 12px; padding: 8px 12px; font-weight: 900; font-size: 15px; white-space: nowrap; }
.stat.streak { color: var(--accent); }
.stat.timer.low { color: var(--bad); }
.progress { height: 8px; background: var(--card); border-radius: 99px; overflow: hidden; margin-bottom: 14px; }
.progress div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.qcard { background: var(--card); border-radius: 24px; padding: 20px; text-align: center; margin-bottom: 14px; min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.qname { font-size: 30px; font-weight: 900; padding: 20px 6px; }
.qhint { color: var(--muted); font-weight: 700; font-size: 14px; }
.answers { display: grid; gap: 10px; }
.answers.flags { grid-template-columns: 1fr 1fr; }
.ans { background: var(--card2); border-radius: 16px; padding: 16px 14px; font-weight: 800; font-size: 17px; text-align: left; border: 3px solid transparent; transition: transform .08s; }
.ans:active { transform: scale(.98); }
.answers.flags .ans { padding: 8px; }
.ans.good { background: var(--good); color: #04281a; }
.ans.bad { background: var(--bad); color: #2d0006; }
.answers.flags .ans.good { background: var(--card2); border-color: var(--good); }
.answers.flags .ans.bad { background: var(--card2); border-color: var(--bad); }
.ans.dim { opacity: .4; }
.feedback { text-align: center; font-weight: 900; font-size: 18px; min-height: 30px; margin-top: 12px; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

/* Resultat & listor */
.result { text-align: center; padding-top: 16px; }
.result .emoji { font-size: 64px; }
.result .score { font-size: 56px; font-weight: 900; margin: 4px 0; }
.result .pct { color: var(--muted); font-weight: 800; }
.result .rec { color: var(--accent); font-weight: 900; margin-top: 8px; font-size: 18px; }
#lbBox { margin-top: 16px; }
.place { text-align: center; font-weight: 900; font-size: 17px; margin-bottom: 6px; }
.lb { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 6px; }
.lb li { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 11px 14px; font-weight: 800; }
.lb .pos { width: 28px; text-align: center; font-weight: 900; color: var(--muted); }
.lb .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .tm { color: var(--muted); font-size: 13px; }
.lb .sc { font-weight: 900; font-size: 18px; min-width: 28px; text-align: right; }
.lb li.me { background: var(--card2); outline: 2px solid var(--accent); }
.lb .empty { justify-content: center; color: var(--muted); }
.codebox { background: var(--card); border-radius: var(--radius); padding: 14px; margin-top: 10px; text-align: center; }
.code { font-size: 40px; font-weight: 900; letter-spacing: 6px; color: var(--accent); margin: 4px 0; }
.chinfo { color: var(--muted); font-weight: 700; line-height: 1.45; }
.chinfo b { color: var(--text); }
.missed { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.missed div { background: var(--card); border-radius: 12px; padding: 8px 10px; font-weight: 800; font-size: 14px; display: flex; align-items: center; gap: 10px; }

/* Lär dig */
.search { width: 100%; font-weight: 800; font-size: 16px; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--card2); background: var(--card); color: var(--text); outline: none; margin: 10px 0; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.tile { background: var(--card); border-radius: 14px; padding: 10px 8px; text-align: center; }
.tile .n { font-weight: 800; font-size: 12.5px; line-height: 1.2; min-height: 32px; display: flex; align-items: center; justify-content: center; margin-top: 6px; }
.tile.hide .n { color: transparent; background: var(--card2); border-radius: 8px; }
.toggle { display: flex; align-items: center; justify-content: space-between; background: var(--card); border-radius: 14px; padding: 10px 14px; font-weight: 800; }
.sw { width: 50px; height: 28px; background: var(--card2); border-radius: 99px; position: relative; transition: .2s; flex: none; }
.sw::after { content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; }
.sw.on { background: var(--good); }
.sw.on::after { left: 25px; }
.count { color: var(--muted); font-weight: 700; font-size: 13px; }

@keyframes pop { from { transform: scale(.88); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.pop { animation: pop .22s ease-out; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.shake { animation: shake .25s; }

/* Duell */
.hint { margin-top: 8px; padding: 10px 14px; border-radius: 12px; background: #3a3210; color: var(--accent); font-weight: 800; font-size: 14px; }
.hint.warn { background: #3d1820; color: #ffb3bb; }
.aliasrow.nudge { border-color: var(--accent); animation: shake .3s; }
.duelbtn { width: 100%; text-align: left; margin-top: 12px; padding: 14px 16px; border-radius: var(--radius); background: linear-gradient(135deg, #8a2be2, #5a1fa0); border: 2px solid #b47cff; display: block; }
.duelbtn b { display: block; font-size: 17px; }
.duelbtn small { display: block; color: #e6d6ff; font-weight: 700; font-size: 13px; margin-top: 2px; }
.code-sm { letter-spacing: 3px; color: var(--accent); }
.conn { color: var(--bad); font-weight: 800; font-size: 14px; min-height: 0; }
.conn:not(:empty) { margin-bottom: 8px; }
.lb.duel li { align-items: flex-start; }
.lb.duel .nm { white-space: normal; }
.lb.duel .nm small { display: block; color: var(--muted); font-weight: 700; font-size: 12.5px; }
.lb.duel .nm em { color: var(--muted); font-style: normal; font-weight: 700; }
.lb.duel .wins { font-size: 13px; color: var(--accent); font-weight: 900; }
.lb.duel li.winner { outline: 2px solid var(--good); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #55667f; margin-top: 6px; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px rgba(46,204,143,.25); }
.pbar { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.pbar div { height: 100%; background: var(--accent); transition: width .3s; }
.duelstrip { display: flex; gap: 6px; overflow-x: auto; margin: -4px 0 10px; padding-bottom: 2px; scrollbar-width: none; }
.duelstrip span { flex: none; background: var(--card); border-radius: 99px; padding: 6px 11px; font-weight: 800; font-size: 13.5px; white-space: nowrap; }
.duelstrip span.me { background: var(--card2); outline: 2px solid var(--accent); }
.duelstrip span.done { color: var(--good); }
.duelstrip small { color: var(--muted); }
.countdown { font-size: 110px; font-weight: 900; color: var(--accent); line-height: 1.1; }

/* PIN */
.overlay { position: fixed; inset: 0; background: rgba(5,10,20,.85); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 10; }
.pinbox { background: var(--card); border-radius: 24px; padding: 24px; width: 100%; max-width: 360px; text-align: center; font-weight: 800; }
.pinicon { font-size: 44px; }
.pinbox input { width: 100%; margin-top: 14px; font-weight: 900; font-size: 26px; letter-spacing: 6px; text-align: center; padding: 12px; border-radius: 14px; border: 2px solid var(--card2); background: var(--bg); color: var(--text); outline: none; }

/* Delstatsflaggor: olika proportioner – visa hela flaggan */
img.flag.st { object-fit: contain; background: transparent; box-shadow: none; border-radius: 0; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
