:root {
  --bg: #f6ecc9; --card: #fbf5df; --ink: #161616; --muted: #77705d; --line: #1616161a;
  --up: #2f7a4f; --down: #b33a22; --upbg: #d6ecd9; --downbg: #f7d3c6;
  --krypto: #ec7a55; --ai: #9db8e3; --energi: #f6d55c; --gull: #e8d9a8; --fond: #8fcdb6; --eiendom: #f2b48f;
  --paper: #f5d9c8; --glass: rgba(255, 252, 240, .5);
  --sans: 'Manrope', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --serif: 'Instrument Serif', Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-weight: 500; font-size: 16px; line-height: 1.42; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; cursor: pointer; color: inherit; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .4; }
a { color: inherit; text-decoration: none; }
input { font: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.serif { font-family: var(--serif); font-weight: 400; }
.cap { font-size: 13px; color: var(--muted); font-weight: 500; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }
.h1 { font-weight: 800; font-size: 34px; letter-spacing: -0.035em; line-height: 1.05; }
.h2 { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; line-height: 1.15; }
.lead { font-size: 16px; line-height: 1.45; color: #3f3a2c; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

/* ---------- knapper ---------- */
.btn { min-height: 56px; padding: 0 24px; border-radius: 999px; background: var(--ink); color: var(--bg); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; font-size: 17px; white-space: nowrap; }
.btn.o { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.btn.g { background: rgba(255,255,255,.55); color: var(--ink); }
.btn.sm { min-height: 44px; padding: 0 18px; font-size: 15px; }
.btn.xs { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn.block { width: 100%; }
.btn.red { background: transparent; color: var(--down); }
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btns { display: flex; gap: 10px; }
.btns > * { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.ib { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; flex: none; background: rgba(255,255,255,.5); font-size: 16px; }
.ib svg { width: 20px; height: 20px; }
.eff { min-height: 40px; min-width: 76px; border-radius: 999px; display: inline-grid; place-items: center; font-weight: 600; font-size: 15px; padding: 0 14px; box-shadow: inset 0 0 0 1.5px var(--ink); font-family: var(--mono); white-space: nowrap; flex: none; }
.eff.on { background: var(--ink); color: var(--bg); box-shadow: none; }
.chg { font-family: var(--mono); font-size: 12px; font-weight: 600; height: 24px; padding: 0 8px; border-radius: 7px; display: inline-flex; align-items: center; white-space: nowrap; background: rgba(22,22,22,.06); color: var(--muted); }
.chg.up { background: var(--upbg); color: var(--up); } .chg.down { background: var(--downbg); color: var(--down); }

/* ---------- topp og meny ---------- */
.top { position: sticky; top: 0; z-index: 20; padding: 12px 16px 0; }
.bar { max-width: 1080px; margin: 0 auto; height: 60px; border-radius: 999px; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 16px;
  background: var(--glass); -webkit-backdrop-filter: blur(16px) saturate(190%); backdrop-filter: blur(16px) saturate(190%);
  border: 1px solid rgba(255,255,255,.75); box-shadow: inset 0 1px 1px rgba(255,255,255,.9), 0 12px 32px rgba(40,30,0,.10); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; letter-spacing: -0.03em; }
.brand svg { flex: none; }
.bar nav { display: flex; gap: 4px; margin-left: auto; }
.bar nav a { height: 44px; padding: 0 16px; border-radius: 999px; display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 15px; color: rgba(22,22,22,.6); }
.bar nav a svg { width: 20px; height: 20px; }
.bar nav a.on { color: var(--ink); background: rgba(255,255,255,.7); box-shadow: inset 0 1px 0 #fff, 0 1px 6px rgba(40,30,0,.08); }
.bar .gt { flex: 1; min-width: 0; text-align: center; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .gt small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.conn { font-size: 12px; color: var(--down); font-weight: 700; }

.nav { position: fixed; left: 16px; right: 16px; bottom: calc(14px + env(safe-area-inset-bottom)); height: 64px; border-radius: 999px; display: none; padding: 5px; gap: 2px; z-index: 15; max-width: 520px; margin: 0 auto;
  background: var(--glass); -webkit-backdrop-filter: blur(16px) saturate(190%); backdrop-filter: blur(16px) saturate(190%);
  border: 1px solid rgba(255,255,255,.75); box-shadow: inset 0 1px 1px rgba(255,255,255,.9), 0 12px 32px rgba(40,30,0,.14); }
.nav a, .nav button { flex: 1; border-radius: 999px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 700; color: rgba(22,22,22,.55); position: relative; }
.nav svg { width: 22px; height: 22px; }
.nav .on { color: var(--ink); background: rgba(255,255,255,.7); box-shadow: inset 0 1px 0 #fff, 0 1px 6px rgba(40,30,0,.1); }
.pip { position: absolute; top: 8px; right: calc(50% - 18px); width: 9px; height: 9px; border-radius: 50%; background: var(--krypto); }
.icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- sider ---------- */
.screen { max-width: 600px; margin: 0 auto; padding: 28px 20px 60px; }
.screen.wide { max-width: 1080px; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.r { display: flex; align-items: center; gap: 12px; min-height: 60px; border-bottom: 1px solid var(--line); padding: 8px 0; width: 100%; text-align: left; }
button.r:hover, a.r:hover { background: rgba(255,255,255,.25); }
.r .t { font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.num { text-align: right; flex: none; }
.num b { display: block; font-family: var(--mono); font-weight: 600; font-size: 17px; letter-spacing: -0.02em; }
.num span { font-family: var(--mono); font-size: 11px; font-weight: 600; }
.av { border-radius: 50%; display: grid; place-items: center; font-weight: 800; flex: none; color: var(--ink); }
.empty { text-align: center; padding: 40px 10px 20px; }
.empty .die { margin: 0 auto 26px; transform: rotate(8deg); }
.box { background: var(--card); border-radius: 26px; padding: 22px; }
.box + .box { margin-top: 14px; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; border-bottom: 1px solid var(--line); }
.kv b { font-family: var(--mono); font-weight: 600; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: rgba(22,22,22,.08); }

/* ---------- skjema ---------- */
.flabel { display: block; font-size: 13px; font-weight: 700; margin: 16px 4px 6px; }
.input { width: 100%; height: 58px; border-radius: 18px; background: rgba(255,255,255,.55); border: 0; padding: 0 18px; font-size: 17px; font-weight: 500; color: var(--ink); }
.input::placeholder { color: #a49d88; }
.input:focus { outline: 2px solid var(--ink); outline-offset: 0; }
.err { color: var(--down); font-size: 14px; font-weight: 600; min-height: 20px; margin: 10px 4px; }
.seg { display: flex; min-height: 48px; border-radius: 999px; background: rgba(255,255,255,.45); padding: 4px; }
.seg button { flex: 1; border-radius: 999px; font-weight: 700; font-size: 15px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.codeboxes { display: flex; gap: 8px; }
.codeboxes input { flex: 1; min-width: 0; height: 64px; border-radius: 16px; border: 0; background: var(--card); text-align: center; font-family: var(--mono); font-size: 26px; font-weight: 600; text-transform: uppercase; color: var(--ink); }

/* ---------- innlogging ---------- */
.auth { max-width: 460px; margin: 0 auto; padding: 20px 20px 60px; min-height: 100vh; }
.auth .back { margin-bottom: 26px; }
.invitehead { background: var(--energi); margin: -20px -20px 10px; padding: 28px 20px 26px; }
.switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }
.switch button { font-weight: 700; color: var(--ink); }

/* ---------- hjem ---------- */
.turncard { display: block; background: var(--krypto); border-radius: 28px; padding: 20px 20px 22px; margin-bottom: 14px; }
.turncard .cap { color: #5a2615; font-weight: 700; }
.turncard .w { font-family: var(--mono); font-size: 36px; font-weight: 600; letter-spacing: -0.04em; display: flex; align-items: center; gap: 10px; margin: 6px 0 16px; }
.turncard .chg { background: #ffffff90; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; align-items: center; gap: 12px; border-radius: 22px; padding: 16px 18px; text-align: left; width: 100%; }
.opt b { display: block; font-size: 17px; }
.opt span.cap { color: rgba(22,22,22,.7); }
.opt::after { content: '›'; margin-left: auto; font-size: 24px; font-weight: 700; }

/* ---------- ark ---------- */
.dim { position: fixed; inset: 0; background: rgba(22,18,8,.32); z-index: 40; animation: fade .2s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--bg); border-radius: 30px 30px 0 0; padding: 10px 22px calc(28px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; max-width: 560px; margin: 0 auto; animation: up .25s cubic-bezier(.2,.8,.2,1); }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet .sh { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
@media (min-width: 761px) { .sheet { bottom: 50%; transform: translateY(50%); border-radius: 30px; animation: fade .2s; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- terning ---------- */
.die { width: 104px; height: 104px; border-radius: 26px; background: var(--card); box-shadow: inset 0 -6px 0 rgba(0,0,0,.06), 0 18px 30px rgba(60,40,0,.14); display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 20px; gap: 4px; flex: none; }
.die i { width: 15px; height: 15px; border-radius: 50%; background: var(--ink); place-self: center; }
.die.sm { width: 44px; height: 44px; border-radius: 12px; padding: 8px; gap: 1px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.06); }
.die.sm i { width: 6px; height: 6px; }
.dice { display: flex; gap: 22px; justify-content: center; }
.rolling .die { animation: tumble .7s ease-in-out infinite alternate; }
.rolling .die:last-child { animation-delay: -.35s; }
@keyframes tumble { from { transform: translateY(0) rotate(-10deg); } to { transform: translateY(-26px) rotate(14deg); } }

/* ---------- spill ---------- */
.game .screen { padding-top: 20px; }
.hero { text-align: center; padding: 30px 0 10px; }
.hero .h1 { font-size: 40px; margin-top: 4px; }
.hero .dice { margin: 34px 0 34px; }
.cta { margin-top: 22px; }
.note { font-size: 13px; color: var(--muted); margin-top: 12px; text-align: center; }
.landed { border-radius: 24px; padding: 18px 20px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.landed .h2 { font-size: 26px; }
.landed p { font-size: 15px; margin-top: 6px; }
.sec-sm { margin-top: 22px; margin-bottom: 4px; }
.choice { display: flex; align-items: center; gap: 12px; min-height: 64px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; padding: 6px 0; }
.choice.sel { background: var(--selc, var(--ai)); border-radius: 20px; border: 0; margin: 4px -10px; padding: 6px 10px; width: calc(100% + 20px); }
.choice.sel .dot { background: var(--ink) !important; }
.choice .sub { font-size: 12px; color: var(--muted); display: block; font-weight: 600; }
.choice .warn { color: var(--down); }
.choice:hover:not(:disabled) .eff { background: var(--ink); color: var(--bg); box-shadow: none; }
.waiting { text-align: center; padding: 26px 0 8px; }
.waiting .av { margin: 0 auto 14px; }
.market-mini { margin-top: 26px; }
.wheelwrap { display: grid; place-items: center; position: relative; margin: 10px auto; max-width: 340px; }
.wheel { width: 100%; height: auto; display: block; }
.wheelscreen { background: var(--energi); border-radius: 30px; padding: 22px 18px 24px; }

/* marked */
.worth { font-family: var(--mono); font-size: 40px; font-weight: 600; letter-spacing: -0.04em; display: flex; align-items: center; gap: 10px; }
.mkfoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }

.bigprice { font-family: var(--mono); font-size: 64px; font-weight: 600; letter-spacing: -0.05em; line-height: 1; }
.sheet .kv { border-color: rgba(22,22,22,.12); }
.chart { width: 100%; height: auto; display: block; margin: 16px 0 10px; }
.pos { font-size: 14px; }

/* brett – skalerer med skjermen; tekst og avstander følger brettets bredde (cqi) */
.board { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); gap: clamp(3px, .7cqi, 7px); aspect-ratio: 1; max-width: 640px; margin: 0 auto; container-type: inline-size; }
.cell { border-radius: clamp(7px, 1.4cqi, 14px); background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-size: clamp(8.5px, 2.1cqi, 18px); line-height: 1.1; font-weight: 700; position: relative; padding: 2px; }
.cell .v { font-size: clamp(11px, 2.65cqi, 24px); font-family: var(--mono); font-weight: 600; }
.cell.here { box-shadow: 0 0 0 3px var(--ink); z-index: 2; }
.cell.picked { outline: 2px dashed var(--ink); outline-offset: 2px; }
.toks { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); display: flex; }
.toks i { width: clamp(12px, 2.2cqi, 20px); height: clamp(12px, 2.2cqi, 20px); border-radius: 50%; border: 2px solid var(--bg); margin-left: -5px; display: block; }
.toks i:first-child { margin-left: 0; }
.center { grid-column: 2 / 8; grid-row: 2 / 8; border-radius: clamp(7px, 1.4cqi, 14px); background: var(--card); padding: clamp(10px, 2.2cqi, 22px); display: flex; flex-direction: column; min-height: 0; }
.center .bhead { font-size: clamp(9.5px, 1.7cqi, 14px); }
.bars { flex: 1; display: flex; align-items: flex-end; gap: clamp(5px, 1.3cqi, 14px); margin-top: 8px; min-height: 0; }
.bars > div { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; }
.bars i { display: block; width: 100%; border-radius: clamp(4px, 1cqi, 10px); }
.bars span { font-family: var(--mono); font-size: clamp(9.5px, 1.75cqi, 15px); font-weight: 600; }
.bars span.lbl { font-size: clamp(8px, 1.4cqi, 12px); }
.cellinfo { max-width: 640px; margin: 18px auto 0; }

/* på PC fyller brettet høyden på skjermen (minus toppen), med feltinfo ved siden av når det er plass */
@media (min-width: 761px) {
  .screen.brett { max-width: 1400px; --bw: min(1000px, max(520px, calc(100dvh - 140px))); }
  .screen.brett .board { max-width: var(--bw); }
  .screen.brett .cellinfo { max-width: var(--bw); }
}
@media (min-width: 1100px) {
  .screen.brett .boardwrap { display: grid; grid-template-columns: minmax(0, var(--bw)) 300px; gap: 36px; justify-content: center; align-items: start; }
  .screen.brett .board { width: 100%; }
  .screen.brett .cellinfo { margin: 0; position: sticky; top: 100px; }
}

/* hendelser */
.event { position: fixed; inset: 0; z-index: 60; background: var(--paper); display: flex; flex-direction: column; padding: calc(60px + env(safe-area-inset-top)) 24px calc(30px + env(safe-area-inset-bottom)); animation: fade .25s; }
.event .in { max-width: 520px; width: 100%; margin: 0 auto; flex: 1; display: flex; flex-direction: column; }
.event .kick { font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding-bottom: 10px; border-bottom: 1.5px solid currentColor; }
.event h2 { font-family: var(--serif); font-weight: 400; font-size: 58px; line-height: .98; margin-top: 22px; letter-spacing: -0.01em; }
.event p { font-size: 18px; margin-top: 14px; line-height: 1.45; }
.event .btn { margin-top: auto; }
.event.warn { background: var(--gull); }
.event.dark { background: var(--ink); color: var(--bg); }
.event.dark .btn { background: var(--bg); color: var(--ink); }
.event.end { background: var(--fond); }

/* sluttresultat */
.result { background: var(--fond); border-radius: 30px; padding: 26px 22px; text-align: center; }
.result .serif { font-size: 54px; line-height: 1; margin-top: 8px; }
.result .w { font-family: var(--mono); font-size: 28px; font-weight: 600; margin-top: 6px; }
.podium { display: flex; align-items: flex-end; gap: 10px; margin: 26px 0 8px; }
.podium > div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.podium .blk { width: 100%; background: var(--ink); color: var(--bg); border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.podium .nm { font-size: 13px; font-weight: 700; }

/* logg */
.logrow { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.logrow.k-up { color: var(--up); } .logrow.k-down { color: var(--down); } .logrow.k-big { font-weight: 700; }

/* regler */
.rules section { margin-top: 28px; }
.rules h2 { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; margin-bottom: 8px; }
.rules p { margin-bottom: 10px; color: #3f3a2c; }
.rules ul { padding-left: 20px; color: #3f3a2c; }
.rules li { margin-bottom: 6px; }
.steps { display: flex; flex-direction: column; gap: 10px; }
.step { display: flex; gap: 12px; align-items: flex-start; }
.step .n { width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none; }

/* lobby */
.lobbyhead { background: var(--energi); border-radius: 30px; padding: 22px 22px 24px; margin-bottom: 18px; }
.invite { display: flex; align-items: center; gap: 8px; height: 52px; border-radius: 999px; background: rgba(255,255,255,.55); padding: 0 6px 0 18px; margin-top: 16px; }
.invite code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 14px; }

/* toppliste */
.lbrow { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; min-height: 60px; border-bottom: 1px solid var(--line); }
.lbrow.me { font-weight: 800; }
.lbstats { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 16px; font-weight: 600; font-size: 15px; max-width: min(92vw, 480px); opacity: 0; pointer-events: none; transition: .25s; z-index: 80; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--down); color: #fff; }

/* ---------- bredt: to kolonner i spillet ---------- */
.cols { display: grid; gap: 40px; }
@media (min-width: 1000px) {
  .game .screen.wide .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .only-narrow { display: none !important; }
}
@media (max-width: 999px) { .only-wide { display: none !important; } }

/* ---------- mobil ---------- */
@media (max-width: 760px) {
  .top { padding: 10px 12px 0; }
  .bar { height: 56px; }
  .bar nav { display: none; }
  .nav { display: flex; }
  .screen { padding: 20px 20px calc(110px + env(safe-area-inset-bottom)); }
  .hero .h1 { font-size: 36px; }
  .event h2 { font-size: 48px; }
}
