:root {
  --bg: #121722; --bg-2: #1b2433; --panel: rgba(255, 255, 255, .055); --line: rgba(255, 255, 255, .1);
  --on-bg: #eef1f6; --on-bg-muted: #97a2b6; --accent: #f2c14e; --ok: #7fdc9c; --bad: #ff9a8f;
  --board: min(760px, 100%); /* sätts till spelplanens bredd av game.js */
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; color: var(--on-bg);
  background: radial-gradient(ellipse at 50% 0%, var(--bg-2), var(--bg) 70%) fixed, var(--bg);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex; flex-direction: column; align-items: center; padding: 16px;
}
.column { width: var(--board); max-width: 100%; }

/* ---------- Knappar ---------- */

button {
  font: inherit; font-size: .85rem; font-weight: 500; cursor: pointer; color: var(--on-bg);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; background: var(--panel);
  transition: background-color .15s, border-color .15s, opacity .15s;
}
button:hover { background: rgba(255, 255, 255, .1); border-color: rgba(242, 193, 78, .5); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .35; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #2b1a10; font-weight: 650; padding: 8px 22px; }
button.primary:hover { background: #f6d27a; }

/* ---------- Läget: dagens ö eller fritt spel ---------- */

.mode-row { text-align: center; margin-bottom: 10px; }
#mode {
  display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: .75rem;
  background: var(--panel); border: 1px solid var(--line); color: var(--on-bg-muted);
}
#mode.daily { border-color: rgba(242, 193, 78, .45); }
#mode b { color: var(--accent); }

/* ---------- Panel ovanför planen: ö och nivåer till vänster, siffror till höger ---------- */

/* Allt ryms på en rad; bara riktigt smala skärmar får bryta */
.hud { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
@media (max-width: 420px) { .hud { flex-wrap: wrap; justify-content: center; row-gap: 10px; } }

.where { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.island { font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; }
.where .label { color: var(--on-bg-muted); font-size: .8rem; }

.stages { display: flex; padding: 4px; gap: 4px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.stages button { border: 0; background: transparent; padding: 5px 12px; min-width: 34px; }
.stages button:hover { background: rgba(255, 255, 255, .08); }
.stages button:disabled { opacity: .45; }
.stages button[aria-pressed="true"] { background: var(--on-bg); color: var(--bg); }
.stages button .check { color: var(--ok); margin-left: 4px; }
.stages button[aria-pressed="true"] .check { color: #2e9b57; }
.stages button svg { width: 11px; height: 11px; margin-left: 5px; vertical-align: -1px; }

.stats { display: flex; gap: 6px; }
.stat {
  display: flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: 12px; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line); color: var(--on-bg-muted); font-size: .75rem;
}
.stat b { color: var(--on-bg); font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.stat.low b { color: var(--bad); }
.stat b.bump { animation: bump .5s cubic-bezier(.3, 1.6, .6, 1); }
@keyframes bump { 40% { transform: scale(1.35); color: var(--accent); } }
#streakBox.hot b { color: var(--accent); }
#streakBox:not(.hot) { opacity: .6; }

/* ---------- Spelplan och knappar under ---------- */

#wrap { width: 100%; display: flex; justify-content: center; }
canvas {
  display: block; touch-action: manipulation; border-radius: 16px; cursor: pointer;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .06);
}
#msg { min-height: 1.5em; margin: 14px 0 10px; font-weight: 600; text-align: center; }
#msg.ok { color: var(--ok); }
#msg.bad { color: var(--bad); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.links { display: flex; justify-content: center; gap: 4px; margin-top: 14px; }
.links button { background: none; border: 0; color: var(--on-bg-muted); }
.links button:hover { background: none; color: var(--on-bg); }
.links { flex-wrap: wrap; }
/* Ljudknapparna visar om ljudet är på eller av */
#musicBtn::before, #effectsBtn::before { content: '♪ '; }
#effectsBtn::before { content: '🔊 '; }
#musicBtn[aria-pressed="false"], #effectsBtn[aria-pressed="false"] { text-decoration: line-through; opacity: .6; }

/* ---------- Dialoger: intro och topplista ---------- */

dialog {
  border: 1px solid var(--line); border-radius: 20px; color: var(--on-bg);
  background: linear-gradient(180deg, #1e2838, #161d2a); box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  max-height: calc(100vh - 32px); overflow: auto;
}
dialog::backdrop { background: rgba(6, 10, 18, .7); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 4px; font-size: 1.35rem; text-align: center; }
dialog .lead { margin: 0 0 18px; color: var(--on-bg-muted); text-align: center; }
dialog .go { display: block; margin: 20px auto 0; font-size: .95rem; }

#intro { width: min(680px, calc(100vw - 32px)); padding: 26px 24px 22px; }
#intro .brand { margin: 0; text-align: center; color: var(--accent); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; font-size: .8rem; }
#intro ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
#intro li { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
#intro li svg { flex: none; width: 104px; height: 78px; border-radius: 8px; }
#intro li b { display: block; margin-bottom: 3px; }
#intro li span { color: var(--on-bg-muted); font-size: .85rem; line-height: 1.4; }
#intro .unlock { margin: 18px 0 0; }
#intro .daily-note { margin: 6px 0 0; }
#intro .daily-note b { color: var(--on-bg); }

#topDialog { width: min(460px, calc(100vw - 32px)); padding: 24px; }
#topDialog .lead { font-size: .9rem; }
#topDialog #topDaily { margin-bottom: 6px; color: var(--on-bg); }
dialog .choice { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
dialog .choice button { font-size: .95rem; }
#quitDialog { width: min(400px, calc(100vw - 32px)); padding: 24px; }
#topDialog table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .9rem; }
#topDialog th { text-align: left; font-weight: 500; color: var(--on-bg-muted); font-size: .75rem; padding: 4px 6px; }
#topDialog td { padding: 7px 6px; border-top: 1px solid var(--line); }
#topDialog .num { text-align: right; }
#topDialog tr.latest td { color: var(--accent); }

@media (prefers-reduced-motion: reduce) { .stat b.bump { animation: none; } }
