/* ============================================================================
 * KOB — Kryds & Karat : det pompøse ydre
 * Guld, brokade, diamanter og en sal, der tager sig ud.
 * ========================================================================== */

:root {
  --gold-1: #fff9d6;
  --gold-2: #f7dc84;
  --gold-3: #d9a520;
  --gold-4: #8a5a12;
  --gold-5: #6b4606;
  --ink: #f4ecd8;
  --velvet-1: #3a1450;
  --velvet-2: #1d0a30;
  --velvet-3: #0b0514;
  --ice-1: #eaf7ff;
  --ice-2: #7fc6ee;
  --panel: linear-gradient(180deg, rgba(52,28,78,.88), rgba(20,10,34,.92));
  --font: Georgia, 'Times New Roman', 'Palatino Linotype', 'Book Antiqua', serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: #05030a; color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  scrollbar-color: var(--gold-3) #150c22;
}

.svg-defs, .defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ------------------------------------------------------------------ salen */
.hall {
  position: relative; min-height: 100vh; padding: 22px 14px 34px;
  display: grid; place-items: center;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--velvet-1) 0%, var(--velvet-2) 38%, var(--velvet-3) 72%, #04020a 100%),
    #05030a;
  overflow: hidden;
}
.brocade {
  position: absolute; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64'%3E%3Cg fill='none' stroke='%23e8c25a' stroke-width='1'%3E%3Cpath d='M32 2 L62 32 L32 62 L2 32 Z' opacity='.35'/%3E%3Cpath d='M32 16 L48 32 L32 48 L16 32 Z' opacity='.22'/%3E%3Ccircle cx='32' cy='32' r='3' opacity='.5'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 64px 64px;
  opacity: .5;
  mask-image: radial-gradient(90% 70% at 50% 40%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(90% 70% at 50% 40%, #000 30%, transparent 100%);
}

/* ----------------------------------------------------------------- rammen */
.frame {
  position: relative; width: min(1180px, 100%);
  padding: 24px clamp(14px, 2.4vw, 30px) 18px;
  border-radius: 22px;
  background: linear-gradient(158deg, #22132f 0%, #150c22 55%, #0f0718 100%);
  box-shadow:
    0 0 0 1px var(--gold-5),
    0 0 0 5px #150c22,
    0 0 0 8px var(--gold-3),
    0 0 0 9px var(--gold-5),
    0 34px 80px rgba(0,0,0,.75),
    inset 0 0 70px rgba(217,165,32,.09);
}
.stud {
  position: absolute; width: 20px; height: 20px;
  background: radial-gradient(circle at 35% 30%, #fff, var(--ice-2) 55%, #1d5f86 100%);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  box-shadow: 0 0 12px rgba(160,220,255,.7);
}
.stud::after {
  content: ''; position: absolute; inset: -6px;
  border: 2px solid var(--gold-2); border-radius: 50%;
  clip-path: none; transform: rotate(45deg);
}
.stud.tl { top: -6px; left: -6px; } .stud.tr { top: -6px; right: -6px; }
.stud.bl { bottom: -6px; left: -6px; } .stud.br { bottom: -6px; right: -6px; }

/* ------------------------------------------------------------ overskrift */
.crest { text-align: center; margin-bottom: 18px; }
.crown { width: clamp(58px, 9vw, 96px); height: auto; filter: drop-shadow(0 6px 14px rgba(0,0,0,.6)); animation: crownFloat 7s ease-in-out infinite; }
.crown.big { width: 110px; }
h1 {
  margin: .1em 0 .1em;
  font-size: clamp(2.1rem, 6.2vw, 4rem);
  letter-spacing: .16em; text-transform: uppercase; font-weight: 700;
  line-height: 1;
}
.gold-text {
  background: linear-gradient(100deg, #fff9d6 0%, #f7dc84 18%, #d9a520 38%, #8a5a12 52%, #f9ecb8 68%, #e0b43e 84%, #fff9d6 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,.45)) drop-shadow(0 0 18px rgba(232,194,90,.35));
  animation: sheen 9s linear infinite;
}
h1 .amp { color: var(--gold-2); font-style: italic; font-size: .72em; vertical-align: .06em; }
.tagline {
  margin: .5em auto .2em; max-width: 62ch;
  color: #e3d3ab; font-style: italic; font-size: clamp(.82rem, 1.6vw, 1.02rem);
  letter-spacing: .03em;
}
.flourish { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 8px; }
.flourish span { height: 1px; width: clamp(40px, 12vw, 130px); background: linear-gradient(90deg, transparent, var(--gold-2), transparent); }
.flourish svg { filter: drop-shadow(0 0 8px rgba(160,220,255,.6)); }

/* -------------------------------------------------------------- layoutet */
.sal {
  display: grid;
  grid-template-columns: minmax(200px, 260px) minmax(280px, 1fr) minmax(210px, 262px);
  gap: clamp(12px, 1.8vw, 22px);
  align-items: start;
}
@media (max-width: 940px) {
  .sal { grid-template-columns: 1fr; }
  .board-wrap { order: -1; }
}
/* Korte skærme (bærbare i 1280x720 og derunder): salen skal kunne ses
   helt uden at rulle — brættet må ikke havne under folden. */
@media (max-height: 880px) {
  .hall { padding: 10px 12px 18px; }
  .frame { padding-top: 14px; }
  .crown { width: clamp(34px, 4.4vw, 56px); }
  h1 { font-size: clamp(1.6rem, 4vw, 2.5rem); }
  .tagline { font-size: .8rem; margin: .25em auto .1em; }
  .crest { margin-bottom: 10px; }
  .flourish { margin-top: 3px; }
  .board-shell { width: min(100%, 430px); }
  .fineprint { margin-top: 10px; }
  .plate { padding: 10px 11px 12px; }
}

/* --------------------------------------------------------------- plader */
.plate {
  background: var(--panel);
  border: 1px solid rgba(217,165,32,.5);
  border-radius: 14px;
  padding: 14px 14px 16px;
  box-shadow: inset 0 0 30px rgba(0,0,0,.6), 0 0 0 4px rgba(217,165,32,.07), 0 14px 30px rgba(0,0,0,.5);
}
.plate-title {
  margin: 2px 0 12px; text-align: center;
  font-size: .7rem; letter-spacing: .26em; text-transform: uppercase;
  color: #ecc96a; font-weight: 400;
}
.plate-title::before, .plate-title::after { content: ' ◆ '; color: rgba(232,194,90,.55); font-size: .7em; }
.sub {
  margin: 16px 0 8px; font-size: .68rem; letter-spacing: .2em;
  text-transform: uppercase; color: #c9b184; font-weight: 400;
  border-bottom: 1px solid rgba(217,165,32,.22); padding-bottom: 4px;
}

/* -------------------------------------------------------- spillerkort */
.player-card {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; margin-bottom: 8px;
  border-radius: 11px; border: 1px solid rgba(217,165,32,.25);
  background: linear-gradient(180deg, rgba(0,0,0,.28), rgba(255,255,255,.03));
  transition: box-shadow .3s, border-color .3s, transform .3s;
}
.player-card.active {
  border-color: var(--gold-2);
  box-shadow: 0 0 20px rgba(232,194,90,.4), inset 0 0 16px rgba(232,194,90,.14);
  transform: translateY(-1px);
}
.player-card.winner { animation: winnerGlow 1.6s ease-in-out infinite; }
.crest-mini { width: 40px; height: 40px; flex: 0 0 40px; }
.crest-mini svg { width: 100%; height: 100%; filter: drop-shadow(0 3px 6px rgba(0,0,0,.6)); }
.crest-mini.gold svg { animation: pieceShimmer 5s ease-in-out infinite; }
.crest-mini.ice svg { animation: pieceShimmer 5s ease-in-out infinite .7s; }
.player-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.player-meta strong { font-size: .82rem; letter-spacing: .14em; color: #f6e6bd; }
.player-meta small { font-size: .68rem; color: #b8a480; font-style: italic; }
.pips { display: flex; gap: 5px; margin-top: 3px; }
.pip {
  width: 10px; height: 10px;
  background: radial-gradient(circle at 35% 30%, #fff, var(--gold-2) 60%, var(--gold-4));
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  transition: opacity .3s, transform .3s;
}
.pip.spent { opacity: .18; transform: scale(.7); }

/* ----------------------------------------------------- dommerens tavle */
.ledger { margin: 0; font-size: .8rem; }
.ledger > div {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 5px 2px; border-bottom: 1px dotted rgba(217,165,32,.18);
}
.ledger dt { color: #b8a480; }
.ledger dd { margin: 0; color: #f4e3b4; }

/* --------------------------------------------------------------- brættet */
.board-wrap { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.board-shell {
  position: relative; width: min(100%, 520px);
  padding: clamp(10px, 1.6vw, 18px);
  border-radius: 20px;
  background:
    linear-gradient(150deg, #3b2408 0%, #8a5a12 14%, #f2db96 30%, #a4700f 48%, #efd88f 62%, #6b4606 82%, #c79a25 100%);
  box-shadow:
    0 20px 50px rgba(0,0,0,.7),
    inset 0 0 0 2px rgba(255,246,204,.35),
    inset 0 0 34px rgba(0,0,0,.35);
}
.board-shell::before {
  content: ''; position: absolute; inset: -7px; border-radius: 24px;
  border: 1px solid rgba(255,246,204,.18); pointer-events: none;
}
.board {
  position: relative;
  display: grid;
  /* minmax(0, 1fr) — ikke 1fr. "1fr" betyder minmax(auto, 1fr), så et felt med
     en brik (SVG'ens iboende mål) kunne tvinge sit spor større, mens tomme
     felter faldt sammen: rækker og kolonner fik forskellige mål. */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 1vw, 12px);
  aspect-ratio: 1 / 1;
  padding: clamp(6px, 1vw, 12px);
  border-radius: 12px;
  background: linear-gradient(160deg, #100a1a, #1e1129 60%, #0b0513);
  box-shadow: inset 0 0 0 2px rgba(107,70,6,.9), inset 0 8px 26px rgba(0,0,0,.85);
}
.cell {
  position: relative; border-radius: 12px;
  min-width: 0; min-height: 0; overflow: hidden;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 28% 20%, rgba(255,255,255,.075), transparent 58%),
    linear-gradient(155deg, #2a1c38, #140b20 55%, #0c0616);
  box-shadow:
    inset 0 0 0 1px rgba(232,194,90,.26),
    inset 0 9px 18px rgba(0,0,0,.55),
    inset 0 -7px 16px rgba(255,246,204,.05);
  transition: box-shadow .28s, transform .2s, filter .28s;
}
.cell.act { cursor: pointer; }
.cell.act:hover {
  box-shadow: inset 0 0 0 1px var(--gold-2), 0 0 22px rgba(232,194,90,.5), inset 0 0 20px rgba(232,194,90,.16);
  transform: translateY(-1px);
}
.cell.legal::after {
  content: ''; position: absolute; width: 42%; height: 42%; border-radius: 50%;
  border: 2px solid rgba(255,232,154,.85);
  box-shadow: 0 0 16px rgba(255,214,110,.75), inset 0 0 12px rgba(255,232,154,.5);
  animation: targetPulse 1.25s ease-in-out infinite;
  pointer-events: none;
}
.cell.sel { box-shadow: inset 0 0 0 2px var(--gold-1), 0 0 26px rgba(255,232,154,.65); }
.cell.win { animation: cellWin 1.5s ease-in-out infinite; }
.cell.deny { animation: shake .32s ease-in-out; }

.piece {
  width: 78%; height: 78%; max-width: 100%; max-height: 100%;
  aspect-ratio: 1 / 1; display: block;
  filter: drop-shadow(0 7px 12px rgba(0,0,0,.65));
}
.piece-X { animation: pieceIn .5s cubic-bezier(.2,1.6,.35,1) both, pieceShimmer 6s ease-in-out infinite .4s; }
.piece-O { animation: pieceIn .5s cubic-bezier(.2,1.6,.35,1) both, pieceShimmer 6s ease-in-out infinite 1s; }
.piece.fly { animation: pieceShimmer 6s ease-in-out infinite; transition: transform .42s cubic-bezier(.25,1.25,.35,1); }
.piece.fly.from { transform: translate(var(--dx), var(--dy)) scale(.86); opacity: .75; }
.piece.mine-hint { animation: pieceShimmer 6s ease-in-out infinite, nudge 1.6s ease-in-out infinite; }

.winline { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }
.linkline { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.linkline line {
  stroke: #ffd873; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 1 15;
  filter: drop-shadow(0 0 7px rgba(255,214,110,.85));
  animation: linkRun 1.1s linear infinite;
}
@keyframes linkRun { to { stroke-dashoffset: -16; } }
.winline line {
  stroke: url(#g-lead); stroke-width: 10; stroke-linecap: round;
  filter: drop-shadow(0 0 12px rgba(255,224,140,.9));
}
.sparkle-layer { position: absolute; inset: 0; overflow: hidden; border-radius: 12px; pointer-events: none; z-index: 5; }

.announce {
  margin: 0; min-height: 1.5em; text-align: center;
  color: #eedfae; font-style: italic; font-size: .92rem; letter-spacing: .02em;
}
.announce .dots span { animation: dots 1.1s ease-in-out infinite; display: inline-block; }
.announce .dots span:nth-child(2) { animation-delay: .15s; } .announce .dots span:nth-child(3) { animation-delay: .3s; }

/* ------------------------------------------------------------- knapper */
.btn {
  font-family: var(--font); font-size: .72rem; letter-spacing: .09em; text-transform: uppercase;
  color: #f3e3b6; padding: .58rem .8rem; border-radius: 10px; cursor: pointer;
  background: linear-gradient(180deg, #3c2554, #1a0e29);
  border: 1px solid rgba(232,194,90,.5);
  box-shadow: inset 0 1px 0 rgba(255,246,204,.16), 0 7px 16px rgba(0,0,0,.5);
  transition: transform .14s, box-shadow .2s, filter .2s, background .2s;
}
.btn:hover { filter: brightness(1.14); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--gold-1); outline-offset: 2px; }
.btn.primary {
  background: linear-gradient(180deg, #fff3bf, #eccf6c 32%, #c8931c 62%, #8a5a12 100%);
  color: #2c1b02; font-weight: 700; border-color: #fff6cc;
  text-shadow: 0 1px 0 rgba(255,255,255,.4);
  box-shadow: 0 0 20px rgba(232,194,90,.45), inset 0 1px 0 rgba(255,255,255,.6);
}
.btn.ghost { background: rgba(0,0,0,.3); border-color: rgba(232,194,90,.3); color: #dcc9a0; }
.btn.big { padding: .85rem 1.5rem; font-size: .86rem; }
.btn.small { padding: .45rem .55rem; font-size: .64rem; flex: 1; }
.btn-row { display: flex; gap: 8px; }
.btn-row.center { justify-content: center; }

.seg { display: flex; gap: 6px; }
.seg-btn { flex: 1; padding: .45rem .3rem; font-size: .64rem; }
.seg-btn.is-on, .seg-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, #f7dc84, #c8931c 60%, #8a5a12);
  color: #2c1b02; font-weight: 700; border-color: #fff6cc;
  box-shadow: 0 0 16px rgba(232,194,90,.4);
}

.switch, .slider { display: flex; align-items: center; gap: 8px; font-size: .74rem; color: #e0cfa6; margin: 6px 0; }
.switch input { accent-color: var(--gold-3); width: 16px; height: 16px; }
.slider { flex-direction: column; align-items: stretch; gap: 2px; }
.slider span { color: #c9b184; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; }
.slider input { accent-color: var(--gold-3); width: 100%; }
.hint { font-size: .68rem; color: #b8a480; font-style: italic; margin: 8px 0 0; }

.fineprint {
  margin-top: 16px; padding-top: 10px; border-top: 1px solid rgba(217,165,32,.2);
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  font-size: .68rem; color: #a89572; letter-spacing: .08em; text-transform: uppercase;
}

/* ------------------------------------------------------------ forhæng */
.veil {
  position: fixed; inset: 0; z-index: 60; padding: 20px;
  display: grid; place-items: center;
  background: radial-gradient(70% 60% at 50% 40%, rgba(35,12,58,.9), rgba(4,2,9,.96));
  backdrop-filter: blur(7px);
}
.veil[hidden] { display: none; }
/* Dommen dæmper salen, men brættet skal kunne beundres bag den. */
#verdict {
  place-items: end center; padding-bottom: clamp(14px, 6vh, 70px);
  background: radial-gradient(75% 65% at 50% 10%, rgba(24,9,40,.12), rgba(4,2,9,.62));
  backdrop-filter: none;
}
#verdict .verdict-card {
  width: min(560px, 100%); animation: veilIn .4s ease-out both;
  padding: 16px clamp(14px, 2.4vw, 26px) 18px;
}
#verdict h2 { margin: .05em 0 .15em; font-size: clamp(1.3rem, 3.4vw, 2rem); }
#verdict p { margin: .1em 0 .8em; font-size: .84rem; }
/* På korte skærme bliver dommen en slank tavle, så hele brættet kan ses. */
@media (max-height: 880px) {
  #verdict .verdict-gems { display: none; }
  #verdict .verdict-card { padding: 12px 16px 14px; }
  #verdict h2 { font-size: clamp(1.1rem, 2.6vw, 1.6rem); }
  #verdict p { font-size: .78rem; margin: .05em 0 .5em; }
}
.gate-card, .verdict-card, .scroll-card {
  position: relative; width: min(680px, 100%); padding: 26px clamp(16px, 3vw, 34px) 24px;
  border-radius: 18px; text-align: center;
  background: linear-gradient(165deg, #241334, #140b21 60%, #0d0716);
  box-shadow: 0 0 0 1px var(--gold-5), 0 0 0 5px #150c22, 0 0 0 7px var(--gold-3),
    0 0 0 8px var(--gold-5), 0 30px 70px rgba(0,0,0,.75), inset 0 0 60px rgba(217,165,32,.1);
  animation: veilIn .45s ease-out both;
}
.gate-card h2, .verdict-card h2, .scroll-card h2 {
  margin: .3em 0 .4em; font-size: clamp(1.5rem, 4.4vw, 2.4rem);
  letter-spacing: .16em; text-transform: uppercase;
}
.gate-card p, .verdict-card p { color: #e0cfa6; font-style: italic; margin: .2em 0 1.1em; }
.gate-card .btn { margin: 0 5px 10px; }
.gate-rules, .scroll-card ol { text-align: left; color: #dfcfa8; font-size: .84rem; line-height: 1.55; }
.gate-rules { margin: 14px auto 0; padding-left: 1.1em; max-width: 54ch; }
.gate-rules li, .scroll-card li { margin-bottom: 6px; }
.gate-rules li::marker, .scroll-card li::marker { color: var(--gold-2); }
.scroll-card strong { color: #f7e3ae; }
.verdict-gems { display: flex; justify-content: center; gap: 14px; }
.verdict-gems svg { width: 46px; height: 46px; animation: crownFloat 3.4s ease-in-out infinite; filter: drop-shadow(0 0 12px rgba(255,224,140,.7)); }
.verdict-gems svg:nth-child(2) { animation-delay: .3s; }
.verdict-gems svg:nth-child(3) { animation-delay: .6s; }
.scroll-card { text-align: left; }
.scroll-card h2 { text-align: center; }
.scroll-card .btn { display: block; margin: 18px auto 0; }

/* ------------------------------------------------------------- konfetti */
.gem {
  position: fixed; top: 0; left: 0; width: var(--size); height: var(--size);
  pointer-events: none; z-index: 70;
  animation: gemFall var(--dur) cubic-bezier(.3,.1,.7,1) var(--delay) both;
}
.sparkle {
  position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  background: radial-gradient(circle, #fff 0%, #ffe07a 45%, rgba(255,224,122,0) 70%);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  animation: sparkleOut .75s ease-out forwards;
}

/* ------------------------------------------------------------ animationer */
@keyframes sheen { 0% { background-position: 0% 50%; } 100% { background-position: 220% 50%; } }
@keyframes crownFloat { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-6px) rotate(1deg); } }
@keyframes pieceIn {
  0% { transform: scale(.2) rotate(-40deg); opacity: 0; }
  60% { transform: scale(1.14) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes pieceShimmer { 0%,88%,100% { filter: drop-shadow(0 7px 12px rgba(0,0,0,.65)) brightness(1); } 92% { filter: drop-shadow(0 0 16px rgba(255,236,170,.95)) brightness(1.35); } }
@keyframes targetPulse { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.22); opacity: .55; } }
@keyframes cellWin { 0%,100% { box-shadow: inset 0 0 0 2px var(--gold-1), 0 0 22px rgba(255,224,140,.6); } 50% { box-shadow: inset 0 0 0 2px #fff, 0 0 40px rgba(255,232,154,.95); } }
@keyframes winnerGlow { 0%,100% { box-shadow: 0 0 16px rgba(232,194,90,.35); } 50% { box-shadow: 0 0 34px rgba(255,224,140,.8); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes nudge { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-4px) scale(1.04); } }
@keyframes sparkleOut { 0% { transform: translate(0,0) scale(.3) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(1.5) rotate(140deg); opacity: 0; } }
@keyframes gemFall {
  0% { transform: translate(var(--x), -8vh) rotate(0) scale(var(--scale)); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translate(calc(var(--x) + var(--dx)), 108vh) rotate(var(--rot)) scale(var(--scale)); opacity: .1; }
}
@keyframes veilIn { from { transform: translateY(18px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes dots { 0%,100% { opacity: .25; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .05s !important; }
}
