/* Vardeild. Én spalte: toppfelt, brett, bunnfelt. Mål i em, der 1em = 10 px på en iPhone og skaleres med skjermen. */
:root {
  --bg: #26362e;
  --bg-deep: #1b2721;
  --panel: #f7f0de;
  --card: #ece2cb;
  --ink: #34281e;
  --sub: #786856;
  --line: #5c4630;
  --accent: #c44a2c;
  --accent-deep: #a23a20;
  --gold: #e2aa36;
  --silver: #d6dae0;
  --silver-edge: #80868e;
  --mist: #e2e2dc;
  --good: #5a9a3c;
  --u: 1;
  --col: 100%;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; }
html { overscroll-behavior: none; }
body {
  margin: 0; background: var(--bg); color: var(--ink); overflow: hidden; overscroll-behavior: none;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
#app { position: relative; height: 100%; display: flex; flex-direction: column; font-size: calc(var(--u) * 10px); font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; border: 0; margin: 0; cursor: pointer; }
button:focus-visible { outline: 0.3em solid var(--gold); outline-offset: 0.2em; }
.col { width: 100%; max-width: var(--col); margin-inline: auto; padding-inline: 1.2em; box-sizing: border-box; display: flex; flex-direction: column; gap: 0.6em; }

/* ---------- topp */
#top, #bottom, #stage, #dialog { touch-action: none; }
#sheet { touch-action: pan-y; }
#top { padding-block: 0.6em; }
.pills { display: flex; gap: 0.9em; align-items: stretch; }
.pill {
  height: 3.6em; box-sizing: border-box; border-radius: 1.8em; background: var(--panel); border: 0.14em solid var(--line);
  display: flex; align-items: center; gap: 0.7em; padding-inline: 1.1em 1.2em; min-width: 0;
}
.pill b { font-size: 2.1em; font-weight: 800; letter-spacing: -0.01em; }
.pill .ic { width: 2.2em; height: 2.4em; flex: none; }
#pill-glor { flex: 0.78 1 0; }
#pill-solv { flex: 1.1 1 0; }
#pill-bolge { flex: 1.1 1 0; justify-content: space-between; gap: 0.4em; padding-inline: 1em 1em; }
#pill-bolge span { font-size: 0.9em; font-weight: 800; letter-spacing: 0.06em; color: var(--sub); }
#pill-bolge b { font-size: 1.75em; letter-spacing: -0.02em; }
.fl1 { fill: var(--accent); } .fl2 { fill: var(--gold); }
.co1 { fill: var(--silver); stroke: var(--silver-edge); stroke-width: 1.6; } .co2 { fill: none; stroke: var(--silver-edge); stroke-width: 1.3; }
.round { width: 3.6em; flex: none; padding: 0; justify-content: center; }
.round svg { width: 2.4em; height: 2.4em; fill: var(--ink); }
.pill.bump b { animation: bump 0.35s ease-out; }
.pill.hurt { animation: hurt 0.5s ease-out; }
@keyframes bump { 0% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes hurt { 0% { background: #ffb39c; } 100% { background: var(--panel); } }

.strip {
  height: 3.6em; border-radius: 1.4em; background: var(--panel); border: 0.14em solid var(--line); box-sizing: border-box;
  display: flex; align-items: center; justify-content: space-between; gap: 1em; padding-inline: 1.4em; text-align: left; width: 100%;
}
.strip-t { display: flex; flex-direction: column; gap: 0.15em; min-width: 0; }
.eyebrow { font-size: 1em; font-weight: 800; letter-spacing: 0.05em; color: var(--accent); line-height: 1.1; }
#varsel { font-size: 1.3em; font-weight: 550; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip svg { width: 0.9em; height: 1.5em; flex: none; fill: none; stroke: var(--sub); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- brett */
#stage { flex: 1 1 0; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; background: var(--bg-deep); }
#board { position: relative; overflow: hidden; box-shadow: 0 0 0 0.14em var(--line); }
#c { display: block; touch-action: none; }
#board.shake { animation: shake 0.28s linear; }
@keyframes shake { 20% { transform: translate(-0.4em, 0.2em); } 45% { transform: translate(0.4em, -0.2em); } 70% { transform: translate(-0.2em, 0.1em); } }
#hint {
  position: absolute; left: 50%; bottom: 0.8em; transform: translateX(-50%); max-width: calc(100% - 2.4em); box-sizing: border-box;
  background: rgba(27, 39, 33, 0.9); color: var(--panel); border-radius: 1.2em; padding: 0.7em 1.3em; text-align: center;
  font-size: 1.25em; font-weight: 600; line-height: 1.3; pointer-events: none; width: max-content;
}
#board.haspanel #hint { bottom: 5.4em; }
#hint small { display: block; font-size: 0.9em; font-weight: 500; color: var(--mist); }
#hint.live { pointer-events: auto; display: flex; align-items: center; gap: 1em; }
#hint button { background: var(--panel); color: var(--ink); border-radius: 0.8em; padding: 0.35em 0.9em; font-weight: 700; }
#toast {
  position: absolute; left: 50%; top: 1em; transform: translateX(-50%); background: rgba(27, 39, 33, 0.9); color: var(--panel);
  border-radius: 1.2em; padding: 0.6em 1.3em; font-size: 1.35em; font-weight: 700; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.35s;
}
#toast.on { opacity: 1; }

/* ---------- bunn */
#bottom { padding-block: 0.6em 0.8em; }
#slot { position: relative; }
#cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.8em; }
.card {
  height: 5.6em; border-radius: 1.2em; background: var(--card); border: 0.14em solid var(--line); box-sizing: border-box; padding: 0.45em 0.5em 0.4em;
  display: grid; grid-template-rows: auto 1fr; justify-items: center; align-items: center; min-width: 0; position: relative;
}
.card .nm { font-size: 1.05em; font-weight: 650; white-space: nowrap; }
.card .bd { display: flex; align-items: center; justify-content: center; gap: 0.2em; width: 100%; }
.card img { height: 3.2em; width: 2.6em; object-fit: contain; flex: none; }
.card .pr { display: flex; align-items: center; gap: 0.2em; font-size: 1.6em; font-weight: 800; letter-spacing: -0.01em; }
.card .pr svg { width: 0.72em; height: 0.72em; }
.card.sel { background: var(--panel); box-shadow: 0 0 0 0.25em var(--gold); border-color: var(--gold); }
.card.poor .pr { color: var(--accent); }
.card.poor img { opacity: 0.55; }
.card.off { opacity: 0.6; }
.card.lock { background: none; border: 0.11em solid var(--sub); color: var(--mist); font-size: 1em; display: flex; flex-direction: column; justify-content: center; gap: 0.25em; cursor: default; }
.card.lock span { font-size: 1.1em; font-weight: 600; line-height: 1.2; }
.card.lock span + span { font-weight: 500; }

#panel {
  position: absolute; left: 0; right: 0; bottom: 0; background: var(--panel); border: 0.14em solid var(--line); border-radius: 1.4em;
  padding: 0.6em 0.8em 0.8em 1em; box-sizing: border-box; display: flex; flex-direction: column; gap: 0.5em; box-shadow: 0 -0.4em 1.6em rgba(0, 0, 0, 0.35);
}
.ph { display: flex; align-items: center; gap: 0.8em; }
.ph .tx { flex: 1; min-width: 0; font-size: 1.15em; line-height: 1.3; color: var(--sub); font-weight: 550; }
.ph .tx b { font-size: 1.3em; font-weight: 800; color: var(--ink); }
.ph .tx i { font-style: normal; font-weight: 650; margin-right: 0.5em; }
.nw { white-space: nowrap; }
.ph .x { width: 2.8em; height: 2.8em; border-radius: 50%; background: var(--card); border: 0.14em solid var(--line); flex: none; display: grid; place-items: center; padding: 0; }
.ph .x svg { width: 1.2em; height: 1.2em; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; fill: none; }
.pa { display: grid; grid-template-columns: 1.7fr 1fr 1fr; gap: 0.7em; }
.pb {
  min-height: 4.4em; border-radius: 1.1em; background: var(--card); border: 0.14em solid var(--line); box-sizing: border-box; padding: 0.4em 0.6em;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1em; min-width: 0;
}
.pb .l { font-size: 1em; font-weight: 700; color: var(--sub); letter-spacing: 0.02em; }
.pb .v { font-size: 1.55em; font-weight: 800; display: flex; align-items: center; gap: 0.3em; }
.pb .v svg { width: 0.75em; height: 0.75em; }
.pb .d { font-size: 0.98em; font-weight: 550; color: var(--sub); text-align: center; line-height: 1.15; }
.pb.go { background: var(--good); border-color: #33601f; color: #fffaf0; }
.pb.go .l, .pb.go .d { color: #eaf6dc; }
.pb[disabled] { opacity: 0.5; cursor: default; }
.pb.go[disabled] { background: var(--card); color: var(--ink); border-color: var(--line); }
.pb.go[disabled] .l, .pb.go[disabled] .d { color: var(--sub); }

.row { display: flex; gap: 0.8em; }
#speed { width: 6.4em; height: 4em; flex: none; border-radius: 1.4em; background: var(--panel); border: 0.14em solid var(--line); font-size: 1em; }
#speed b { font-size: 1.8em; font-weight: 800; }
#start {
  flex: 1; height: 4em; border-radius: 1.4em; background: var(--accent); border: 0.14em solid var(--line); color: #fffaf0;
  display: flex; align-items: center; justify-content: center; min-width: 0;
}
#start span { font-size: 1.6em; font-weight: 800; white-space: nowrap; }
#start:active:not([disabled]) { background: var(--accent-deep); }
#start[disabled] { background: #55473b; color: var(--mist); cursor: default; }
#start.ready { animation: ready 1.6s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: 0 0 0 0.35em rgba(226, 170, 54, 0.55); } }

/* ---------- dialoger */
#dialog { position: absolute; inset: 0; background: rgba(15, 22, 18, 0.72); display: flex; align-items: center; justify-content: center; padding: 1.6em; z-index: 20; }
#sheet {
  width: 100%; max-width: 36em; max-height: 100%; overflow-y: auto; box-sizing: border-box; background: var(--panel); border: 0.16em solid var(--line);
  border-radius: 2em; padding: 2em 1.8em 1.8em; display: flex; flex-direction: column; gap: 1.2em; -webkit-overflow-scrolling: touch;
}
#sheet h2 { margin: 0; font-size: 2.4em; font-weight: 800; letter-spacing: -0.01em; text-wrap: balance; text-align: center; }
#sheet p { margin: 0; font-size: 1.45em; line-height: 1.4; color: var(--ink); }
#sheet p.c { text-align: center; }
#sheet p.s { font-size: 1.25em; color: var(--sub); }
#sheet ol.how { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.9em; }
#sheet ol.how li { font-size: 1.45em; line-height: 1.35; display: flex; gap: 0.7em; align-items: center; }
#sheet ol.how img { width: 2.6em; height: 2.6em; object-fit: contain; flex: none; }
#sheet ol.how .ei { height: 2.6em; }
.btn {
  min-height: 4.4em; border-radius: 1.4em; background: var(--card); border: 0.14em solid var(--line); padding: 0.5em 1em; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%;
}
.btn span { font-size: 1.55em; font-weight: 750; }
.btn small { font-size: 1.15em; color: var(--sub); font-weight: 500; }
.btn.pri { background: var(--accent); color: #fffaf0; }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btns { display: flex; flex-direction: column; gap: 0.8em; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8em; }
.seg .btn.on { background: var(--ink); color: var(--panel); }
.lbl { font-size: 1.1em; font-weight: 800; letter-spacing: 0.06em; color: var(--sub); text-transform: uppercase; margin-top: 0.4em; }
.stars { display: flex; justify-content: center; gap: 0.8em; }
.stars svg { width: 5em; height: 5em; }
.stars .on { fill: var(--gold); stroke: #a8771c; stroke-width: 1.2; }
.stars .no { fill: #d8ccb2; stroke: #b9ab8e; stroke-width: 1.2; }
.wl { display: flex; flex-direction: column; gap: 0.5em; }
.wr { display: grid; grid-template-columns: 2.6em 1fr; align-items: center; gap: 0.8em; padding: 0.55em 0.8em; border-radius: 1em; background: var(--card); }
.wr.cur { box-shadow: inset 0 0 0 0.2em var(--gold); background: #fff8e4; }
.wr.done { opacity: 0.5; }
.wr .no { font-size: 1.5em; font-weight: 800; text-align: center; color: var(--sub); }
.wr .gs { display: flex; flex-wrap: wrap; gap: 0.3em 1.1em; }
.wr .g { display: flex; align-items: center; gap: 0.35em; font-size: 1.5em; font-weight: 750; }
.ei { display: block; flex: none; background-repeat: no-repeat; }
.wr .g .ei { height: 1.45em; }
.legend { display: flex; flex-direction: column; gap: 0.5em; }
.legend .e { display: grid; grid-template-columns: 4.2em 1fr; gap: 0.8em; align-items: center; }
.legend .ei { height: 3em; justify-self: center; }
.legend b { font-size: 1.4em; text-transform: capitalize; }
.legend span { font-size: 1.2em; color: var(--sub); display: block; line-height: 1.3; }

/* ---------- lasting */
#loading { position: absolute; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 30; transition: opacity 0.4s; }
#loading.gone { opacity: 0; pointer-events: none; }
.ld { display: flex; flex-direction: column; align-items: center; gap: 1.4em; color: var(--panel); }
.ld-fire { width: 5em; height: 6em; background: var(--accent); clip-path: polygon(50% 0, 88% 44%, 76% 100%, 24% 100%, 12% 44%); position: relative; animation: flick 0.9s ease-in-out infinite alternate; }
.ld-fire::after { content: ""; position: absolute; inset: 38% 26% 0; background: var(--gold); clip-path: polygon(50% 0, 100% 50%, 82% 100%, 18% 100%, 0 50%); }
@keyframes flick { to { transform: scaleY(1.08) translateY(-3%); } }
#ld-t { font-size: 1.7em; font-weight: 700; }
.ld-bar { width: 16em; height: 0.8em; border-radius: 0.4em; background: var(--bg-deep); overflow: hidden; }
.ld-bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.2s; }

@media (prefers-reduced-motion: reduce) {
  #start.ready, .ld-fire, #board.shake, .pill.bump b { animation: none; }
}
