/* Trekantdomino: træ-bordet som Domino (brætspil). Skrift, filt og bjælke kommer fra Solitaire.css og kabale-kort.css */
:root {
  --bord: #6D4020;
  --bjaelke: #372417;
  --knap: #6A452B;
  --brik: #FCF7EE;
  --kul: #1E2421;
  --roed: #C63F28;
  --guld: #D69A2D;
  --kant-brik: rgba(30,36,33,.55);
  --t0: #4A4F4C; --t1: #B3261E; --t2: #1F5FA8; --t3: #1E7A3C; --t4: #7A3A9A; --t5: #B5560F;
}
html.kabale-mork {
  --bord: #402613;
  --bjaelke: #18110D;
  --knap: #4B2F1C;
  --brik: #F1E9DA;
}
body { background: var(--filt), var(--bord); color: var(--creme); font-variant-numeric: tabular-nums; }
button, select { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
#spil svg, #kk-besked svg { background: none; width: auto; height: auto; }

#kk-bar { align-items: center; }
#kk-bar select {
  font: 600 15px/1.2 Poppins, system-ui, sans-serif; min-height: 44px; min-width: 0; padding: 0 34px 0 14px; border: 1px solid rgba(252,247,238,.22); border-radius: 8px;
  background: var(--knap) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23FCF7EE' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--creme); cursor: pointer; -webkit-appearance: none; appearance: none;
}
#kk-bar select option { background: #FCF7EE; color: #1E2421; }
#kk-bar button:focus-visible, #kk-bar select:focus-visible, #knapper button:focus-visible, #valg button:focus-visible, #kk-besked button:focus-visible { outline: 3px solid var(--creme); outline-offset: 2px; }
@media (max-width: 480px) {
  #kk-bar { gap: 5px; padding: 6px; }
  #kk-bar button, #kk-bar select { flex: 1 1 auto; font-size: 14px; padding-left: 8px; padding-right: 8px; white-space: nowrap; }
  #kk-bar select { padding-right: 22px; background-position: right 7px center; }
}
@media (max-width: 360px) {
  #kk-bar { gap: 4px; padding: 6px 4px; }
  #kk-bar button, #kk-bar select { font-size: 13px; padding-left: 6px; padding-right: 6px; }
  #kk-bar select { padding-right: 18px; background-position: right 5px center; background-size: 9px 6px; }
}
#kk-bar.sk-bar.sk-taet > select { flex: 1 1 calc(33% - 6px); }

/* Spilleområdet: modstandere, bordet, status, din hånd og knapperne nederst ved tommelfingeren */
#spil { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 6px; padding: 6px 6px 8px; box-sizing: border-box; max-width: 980px; width: 100%; margin: 0 auto; }
#modst { flex: none; display: flex; gap: 6px; justify-content: center; }
.modspiller {
  flex: 0 1 200px; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 3px 10px; min-height: 40px; box-sizing: border-box;
  border-radius: 8px; background: rgba(0,0,0,.18); border: 2px solid transparent; font: 400 14px/1.3 Poppins, system-ui, sans-serif;
}
.modspiller div { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.modspiller b { font-weight: 600; font-size: 15px; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.modspiller i { font-style: normal; font-weight: 600; flex: none; }
.modspiller span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modspiller.tur { border-color: var(--creme); background: rgba(252,247,238,.1); }
.modspiller.tur div::before { content: ''; flex: none; width: 0; height: 0; border-style: solid; border-width: 5px 0 5px 8px; border-color: transparent transparent transparent var(--roed); filter: drop-shadow(0 0 1px var(--creme)); }
.modspiller.leder i::before, #mig.leder::before { content: ''; display: inline-block; margin-right: 5px; vertical-align: 1px; width: 8px; height: 8px; border-radius: 50%; background: var(--guld); box-shadow: 0 0 0 1.5px var(--creme); flex: none; }

#braet { flex: 1 1 auto; min-height: 110px; position: relative; overflow: hidden; border-radius: 10px; background: rgba(0,0,0,.12); box-shadow: inset 0 0 0 1px rgba(252,247,238,.1); }
#bord { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; touch-action: none; -webkit-user-select: none; user-select: none; }
#braet.kan-flytte #bord { cursor: grab; }
#tom { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; padding: 10px; pointer-events: none; font: 400 14px/1.4 Poppins, system-ui, sans-serif; color: var(--creme); opacity: .9; }
#flyt { position: absolute; right: 6px; top: 6px; min-height: 44px; min-width: 44px; padding: 0 10px; border-radius: 8px; border: 1px solid rgba(252,247,238,.25);
  background: rgba(0,0,0,.35); color: var(--creme); font: 600 14px/1 Poppins, system-ui, sans-serif; cursor: pointer; }
#flyt[hidden] { display: none; }

/* Brikkerne (bord og hånd): enheden er én sidelængde */
.tbrik .krop { fill: var(--brik); stroke: var(--kant-brik); stroke-width: .03; stroke-linejoin: round; }
.tbrik text { font: 700 .26px Poppins, system-ui, sans-serif; text-anchor: middle; dominant-baseline: central; }
.tbrik .n0 { fill: var(--t0); } .tbrik .n1 { fill: var(--t1); } .tbrik .n2 { fill: var(--t2); } .tbrik .n3 { fill: var(--t3); } .tbrik .n4 { fill: var(--t4); } .tbrik .n5 { fill: var(--t5); }
.tbrik .prik { fill: var(--kant-brik); }
.ny > .tbrik .krop { stroke: var(--roed); stroke-width: .07; }
.ind > .tbrik { animation: ind 260ms ease-out both; transform-box: fill-box; transform-origin: center; }
@keyframes ind { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: none; } }

/* Mulige pladser til den valgte brik */
.plads { cursor: pointer; outline: none; }
.plads .ramme { fill: rgba(252,247,238,.14); stroke: var(--creme); stroke-width: .045; stroke-dasharray: .1 .07; stroke-linejoin: round; }
.plads .tbrik { opacity: .55; }
.plads:hover .ramme, .plads:focus-visible .ramme { fill: rgba(252,247,238,.32); stroke-dasharray: none; stroke-width: .07; }
.plads.tip .ramme { stroke: var(--guld); animation: puls 900ms ease-in-out infinite alternate; }
.plads .pt { font: 700 .22px Poppins, system-ui, sans-serif; fill: var(--creme); text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: rgba(0,0,0,.55); stroke-width: .05; }
.plads.forslag .tbrik { opacity: 1; }
.plads.forslag .ramme { fill: none; stroke: var(--guld); stroke-width: .08; stroke-dasharray: none; animation: puls 900ms ease-in-out infinite alternate; }
@keyframes puls { from { stroke-opacity: .55; } to { stroke-opacity: 1; } }
.plads .hit { fill: transparent; }

/* Point der stiger op, og sekskantens guldkant */
.pop { font: 700 .3px Poppins, system-ui, sans-serif; fill: #FFE9A8; text-anchor: middle; paint-order: stroke; stroke: rgba(0,0,0,.6); stroke-width: .07; pointer-events: none;
  animation: pop 1500ms ease-out both; }
.pop.stor { font-size: .44px; fill: #FFD25E; }
@keyframes pop { 0% { opacity: 0; transform: translateY(.15px); } 15% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-.5px); } }
.sekskant { fill: rgba(255,210,94,.18); stroke: #FFD25E; stroke-width: .08; stroke-linejoin: round; pointer-events: none; animation: glimt 1600ms ease-out both; }
@keyframes glimt { 0% { opacity: 0; } 20% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }

#info { flex: none; display: flex; align-items: center; gap: 10px; min-height: 24px; font: 600 15px/1.3 Poppins, system-ui, sans-serif; }
#status { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mig { flex: none; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
#mig small { font-weight: 400; font-size: 14px; opacity: .85; }

/* Din hånd: en eller to strimler af trekanter */
#haand { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
#haand svg { display: block; overflow: visible; }
.hbrik { cursor: pointer; outline: none; }
.hbrik .hit { fill: transparent; }
.hbrik > g { transition: transform 160ms ease-out; }
.hbrik.valgt > g { transform: translateY(-.07px); }
.hbrik.valgt .krop { stroke: var(--roed); stroke-width: .08; }
.hbrik.ude .tbrik { opacity: .55; }
.hbrik.ny .krop { stroke: var(--guld); stroke-width: .07; }
.hbrik.tip .krop { stroke: var(--guld); stroke-width: .08; animation: puls 900ms ease-in-out infinite alternate; }
.hbrik:focus-visible .krop { stroke: var(--creme); stroke-width: .09; }

#knapper, #valg { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#knapper[hidden], #valg[hidden] { display: none; }
#knapper button, #valg button {
  min-height: 48px; padding: 0 8px; border-radius: 8px; cursor: pointer; font: 600 15px/1.1 Poppins, system-ui, sans-serif;
  border: 1px solid rgba(252,247,238,.22); background: var(--knap); color: var(--creme);
}
#knapper button:disabled { opacity: .45; cursor: default; }
#knapper button.maa, #valg button.primaer { background: var(--brik); color: var(--bjaelke); border-color: var(--roed); box-shadow: inset 0 -4px 0 var(--roed); }
#knapper button.blink { animation: blink 300ms ease-out 2; }
@keyframes blink { 50% { transform: scale(1.06); } }

/* Beskeden: regler og rundens resultat */
#kk-besked { width: max-content; max-width: min(calc(100vw - 24px), 460px); max-height: calc(100vh - 24px); overflow: auto; box-sizing: border-box; bottom: 8px; }
#kk-besked p { margin: 0 0 6px; font-size: 15px; }
#kk-besked p.titel { font-weight: 600; font-size: 17px; }
#kk-besked.regler p { text-align: left; }
#kk-besked .raekke { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 14px; text-align: left; }
#kk-besked .raekke .navn { flex: none; width: 4.2em; font-weight: 600; }
#kk-besked .raekke .smaa { display: flex; flex-wrap: wrap; gap: 2px; flex: 1 1 auto; min-width: 0; }
#kk-besked .raekke .smaa svg { flex: none; width: 38px !important; height: 33px !important; }
#kk-besked .raekke .sum { flex: none; margin-left: auto; white-space: nowrap; }
#kk-besked .knapper { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
#kk-besked .knapper button { margin: 0; }
#kk-besked button.primaer { background: var(--roed); color: var(--creme); }

@media (prefers-reduced-motion: reduce) {
  .ind > .tbrik, .plads.tip .ramme, .plads.forslag .ramme, .hbrik.tip .krop, #knapper button.blink, .pop, .sekskant { animation: none; }
  .pop, .sekskant { display: none; }
  .hbrik > g { transition: none; }
}
