/* Hard Eight. Every colour, size and duration is a token from DESIGN.md - never a raw value.
   Pit dark, one table in the light cone, and the winning glow as the loudest thing on screen. */

@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/oswald-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2070-209F, U+20A0-20AB, U+2113, U+2C60-2C7F;
}
@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/oswald-latin-ext-500-normal.woff2') format('woff2');
  unicode-range: U+0100-024F, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/oswald-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2070-209F, U+20A0-20AB, U+2113, U+2C60-2C7F;
}
@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/oswald-latin-ext-700-normal.woff2') format('woff2');
  unicode-range: U+0100-024F, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Pit - everything outside the table */
  --he-pit: #0a0b0c;
  --he-surface: #14181a;
  --he-surface-2: #1d2224;
  --he-line: #2c3134;

  /* Text outside the felt */
  --he-ink: #f4efe4;
  --he-ink-2: #bdb6a8;
  --he-ink-3: #8b857a;
  --he-ink-dark: #120f08;

  /* Gold - the only accent outside the felt */
  --he-gold: #e3b23c;
  --he-gold-deep: #9a7420;
  --he-gold-soft: rgba(227, 178, 60, .12);

  /* Casino red - fill and signal, never body text */
  --he-red: #c8102e;
  --he-red-light: #ef4a5e;

  /* The felt */
  --he-felt: #0e4133;
  --he-felt-dark: #072318;
  --he-felt-light: #17604a;

  /* The print ON the felt */
  --he-print: #f3ead7;
  --he-print-gold: #e9cd72;
  --he-print-red: #c8102e;

  /* The table's physical parts */
  --he-leather: #3b2119;
  --he-chrome: #c6ccd1;
  --he-dice: #d4142b;
  --he-pip: #fbf7ef;

  /* Winning */
  --he-win: #ffd766;
  /* The error state on the felt. --he-red-light is 2,1:1 on --he-felt-light and may only be
     used on --he-pit / --he-surface (DESIGN.md 1). This rose holds 4,9:1 on the lightest
     felt and 7,6:1 on the base felt. */
  --he-red-on-felt: #ffc2c7;
  --he-win-soft: rgba(255, 215, 102, .22);
  --he-lose: rgba(0, 0, 0, .55);

  /* Chips */
  --he-chip-1: #f4f2ec;
  --he-chip-5: #c8102e;
  --he-chip-25: #16663e;
  --he-chip-100: #141414;
  --he-chip-500: #5b2d8e;
  --he-chip-1000: #e0771c;

  /* Typography */
  --he-font-print: 'Oswald', 'Haettenschweiler', 'Arial Narrow', sans-serif;
  --he-font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  --he-font-num: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --he-t-wordmark: clamp(2.2rem, 11vw, 4.4rem);
  --he-t-h1: clamp(1.4rem, 5vw, 1.9rem);
  --he-t-h2: 1.15rem;
  --he-t-body: 1rem;
  --he-t-meta: .8125rem;
  --he-t-print: clamp(.6875rem, 1.1vw, .95rem);
  --he-t-money: 1.35rem;

  /* Rhythm and touch */
  --he-gap-1: 4px;
  --he-gap-2: 8px;
  --he-gap-3: 12px;
  --he-gap-4: 16px;
  --he-gap-5: 24px;
  --he-gap-6: 36px;
  --he-r-sm: 6px;
  --he-r-md: 12px;
  --he-r-lg: 18px;
  --he-r-print: 4px;
  --he-tap: 48px;
  --he-tap-min: 44px;

  /* Motion */
  --he-t-tick: 90ms;
  --he-t-fast: 160ms;
  --he-t-base: 240ms;
  --he-t-slow: 420ms;
  --he-t-hold: 900ms;
  --he-ease-out: cubic-bezier(.22, .9, .26, 1);
  --he-ease-in: cubic-bezier(.5, 0, .9, .4);
  --he-ease-pop: cubic-bezier(.2, 1.5, .35, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  /* clip, not hidden - hidden kills position: sticky (house rule) */
  overflow-x: clip;
  background: var(--he-pit);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--he-pit);
  color: var(--he-ink-2);
  font-family: var(--he-font-ui);
  font-size: var(--he-t-body);
  line-height: 1.5;
  overscroll-behavior-y: contain;
}

/* [hidden] before any display rule, so it always wins (house rule) */
[hidden] { display: none !important; }

h1, h2, h3 { color: var(--he-ink); margin: 0 0 var(--he-gap-3); line-height: 1.2; }
h1 { font-size: var(--he-t-h1); }
h2 { font-size: var(--he-t-h2); }
p { margin: 0 0 var(--he-gap-3); }
a { color: var(--he-gold); }

:focus-visible {
  outline: 2px solid var(--he-gold);
  outline-offset: 2px;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.he-sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- buttons */
.he-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--he-gap-2);
  min-height: var(--he-tap);
  padding: 0 var(--he-gap-5);
  border: 1px solid var(--he-gold-deep);
  border-radius: var(--he-r-md);
  background: var(--he-surface-2);
  color: var(--he-ink);
  font-family: var(--he-font-print);
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: background var(--he-t-tick) var(--he-ease-out), transform var(--he-t-tick) var(--he-ease-out);
}
.he-btn:hover:not(:disabled) { background: var(--he-surface); }
.he-btn:active:not(:disabled) { transform: translateY(1px); }
.he-btn:disabled { opacity: .45; cursor: not-allowed; }
.he-btn--primary {
  background: linear-gradient(180deg, var(--he-gold), var(--he-gold-deep));
  color: var(--he-ink-dark);
  border-color: var(--he-gold);
  font-weight: 700;
}
.he-btn--ghost { background: transparent; border-color: var(--he-line); }
.he-btn--icon {
  flex: 0 0 auto;
  min-width: var(--he-tap-min);
  min-height: var(--he-tap-min);
  width: var(--he-tap-min);
  height: var(--he-tap-min);
  padding: 0;
  border-radius: 50%;
  font-size: 1.05rem;
}

/* ---------------------------------------------------------------- screens */
.he-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------------------------------------------------------------- name screen */
#skaerm-navn {
  align-items: center;
  justify-content: center;
  padding: var(--he-gap-5) var(--he-gap-4);
  text-align: center;
  position: relative;
  isolation: isolate;
}
#navn-baggrund {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60% 40% at 50% 42%, rgba(23, 96, 74, .35), transparent 70%),
    radial-gradient(80% 60% at 50% 110%, rgba(59, 33, 25, .5), transparent 70%),
    var(--he-pit);
}
.he-wordmark {
  font-family: var(--he-font-print);
  font-weight: 700;
  font-size: var(--he-t-wordmark);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--he-ink);
  margin: 0;
  line-height: .95;
}
.he-wordmark span { color: var(--he-gold); display: block; }
.he-tagline { color: var(--he-ink-3); font-size: var(--he-t-meta); margin-bottom: var(--he-gap-5); }

.he-playmoney {
  display: inline-flex;
  align-items: center;
  gap: var(--he-gap-2);
  padding: var(--he-gap-2) var(--he-gap-4);
  border: 1px solid var(--he-gold-deep);
  border-radius: 999px;
  background: var(--he-gold-soft);
  color: var(--he-gold);
  font-family: var(--he-font-print);
  font-size: var(--he-t-meta);
  letter-spacing: .1em;
  text-transform: uppercase;
}

#navn-form {
  display: flex;
  flex-direction: column;
  gap: var(--he-gap-3);
  width: 100%;
  max-width: 22rem;
  margin: var(--he-gap-5) 0;
}
#navn-felt {
  /* 16 px minimum: anything smaller makes iOS zoom on focus (house rule) */
  font-size: var(--he-t-body);
  font-family: var(--he-font-ui);
  min-height: var(--he-tap);
  padding: 0 var(--he-gap-4);
  border: 1px solid var(--he-line);
  border-radius: var(--he-r-md);
  background: var(--he-surface);
  color: var(--he-ink);
  text-align: center;
}
#navn-felt::placeholder { color: var(--he-ink-3); }
#navn-felt[aria-invalid='true'] { border-width: 2px; border-color: var(--he-red-light); }
#navn-fejl { color: var(--he-red-light); font-size: var(--he-t-meta); min-height: 1.25rem; }
.he-bankroll { color: var(--he-ink-2); font-size: var(--he-t-meta); }
.he-bankroll strong { color: var(--he-win); font-family: var(--he-font-print); font-size: var(--he-t-money); }

#lyd-invitation { display: flex; gap: var(--he-gap-2); justify-content: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------- the table */
#skaerm-bord { padding: 0; }

#bord-omrade {
  position: relative;
  /* NOT flex: 1 1 auto. The height is set from JS and is the single number the WebGL
     camera, the canvas and the DOM field layer are all projected into; letting flex stretch
     it made the canvas taller than the projection, so every button sat one lane above the
     print it belongs to (ZT-269, Judge Stripez runde 3, fund 1). */
  flex: 0 0 auto;
  /* Spare space goes ABOVE the table - pit over the back wall - never under the rail. */
  margin-top: auto;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(70% 50% at 50% 30%, rgba(23, 96, 74, .18), transparent 70%),
    var(--he-pit);
  touch-action: none;
}

#lerred {
  position: absolute;
  left: 0;
  top: 0;
  /* No 100%/100%: the renderer sets an explicit pixel size, so the canvas is exactly the
     box the DOM layer was projected into. A stretched canvas is a misaligned table. */
  display: block;
}

/* The matrix3d layer: field buttons and the glow, glued to the felt corners. */
#dom-lag {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}
#dom-lag > * { position: absolute; }

/* The overlay: chips, puck, payout pills and calls, upright so the text stays readable. */
#overlay-lag {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#overlay-lag > * { position: absolute; }

/* ---------------------------------------------------------------- .he-field */
.he-field {
  /* The print is in the felt texture underneath; only the STATE draws anything. */
  background: transparent;
  border: 0;
  border-radius: var(--he-r-print);
  padding: 0;
  margin: 0;
  appearance: none;
}
.he-field.is-disc { border-radius: 50%; }
.he-field.is-open { box-shadow: inset 0 0 0 1px rgba(243, 234, 215, .22); }
.he-field.is-closed {
  background: var(--he-lose);
  opacity: .22;
  box-shadow: none;
  cursor: not-allowed;
}
.he-field.is-rolled { animation: he-rolled var(--he-t-base) var(--he-ease-out); }
@keyframes he-rolled {
  0% { box-shadow: inset 0 0 0 1px rgba(243, 234, 215, 0); }
  40% { box-shadow: inset 0 0 0 1px rgba(243, 234, 215, .9); }
  100% { box-shadow: inset 0 0 0 1px rgba(243, 234, 215, .3); }
}
.he-field.first-hint { animation: he-rolled 1s var(--he-ease-out); }

/* The glow: the single most important visual element on the page. Three layers. */
.he-glow {
  pointer-events: none;
  border-radius: var(--he-r-print);
  opacity: 0;
  background: radial-gradient(closest-side, var(--he-win-soft), transparent 78%);
  box-shadow:
    0 0 0 2px var(--he-win),
    0 0 14px 2px var(--he-win-soft),
    inset 0 0 22px 4px var(--he-win-soft);
}
.he-glow.is-disc { border-radius: 50%; }
.he-glow.is-on { animation: he-glow-ramp 1700ms var(--he-ease-out) forwards; }
@keyframes he-glow-ramp {
  0% { opacity: 0; }
  14% { opacity: 1; }      /* 160-400 ms: ramp up */
  76% { opacity: 1; }      /* holds for 900 ms */
  100% { opacity: 0; }     /* falls over 400 ms */
}

/* ---------------------------------------------------------------- stacks and chips */
.he-stack {
  pointer-events: none;
  transform-origin: 50% 100%;
}
.he-chip {
  position: absolute;
  left: 50%;
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .55), 0 2px 5px rgba(0, 0, 0, .45);
  border: 2px solid var(--he-print);
  display: grid;
  place-items: center;
  font-family: var(--he-font-print);
  font-weight: 700;
  letter-spacing: 0;
}
.he-chip::after {
  /* Three edge marks, so a chip is legible without its colour. */
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, .55);
  opacity: .8;
}
.he-chip--1 { background: var(--he-chip-1); color: var(--he-ink-dark); }
.he-chip--5 { background: var(--he-chip-5); color: var(--he-print); }
.he-chip--25 { background: var(--he-chip-25); color: var(--he-print); }
.he-chip--100 { background: var(--he-chip-100); color: var(--he-print); }
.he-chip--500 { background: var(--he-chip-500); color: var(--he-print); }
.he-chip--1000 { background: var(--he-chip-1000); color: var(--he-ink-dark); }
.he-chip--shadow::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 112%;
  height: 26%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(0, 0, 0, .45);
  filter: blur(3px);
  z-index: -1;
}
.he-count, .he-lammer {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 5px;
  border-radius: var(--he-r-sm);
  background: var(--he-print);
  color: var(--he-ink-dark);
  font-family: var(--he-font-print);
  font-size: var(--he-t-meta);
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
}
.he-lammer { background: var(--he-gold); }
.he-stack.is-paid { animation: he-chip-in var(--he-t-slow) var(--he-ease-out); }
.he-stack.is-swept { animation: he-sweep 260ms var(--he-ease-in) forwards; }
@keyframes he-chip-in {
  0% { transform: translate(-30px, -18px) scale(.9); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
@keyframes he-sweep {
  0% { transform: none; opacity: 1; }
  100% { transform: translate(14px, -26px) scale(.8); opacity: 0; }
}

/* ---------------------------------------------------------------- puck and pills */
.he-puck {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 3px solid var(--he-chrome);
  display: grid;
  place-items: center;
  font-family: var(--he-font-print);
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .08em;
  color: var(--he-print);
  background: var(--he-chip-100);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .6);
  transition: left var(--he-t-slow) var(--he-ease-out), top var(--he-t-slow) var(--he-ease-out);
  pointer-events: none;
}
.he-puck.is-on { background: var(--he-chip-25); }

.he-payout {
  padding: 4px 10px;
  border: 1px solid var(--he-win);
  border-radius: 999px;
  background: rgba(10, 11, 12, .9);
  box-shadow: 0 0 14px 2px var(--he-win-soft);
  color: var(--he-win);
  font-family: var(--he-font-print);
  font-weight: 700;
  font-size: 1rem;
  z-index: 3;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  animation: he-pop var(--he-t-fast) var(--he-ease-pop);
}
@keyframes he-pop {
  0% { transform: translate(-50%, -50%) scale(.6); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.he-payout--more { border-color: var(--he-gold-deep); }

/* ---------------------------------------------------------------- calls and hand */
.he-call {
  left: 50%;
  top: var(--he-gap-3);
  transform: translateX(-50%);
  text-align: center;
  font-family: var(--he-font-print);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--he-print);
  /* A real band, not just a shadow: in 2D the call sits straight on the printed layout,
     and DESIGN.md 5.5 asks for something it can be read over. */
  padding: 2px var(--he-gap-3);
  border-radius: var(--he-r-sm);
  background: rgba(7, 12, 10, .72);
  text-shadow: 0 2px 6px rgba(0, 0, 0, .95);
  pointer-events: none;
  max-width: 94%;
}
.he-call .he-call-2 { font-size: 60%; opacity: .9; display: block; }
.he-call.is-epic { font-size: 44px; }
.he-call.is-in { animation: he-fade-in 120ms var(--he-ease-out); }
@keyframes he-fade-in { from { opacity: 0; } to { opacity: 1; } }

.he-noroll {
  left: 50%;
  top: 34%;
  transform: translateX(-50%);
  padding: var(--he-gap-2) var(--he-gap-4);
  background: var(--he-print-red);
  color: var(--he-print);
  font-family: var(--he-font-print);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-radius: var(--he-r-sm);
  animation: he-blink 400ms steps(1) 2;
}
@keyframes he-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .15; } }

.he-hand {
  right: var(--he-gap-3);
  bottom: calc(var(--he-gap-3) + 1.3rem);
  padding: var(--he-gap-1) var(--he-gap-2);
  border-radius: var(--he-r-sm);
  font-family: var(--he-font-print);
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--he-print);
  background: rgba(10, 11, 12, .6);
  transition: box-shadow var(--he-t-slow) var(--he-ease-out);
}
.he-hand[data-streak='1'] { box-shadow: 0 0 6px 1px var(--he-win-soft); }
.he-hand[data-streak='2'] { box-shadow: 0 0 10px 2px var(--he-win-soft); }
.he-hand[data-streak='3'] { box-shadow: 0 0 14px 3px var(--he-win-soft); }
.he-hand[data-streak='4'] { box-shadow: 0 0 18px 4px var(--he-win-soft); color: var(--he-win); }

#bane {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#bord-omrade.is-epic { animation: he-shake 240ms linear; }
@keyframes he-shake {
  0%, 100% { transform: none; }
  20% { transform: translate(6px, -3px); }
  45% { transform: translate(-5px, 4px); }
  70% { transform: translate(3px, 2px); }
}
#bord-omrade.is-lit::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(60% 50% at 50% 45%, var(--he-win-soft), transparent 70%);
  animation: he-lift 600ms var(--he-ease-out);
}
@keyframes he-lift { from { opacity: 0; } 50% { opacity: 1; } to { opacity: 0; } }

.he-spark {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--he-win);
  pointer-events: none;
  animation: he-spark 700ms var(--he-ease-out) forwards;
}
@keyframes he-spark {
  from { transform: none; opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; }
}

/* ---------------------------------------------------------------- rail */
.he-rail {
  flex: 0 0 auto;
  /* Stuck to the bottom of the viewport: on a short phone the page scrolls, and ROLL,
     TAG NED and PROPS must stay on screen whatever happens. DESIGN.md 5.6 is categorical
     about ROLL, and TAG NED/PROPS are the ONLY way to take a bet down or bet a prop. */
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: linear-gradient(180deg, #4a2a20, var(--he-leather));
  border-top: 2px solid var(--he-gold-deep);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, .45);
  padding: var(--he-gap-1) var(--he-gap-2) calc(var(--he-gap-1) + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: var(--he-gap-1);
}
.he-rail-row {
  display: flex;
  align-items: center;
  gap: var(--he-gap-2);
  flex-wrap: wrap;
}
.he-rail-row--top { flex-wrap: nowrap; gap: var(--he-gap-1); }
/* NEVER two rows. DESIGN.md 3 budgets 6 chips on one line down to 320 px, and a second
   row costs 54 px of table (ZT-269, Judge Stripez runde 2, fund 1). The chips shrink to
   the 44 px minimum before the row is ever allowed to break. */
.he-rail-row--chips {
  flex-wrap: nowrap;
  gap: 4px;
  justify-content: center;
}
/* A deliberate grid rather than a ragged wrap: mode + odds on one line, the three actions
   on the next. On desktop there is room for all five side by side. */
.he-rail-row--handling {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas: 'mode mode odds' 'tagned props roll';
  gap: var(--he-gap-1);
}
.he-rail-row--handling #indsats-mode { grid-area: mode; }
.he-rail-row--handling #knap-odds { grid-area: odds; }
.he-rail-row--handling #knap-tagned { grid-area: tagned; }
.he-rail-row--handling #knap-props { grid-area: props; }
.he-rail-row--handling #knap-rul { grid-area: roll; }
.he-rail-row--handling .he-btn { padding: 0 var(--he-gap-3); }
.he-mode button { min-width: 0; flex: 1 1 0; padding: 0 var(--he-gap-2); }
.he-mode { flex: 1 1 auto; }

.he-denom {
  width: var(--he-denom, 48px);
  height: var(--he-denom, 48px);
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid var(--he-print);
  display: grid;
  place-items: center;
  font-family: var(--he-font-print);
  font-weight: 700;
  font-size: .8125rem;
  padding: 0;
  position: relative;
  transition: transform var(--he-t-tick) var(--he-ease-out), filter var(--he-t-tick) linear;
}
.he-denom::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, .5);
}
.he-denom[aria-pressed='true'] { transform: translateY(-6px) scale(1.06); box-shadow: 0 0 0 2px var(--he-gold); }
.he-denom:disabled { filter: grayscale(.7) brightness(.6); cursor: not-allowed; }

.he-saldo {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 auto 0 0;
  font-family: var(--he-font-print);
  font-size: var(--he-t-money);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--he-win);
  line-height: 1.05;
}
.he-saldo small {
  display: block;
  font-size: var(--he-t-meta);
  font-weight: 500;
  color: var(--he-ink-3);
  letter-spacing: .08em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The exposure meter lives UNDER the balance instead of beside it, so the four round
   buttons keep their 44 px on a 320 px rail. */
.he-maaler {
  display: block;
  width: min(100%, 9rem);
  height: 5px;
  margin-top: 3px;
  border-radius: 3px;
  background: rgba(0, 0, 0, .45);
  overflow: hidden;
}
/* The width starts at 0 here, not in a style attribute: the CSP has no 'unsafe-inline'. */
.he-maaler i { display: block; width: 0; height: 100%; background: var(--he-ink-3); transition: width var(--he-t-slow) var(--he-ease-out); }
.he-maaler.is-high i { background: var(--he-gold); }

.he-mode {
  display: inline-flex;
  border: 1px solid var(--he-gold-deep);
  border-radius: var(--he-r-md);
  overflow: hidden;
}
.he-mode button {
  min-width: 72px;
  min-height: var(--he-tap-min);
  border: 0;
  background: transparent;
  color: var(--he-ink-2);
  font-family: var(--he-font-print);
  font-size: var(--he-t-meta);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.he-mode button[aria-pressed='true'] { background: var(--he-gold-soft); color: var(--he-gold); }

#rail-besked {
  position: absolute;
  left: var(--he-gap-2);
  right: var(--he-gap-2);
  bottom: var(--he-gap-4);
  margin: 0;
  z-index: 4;
  font-size: var(--he-t-meta);
  line-height: 1.3;
  color: var(--he-ink-2);
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .95), 0 0 10px rgba(0, 0, 0, .8);
  pointer-events: none;
}
#rail-besked.is-error { color: var(--he-red-on-felt); }
#rail-besked:empty { display: none; }

#knap-rul { min-width: 108px; }

/* ---------------------------------------------------------------- sheets and panels */
.he-sheet {
  position: fixed;
  /* Above the rail, never over it: --he-rail-h is measured and set by app.js on layout. */
  inset: auto 0 var(--he-rail-h, 0px) 0;
  z-index: 40;
  max-height: 62vh;
  overflow-y: auto;
  background: var(--he-felt);
  border-top: 2px solid var(--he-gold-deep);
  border-radius: var(--he-r-lg) var(--he-r-lg) 0 0;
  padding: var(--he-gap-4) var(--he-gap-3) calc(var(--he-gap-5) + env(safe-area-inset-bottom, 0px));
  transform: translateY(0);
  transition: transform var(--he-t-base) var(--he-ease-out);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .6);
}
.he-sheet h2 { font-family: var(--he-font-print); letter-spacing: .08em; text-transform: uppercase; color: var(--he-print); }
.he-sheet-luk { position: absolute; top: var(--he-gap-2); right: var(--he-gap-2); }

#props-ark .props-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--he-gap-2); }
#props-ark .props-grid .span-2 { grid-column: span 2; }
.he-prop {
  min-height: 64px;
  border: 1px solid var(--he-print-gold);
  border-radius: var(--he-r-sm);
  background: rgba(7, 35, 24, .5);
  color: var(--he-print);
  font-family: var(--he-font-print);
  letter-spacing: .06em;
  text-transform: uppercase;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: var(--he-gap-1);
  font-size: var(--he-t-print);
}
.he-prop .pays { color: var(--he-print-gold); font-size: var(--he-t-meta); }
.he-prop .gevinst {
  color: var(--he-win);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: var(--he-t-meta);
}
.he-prop .staked { color: var(--he-win); font-variant-numeric: tabular-nums; }
.he-prop.is-win { box-shadow: 0 0 0 2px var(--he-win), 0 0 12px 2px var(--he-win-soft); }
.he-prop.span-2 { min-height: 48px; }

.he-panel {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--he-surface);
  overflow-y: auto;
  padding: var(--he-gap-4) var(--he-gap-4) var(--he-gap-6);
}
.he-panel header {
  position: sticky;
  top: calc(var(--he-gap-4) * -1);
  display: flex;
  align-items: center;
  gap: var(--he-gap-3);
  padding: var(--he-gap-3) 0;
  margin: calc(var(--he-gap-4) * -1) 0 var(--he-gap-3);
  background: var(--he-surface);
  border-bottom: 1px solid var(--he-line);
  z-index: 2;
}
.he-panel header h1 { margin: 0; margin-right: auto; }

.he-tabs { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--he-gap-2); margin-bottom: var(--he-gap-4); }
.he-tabs button {
  min-height: var(--he-tap);
  border: 1px solid var(--he-line);
  border-radius: var(--he-r-md);
  background: var(--he-surface-2);
  color: var(--he-ink-2);
  font-size: var(--he-t-meta);
}
.he-tabs button[aria-selected='true'] { background: var(--he-gold-soft); border-color: var(--he-gold-deep); color: var(--he-gold); }

table.he-table { width: 100%; border-collapse: collapse; font-size: var(--he-t-meta); }
table.he-table th, table.he-table td { padding: var(--he-gap-2) var(--he-gap-1); text-align: right; }
table.he-table th:nth-child(2), table.he-table td:nth-child(2) { text-align: left; }
table.he-table thead th { position: sticky; top: 3.5rem; background: var(--he-surface); color: var(--he-ink-3); z-index: 1; }
table.he-table tbody tr:nth-child(even) { background: var(--he-surface-2); }
table.he-table td { font-variant-numeric: tabular-nums; }
table.he-table .navn { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.he-table tr.is-me { outline: 1px solid var(--he-gold); color: var(--he-ink); }

.he-empty { color: var(--he-ink-3); padding: var(--he-gap-5) 0; text-align: center; }

.he-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: var(--he-gap-3); }
.he-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--he-gap-1);
  padding: var(--he-gap-3);
  border: 1px solid var(--he-line);
  border-radius: var(--he-r-md);
  background: var(--he-surface-2);
  text-align: center;
  font-size: var(--he-t-meta);
}
.he-badge svg { width: 54px; height: 54px; }
.he-badge:not(.is-earned) { opacity: .45; }
.he-badge:not(.is-earned) svg { filter: grayscale(1); }
.he-badge b { color: var(--he-ink); font-family: var(--he-font-print); letter-spacing: .06em; text-transform: uppercase; }
.he-badge span { color: var(--he-ink-3); }

#badge-ceremoni {
  position: fixed;
  left: 50%;
  top: 28%;
  z-index: 60;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--he-gap-2);
  padding: var(--he-gap-4) var(--he-gap-5);
  border: 1px solid var(--he-gold);
  border-radius: var(--he-r-lg);
  background: rgba(10, 11, 12, .92);
  pointer-events: none;
  animation: he-badge-in 1800ms var(--he-ease-out) forwards;
}
#badge-ceremoni b { color: var(--he-win); font-family: var(--he-font-print); letter-spacing: .08em; text-transform: uppercase; }
#badge-ceremoni span { color: var(--he-ink-2); font-size: var(--he-t-meta); max-width: 16rem; text-align: center; }
@keyframes he-badge-in {
  0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; }
  14% { transform: translate(-50%, -50%) scale(1.06); opacity: 1; }
  22% { transform: translate(-50%, -50%) scale(1); }
  78% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, 220%) scale(.4); opacity: 0; }
}

.he-histogram { display: flex; align-items: flex-end; gap: 3px; height: 160px; position: relative; margin: var(--he-gap-4) 0; }
.he-histogram .bar { flex: 1 1 0; background: linear-gradient(180deg, var(--he-gold), var(--he-gold-deep)); border-radius: 2px 2px 0 0; position: relative; min-height: 2px; }
.he-histogram .bar b { position: absolute; bottom: -1.3rem; left: 50%; transform: translateX(-50%); font-size: var(--he-t-meta); color: var(--he-ink-3); font-weight: 500; }
.he-histogram svg { position: absolute; inset: 0; pointer-events: none; }
.he-histogram + .he-legend { font-size: var(--he-t-meta); color: var(--he-ink-3); margin-top: var(--he-gap-5); }

.he-info dl { display: grid; grid-template-columns: auto 1fr; gap: var(--he-gap-2) var(--he-gap-4); margin: 0; }
.he-info dt { color: var(--he-ink-3); font-size: var(--he-t-meta); }
.he-info dd { margin: 0; color: var(--he-ink-2); font-size: var(--he-t-meta); }
.he-info .edge { font-family: var(--he-font-print); font-size: 1.5rem; color: var(--he-gold); font-variant-numeric: tabular-nums; }
.he-info .three { display: flex; gap: var(--he-gap-2); flex-wrap: wrap; margin-top: var(--he-gap-3); }
.he-info .three button { flex: 1 1 8rem; min-height: var(--he-tap); }

#coach-kort {
  position: fixed;
  left: var(--he-gap-3);
  right: var(--he-gap-3);
  bottom: calc(100% - 100vh + 1px);
  z-index: 30;
}
.he-coach {
  padding: var(--he-gap-2) var(--he-gap-3);
  border: 1px solid var(--he-gold-deep);
  border-radius: var(--he-r-md);
  background: rgba(20, 24, 26, .95);
  color: var(--he-ink-2);
  font-size: var(--he-t-meta);
}
.he-coach b { color: var(--he-gold); }

.he-foot {
  padding: var(--he-gap-4) var(--he-gap-4) var(--he-gap-5);
  color: var(--he-ink-3);
  font-size: var(--he-t-meta);
  text-align: center;
}
.he-foot a { color: var(--he-gold); }

.he-intro {
  position: fixed;
  left: var(--he-gap-3);
  right: var(--he-gap-3);
  bottom: var(--he-gap-5);
  z-index: 45;
  max-width: 26rem;
  margin: 0 auto;
  padding: var(--he-gap-4);
  border: 1px solid var(--he-gold-deep);
  border-radius: var(--he-r-lg);
  background: rgba(10, 11, 12, .95);
}
.he-intro h2 { font-size: var(--he-t-h2); }
.he-intro .trin { color: var(--he-gold); font-family: var(--he-font-print); font-size: var(--he-t-meta); letter-spacing: .1em; text-transform: uppercase; }
.he-intro .knapper { display: flex; gap: var(--he-gap-2); margin-top: var(--he-gap-3); }

#fallback-band {
  padding: var(--he-gap-2) var(--he-gap-3);
  background: var(--he-surface-2);
  color: var(--he-ink-2);
  font-size: var(--he-t-meta);
  text-align: center;
  border-bottom: 1px solid var(--he-line);
}

#forbindelse-band {
  padding: var(--he-gap-2) var(--he-gap-3);
  background: var(--he-surface);
  color: var(--he-ink-2);
  font-size: var(--he-t-meta);
  text-align: center;
  border-bottom: 1px solid var(--he-line);
}

/* 6 chips on ONE row down to 320 px: 6 x 44 + 5 x 4 = 284 px inside a 296 px rail. */
@media (max-width: 374px) {
  :root { --he-denom: 44px; }
  .he-rail-row--handling .he-btn { padding: 0 var(--he-gap-2); font-size: var(--he-t-meta); }
  .he-mode button { font-size: .75rem; letter-spacing: .04em; }
  .he-saldo { font-size: 1.15rem; }
}

/* ---------------------------------------------------------------- desktop */
@media (min-width: 768px) {
  #bord-kolonne { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
  .he-prop { min-height: 76px; }
  .he-rail-row--handling {
    grid-template-columns: auto auto auto auto 1fr;
    grid-template-areas: 'mode odds tagned props roll';
  }
  .he-tabs { grid-template-columns: repeat(4, 1fr); }
  .he-tabs button { min-height: var(--he-tap-min); }
  .he-btn { min-height: var(--he-tap-min); }
  .he-denom { width: 64px; height: 64px; font-size: .9375rem; }
  .he-panel { inset: 0 0 0 auto; width: min(32rem, 100%); border-left: 1px solid var(--he-line); }
  .he-call { font-size: 26px; }
}

/* The props SIDE PANEL needs 300 px of its own, and the desktop table needs ~653 px to
   keep every field on screen at 44 px. Below 1024 px there is not room for both, so the
   panel stays the overlay sheet it is on a phone - the table is never clipped to make
   space for it (DESIGN.md 5.4: "bordet skaleres, så panelet får plads"). */
@media (min-width: 1024px) {
  #skaerm-bord { flex-direction: row; align-items: stretch; }
  #props-ark.is-panel {
    position: static;
    inset: auto;
    bottom: auto;
    flex: 0 0 300px;
    max-height: none;
    border-radius: 0;
    border-top: 0;
    border-left: 2px solid var(--he-gold-deep);
    background: var(--he-felt);
    overflow-y: auto;
  }
  #props-ark.is-panel .he-sheet-luk { display: none; }
  #props-ark.is-panel .props-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------------------------------------------------------- reduced motion
   Every animation has a reduced variant. The winning field STILL glows, the dice STILL
   land on the server's numbers and the amount per field is STILL shown (DESIGN.md 6.4). */
.he-reduced .he-stack.is-paid { animation: he-fade-in var(--he-t-fast) var(--he-ease-out); }
.he-reduced .he-stack.is-swept { animation: he-fade-out var(--he-t-base) linear forwards; }
@keyframes he-fade-out { from { opacity: 1; } to { opacity: 0; } }
.he-reduced .he-payout { animation: he-fade-in var(--he-t-fast) linear; }
.he-reduced .he-puck { transition: opacity 200ms linear; }
.he-reduced #bord-omrade.is-epic { animation: none; }
.he-reduced .he-spark { display: none; }
.he-reduced #badge-ceremoni { animation: he-badge-slide 1600ms var(--he-ease-out) forwards; }
@keyframes he-badge-slide {
  0% { transform: translate(-50%, -50%) translateX(40px); opacity: 0; }
  12% { transform: translate(-50%, -50%); opacity: 1; }
  88% { opacity: 1; }
  100% { opacity: 0; }
}
.he-reduced .he-glow.is-on { animation: he-glow-step 1600ms steps(1) forwards; }
@keyframes he-glow-step {
  0% { opacity: 0; }
  12% { opacity: 1; }
  87% { opacity: 1; }
  100% { opacity: 0; }
}
.he-reduced .he-sheet { transition: none; }
.he-reduced .he-field.is-rolled { animation: none; box-shadow: inset 0 0 0 1px rgba(243, 234, 215, .5); }
.he-reduced .he-noroll { animation: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
  /* These three must survive: the glow, the badge and the amount per field are the point. */
  .he-glow.is-on { animation: he-glow-step 1600ms steps(1) forwards !important; }
  #badge-ceremoni { animation: he-badge-slide 1600ms var(--he-ease-out) forwards !important; }
  .he-payout { animation: he-fade-in var(--he-t-fast) linear !important; }
  /* No camera shake and no particles, ever. */
  #bord-omrade.is-epic { animation: none !important; }
  .he-spark { display: none !important; }
  .he-puck, .he-maaler i { transition: opacity 200ms linear !important; }
}

/* Without JavaScript there is no game, only an honest explanation. */
.he-noscript { padding: var(--he-gap-4); color: var(--he-ink-2); }

/* --------------------------------------------------- off-frame winners (ZT-269 runde 4) */
/* A pill that had to slide away from its field keeps a thin leader line pointing back at
   it, and carries the field's own name - it is no longer standing on the print. */
.he-payout.is-nudged::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--he-leder-laengde, 0);
  height: 1px;
  background: linear-gradient(90deg, var(--he-win) 0%, transparent 100%);
  transform: rotate(var(--he-leder-vinkel, 0deg));
  transform-origin: 0 50%;
  opacity: .75;
  pointer-events: none;
}
.he-payout .he-payout-felt {
  color: var(--he-print-gold);
  font-weight: 500;
  letter-spacing: .06em;
  margin-right: var(--he-gap-1);
}

/* The PROPS button lights with the amount when a winning prop is off-frame. It stacks the
   amount UNDER the label inside the same 48 px box, so the rail's width never changes. */
#knap-props { position: relative; }
#knap-props.is-win {
  flex-direction: column;
  gap: 0;
  border-color: var(--he-win);
  color: var(--he-win);
  box-shadow: 0 0 0 1px var(--he-win), 0 0 14px 2px var(--he-win-soft);
  animation: he-props-vind var(--he-t-hold) var(--he-ease-out) 2;
}
#knap-props.is-win .he-btn-tekst { font-size: var(--he-t-meta); line-height: 1.1; }
.he-props-gevinst {
  font-size: var(--he-t-meta);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--he-win);
}
.he-props-gevinst[hidden] { display: none; }
@keyframes he-props-vind {
  0%, 100% { box-shadow: 0 0 0 1px var(--he-win), 0 0 14px 2px var(--he-win-soft); }
  50% { box-shadow: 0 0 0 2px var(--he-win), 0 0 22px 6px var(--he-win-soft); }
}
@media (prefers-reduced-motion: reduce) {
  #knap-props.is-win { animation: none; }
}
