* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #120b07;
  --card: rgba(28, 19, 13, .92);
  --line: rgba(232, 176, 74, .3);
  --gold: #e8b04a;
  --gold-hi: #ffd54a;
  --text: #f5ead6;
  --muted: rgba(245, 234, 214, .65);
}

html, body { min-height: 100%; }
body {
  background: radial-gradient(ellipse at 50% -10%, #5a3214 0%, #2a160b 35%, var(--bg) 75%) fixed, var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif, "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji";
  padding: clamp(16px, 2.5vw, 40px);
  font-size: clamp(15px, 1.25vw, 24px);
}

.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: clamp(14px, 2vw, 32px); flex-wrap: wrap; }
h1 {
  font-size: clamp(30px, 4.2vw, 76px); font-weight: 900; letter-spacing: -1px; line-height: 1;
  background: linear-gradient(#ffe7a3, #d08a2e);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.live-dot {
  font-size: .32em; letter-spacing: 2px; vertical-align: middle; color: #ff6b5a; -webkit-text-fill-color: #ff6b5a;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; } }
.subtitle { margin-top: 6px; font-size: 1.1em; color: var(--muted); }
.subtitle b { color: var(--gold-hi); letter-spacing: 3px; }
.meta { text-align: right; }
.clock { font-size: 2em; font-weight: 800; font-variant-numeric: tabular-nums; }
.join { color: var(--muted); }
.join b { color: var(--gold); }

.grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: clamp(14px, 2vw, 32px); align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: minmax(0, 1fr); } .meta { text-align: left; } }
@media (max-width: 600px) { .leader .avatar { font-size: 2.2em; } .leader .name { font-size: 1.5em; } .leader .score { font-size: 2.2em; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: clamp(14px, 1.6vw, 28px); box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
h2 { font-size: 1.3em; color: var(--gold); }
.pill { padding: 4px 12px; border-radius: 999px; background: rgba(232,176,74,.15); color: var(--gold-hi); font-weight: 700; white-space: nowrap; font-size: .85em; }

.leader {
  display: flex; align-items: center; gap: 18px; margin-bottom: 16px;
  padding: clamp(12px, 1.4vw, 24px); border-radius: 16px;
  background: linear-gradient(90deg, rgba(255,213,74,.25), rgba(255,213,74,.04));
  border: 1px solid rgba(255,213,74,.5);
}
.leader .avatar { font-size: 3.2em; line-height: 1; }
.leader .who { flex: 1; min-width: 0; }
.leader .label { color: var(--gold-hi); font-weight: 800; text-transform: uppercase; letter-spacing: 2px; font-size: .75em; }
.leader .name { font-size: 2em; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader .score { font-size: 3em; font-weight: 900; color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.leader .tasted { color: var(--muted); }

.board { width: 100%; border-collapse: collapse; }
.board th { text-align: left; font-size: .7em; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 6px 10px; font-weight: 700; }
.board td { padding: .55em 10px; }
.board tbody tr:nth-child(odd) { background: rgba(255,255,255,.045); }
.board th.num, .board td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.board td.rank { width: 2.4em; color: var(--muted); font-weight: 700; }
.board td.name { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.board td.best { font-weight: 900; color: var(--gold-hi); font-size: 1.1em; }
.board td.tasted { color: #f0c27a; font-weight: 700; }
.board tr.first td.rank { color: var(--gold-hi); }
.board tr.none { opacity: .5; }
.board tr.flash { animation: flash 2.5s ease-out; }
@keyframes flash { 0% { background: rgba(125, 220, 106, .55); } 100% { background: transparent; } }
.board.small { font-size: .9em; }

.empty { color: var(--muted); text-align: center; padding: 24px 8px; font-size: 1.1em; }
.note { margin-top: 14px; color: var(--muted); font-size: .8em; }
.status { position: fixed; bottom: 10px; right: 16px; font-size: 13px; color: #ffb27a; }
.hidden { display: none !important; }

/* QR-kode til spillet */
.qr-box {
  display: flex; align-items: center; gap: 16px; margin-bottom: 20px; padding-bottom: 18px;
  border-bottom: 1px solid var(--line); color: inherit; text-decoration: none;
}
.qr { flex: 0 0 auto; width: clamp(120px, 11vw, 220px); aspect-ratio: 1; background: #fff; border-radius: 12px; padding: 6px; }
.qr svg { display: block; width: 100%; height: 100%; }
.qr-title { font-size: 1.25em; font-weight: 900; color: var(--gold-hi); }
.qr-sub { color: var(--muted); margin-top: 4px; word-break: break-all; }
.qr-sub b { color: var(--gold); letter-spacing: 2px; white-space: nowrap; }
@media (max-width: 900px) { .qr { width: 120px; } }
.admin-link { color: var(--gold); font-size: .85em; font-weight: 700; text-decoration: none; margin-left: 12px; }
.meta .admin-link { display: inline-block; margin-top: 6px; }

/* Rekorder: dato ved klikk eller mouseover */
.board tr.record { cursor: pointer; }
.board tr.record:hover td { background: rgba(232,176,74,.1); }
.board tr.record.open td { background: rgba(232,176,74,.14); }
.board tr.record-when td { padding-top: 0; color: var(--muted); font-size: .85em; background: rgba(232,176,74,.14); }
.row-actions { display: inline-flex; flex-wrap: wrap; gap: 8px; margin-left: 12px; vertical-align: middle; }
.row-btn {
  font: inherit; font-size: .9em; font-weight: 700; cursor: pointer; padding: 3px 10px; border-radius: 8px;
  color: var(--text); background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2);
}
.row-btn:hover { border-color: var(--gold); }
.row-btn.danger { color: #ffb0a5; border-color: rgba(255,107,90,.4); }
.board tr.record-when td { white-space: normal; }
.whoami { margin-top: 8px; font-size: .85em; color: var(--muted); }
.whoami b { color: var(--text); }
.whoami a { color: var(--gold); }
.whoami .role {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: -0.45em; margin-left: 4px;
  width: 1.6em; height: 1.6em; border-radius: 50%; cursor: help;
  color: #2a1606; background: linear-gradient(#ffd77a, #e09a35); box-shadow: 0 0 0 1px rgba(255,213,74,.5);
}
.whoami .role svg { width: 1.05em; height: 1.05em; }
.main-card .note { margin-top: 12px; }

/* ---------- Spillerpanel ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center;
  padding: clamp(12px, 4vw, 48px) 16px; overflow-y: auto; background: rgba(6, 3, 2, .7);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.modal-card {
  position: relative; width: 100%; max-width: 760px; margin: auto; min-width: 0; box-sizing: border-box;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: clamp(16px, 2vw, 28px);
  box-shadow: 0 20px 60px rgba(0,0,0,.6); font-size: clamp(14px, 1.1vw, 18px);
}
.modal-close {
  position: absolute; top: 10px; right: 14px; background: none; border: 0; color: var(--muted);
  font-size: 30px; line-height: 1; cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.pp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding-right: 30px; }
.pp-avatar { font-size: 2.4em; line-height: 1; }
.pp-head h2 { font-size: 1.6em; color: var(--text); }
.pp-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 14px; }
.pp-tile { background: rgba(255,255,255,.05); border-radius: 12px; padding: 8px 12px; }
.pp-tile span { display: block; color: var(--muted); font-size: .8em; }
.pp-tile b { font-size: 1.35em; font-variant-numeric: tabular-nums; }
.pp-charts { display: grid; gap: 6px; }
.pp-chart { margin: 0; }
.pp-chart figcaption { color: var(--muted); font-size: .85em; margin-bottom: 2px; }
.pp-chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.pp-grid { stroke: rgba(245,234,214,.1); stroke-width: 1; }
.pp-axis { fill: rgba(245,234,214,.55); font-size: 15px; font-variant-numeric: tabular-nums; }
.pp-cross { stroke: rgba(245,234,214,.5); stroke-width: 1; stroke-dasharray: 3 3; }
.pp-tip {
  position: absolute; z-index: 2; pointer-events: none; display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; border-radius: 10px; font-size: .85em; white-space: nowrap;
  background: #2a1d13; border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
.pp-sub { margin: 16px 0 6px; color: var(--gold); font-size: 1em; }
.pp-table-wrap { max-height: 40vh; overflow: auto; }
.pp-table td.when { white-space: nowrap; color: var(--muted); width: 1%; }
.pp-table td.name { color: var(--muted); }
svg .hidden { display: none; }
@media (max-width: 600px) {
  .modal { padding: 8px; }
  .pp-stats { grid-template-columns: repeat(3, 1fr); }
  .pp-tile b { font-size: 1.1em; }
  .pp-table td, .pp-table th { padding: 6px 5px; }
}
.whoami .link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--gold); cursor: pointer; text-decoration: underline; }
