/* Chicken Checkers - halm, traeaeg og hoens. Telefonen foerst. */

:root {
  --bg: #f4e6c3;
  --card: #fffaf0;
  --ink: #3b2a1a;
  --muted: #7a6650;
  --line: #e2cfa0;
  --primary: #5a3d22;
  --primary-ink: #fff8ea;
  --red: #d9483a;
  --green: #45a852;
  --cell-a: #f2dfac;
  --cell-b: #ead196;
  --frame: #b88a4a;
  --gold: #e9b52c;
  color-scheme: light;
}

* { box-sizing: border-box; }

/* hidden skal vinde over display: flex/grid laengere nede. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px 32px;
}

h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 .6em; }
.small { font-size: .85rem; color: var(--muted); }
.loading { text-align: center; margin-top: 30vh; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}

.stack { display: grid; gap: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 0; }

button, .button {
  font: inherit;
  font-weight: 600;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid var(--primary);
  background: var(--card);
  color: var(--primary);
  cursor: pointer;
  touch-action: manipulation;
}
button.primary { background: var(--primary); color: var(--primary-ink); }
button.danger { border-color: #a33; color: #a33; }
button:disabled { opacity: .45; cursor: default; }
button.link { border: 0; background: none; min-height: 0; padding: 4px; text-decoration: underline; font-weight: 500; }

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
label { display: block; font-weight: 600; margin-bottom: 10px; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--gold); outline-offset: 1px; }

/* ---------- Forside ---------- */

.hero { text-align: center; padding: 18px 0 8px; }
.hero .hen { font-size: 4rem; line-height: 1; }
.code-input { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-size: 1.4rem; font-weight: 700; }
.code-input::placeholder { color: #d6c49a; font-weight: 500; }
.error { color: #a33; font-weight: 600; }

/* ---------- Lobby ---------- */

.room-code { font-size: 2.6rem; font-weight: 800; letter-spacing: .25em; text-align: center; margin: 4px 0 10px; }
.seats { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.seats li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: #fff; border: 1px solid var(--line); }
.seats .tag { margin-left: auto; font-size: .8rem; color: var(--muted); }
.dot { width: 18px; height: 18px; border-radius: 50%; flex: none; background: var(--pc); }
.offline { opacity: .5; }
.settings-view dt { font-weight: 600; }
.settings-view dd { margin: 0 0 8px; color: var(--muted); }

/* ---------- Moenterne ---------- */

/* Moenten har spillerens farve. Jokerne har en tyk roed eller groen ring med
   en hvid streg indenfor, saa ringen ikke flyder sammen med den orange. */
.coin {
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  background: var(--pc);
  border: .1em solid rgba(0, 0, 0, .28);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .45);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  transform: rotate(var(--rot, 0deg)) scale(var(--scale, 1));
  transition: transform .15s;
}
.coin.r1, .coin.r2 { border-width: .22em; background: radial-gradient(closest-side, var(--pc) 84%, #fff 87%); }
.coin.r1 { border-color: var(--green); }
.coin.r2 { border-color: var(--red); }
.diamond .coin { --rot: 45deg; }
/* Maerket for undersiden staar under moenten. Paa diamanten peger det ud i
   feltets hjoerne, hvor der er plads - ikke ind over nabofeltet. */
.coin .under {
  position: absolute;
  left: 50%;
  bottom: -34%;
  transform: translateX(-50%);
  font-size: .72em;
  line-height: 1;
  filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff);
}
.coin.dead { opacity: .35; filter: grayscale(.6); }

/* ---------- Opstilling ---------- */

.brushes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.brushes button { display: flex; align-items: center; gap: 8px; text-align: left; font-size: .95rem; padding: 8px 10px; border-color: var(--line); }
.brushes button.on { border-color: var(--primary); background: #fff3d6; box-shadow: inset 0 0 0 1px var(--primary); }
.brushes .count { margin-left: auto; font-size: .8rem; color: var(--muted); font-weight: 600; }
.brushes .count.done { color: var(--green); }

.setup-diamond { max-width: 300px; margin: 0 auto 4px; }
.block .slot:disabled { opacity: 1; }

.ready-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.ready-list li { display: flex; gap: 8px; align-items: center; }

/* ---------- Braettet ---------- */

.players { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; align-items: stretch; }
.chip {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 9px 4px 5px; border-radius: 999px;
  background: var(--card); border: 2px solid var(--line);
  font-size: .9rem; font-weight: 600;
}
.chip.turn { border-color: var(--pc); box-shadow: 0 0 0 2px var(--pc); }
.chip.out { opacity: .5; text-decoration: line-through; }
.chip .eggs { font-weight: 500; letter-spacing: -.1em; }
.chip .stolen { font-size: .8rem; color: var(--muted); }
.topbar { display: flex; gap: 8px; align-items: flex-start; }
.topbar .players { flex: 1; }
.topbar .menu-btn { flex: none; min-height: 40px; padding: 4px 12px; font-size: 1.2rem; }

/* Braettet er et kvadrat drejet 45 grader. Diamantens bredde er kvadratets
   diagonal, saa kvadratet faar 1/sqrt(2) af pladsen. */
.diamond {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.diamond > .board, .diamond > .block { width: 70.7%; transform: rotate(-45deg); }
.board { --n: 8; }
.block { --n: 3; }
.board, .block {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  aspect-ratio: 1;
  border: 4px solid var(--frame);
  border-radius: 10px;
  overflow: hidden;
  container-type: inline-size;
  background: var(--cell-a);
  user-select: none;
}
.cell {
  position: relative;
  border: 0;
  padding: 0;
  min-height: 0;
  border-radius: 0;
  background: var(--cell-a);
  font-size: calc(100cqw / var(--n) * .42);
  cursor: default;
}
.cell.alt { background: var(--cell-b); }
.cell.home { background-image: linear-gradient(var(--home), var(--home)); }
.cell.last-from::before {
  content: ""; position: absolute; inset: 30%; border-radius: 50%;
  border: 2px dashed rgba(59, 42, 26, .45);
}
.cell.target { cursor: pointer; }
.cell.target::after {
  content: ""; position: absolute; inset: 34%; border-radius: 50%;
  background: rgba(59, 42, 26, .42);
}
.cell.target.hit::after {
  inset: 2%; background: none; border: 3px dashed #b3261e; z-index: 2;
  animation: pulse 1s ease-in-out infinite alternate;
}
.cell.pick { cursor: pointer; }
.coin.movable { box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(59, 42, 26, .55); }
.coin.selected { --scale: 1.12; box-shadow: 0 0 0 2px #fff, 0 0 0 5px var(--ink); z-index: 1; }
.coin.upgradable { box-shadow: 0 0 0 2px #fff, 0 0 0 5px var(--gold); animation: pulse 1s ease-in-out infinite alternate; }
.cell.last-to .coin { animation: land .35s ease-out; }

@keyframes pulse { from { opacity: 1; } to { opacity: .55; } }
@keyframes land {
  from { transform: rotate(var(--rot, 0deg)) scale(1.35); }
  to { transform: rotate(var(--rot, 0deg)) scale(1); }
}

.legend { text-align: center; margin: 2px 0 0; }
.legend .ring {
  display: inline-block; width: 1em; height: 1em; vertical-align: -.15em;
  border-radius: 50%; border: .2em solid; background: var(--muted);
}
.legend .ring.r1 { border-color: var(--green); }
.legend .ring.r2 { border-color: var(--red); }

.panel {
  display: flex; align-items: center; gap: 12px;
  min-height: 76px; margin: 10px 0;
  padding: 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
}
.panel .grow { flex: 1; }
.panel p { margin: 0; }
.panel button.primary { flex: 1; font-size: 1.1rem; }
.die {
  width: 54px; height: 54px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px; border: 2px solid var(--ink); background: #fff;
  font-size: 1.7rem; font-weight: 800;
}

.log { list-style: none; padding: 0; margin: 0; font-size: .9rem; display: grid; gap: 3px; }
.log li { padding: 4px 8px; border-radius: 8px; }
.log li.quiet { color: var(--muted); }
.log li.big { background: var(--card); font-weight: 600; }

.results { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.results li { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.results .place { width: 2em; font-size: 1.2rem; }
.results .meta { margin-left: auto; font-weight: 500; color: var(--muted); font-size: .9rem; }

.stars { display: flex; gap: 6px; margin: 4px 0 10px; }
.stars button { flex: 1; min-height: 44px; padding: 0; font-size: 1.1rem; border-color: var(--line); }
.stars button.on { border-color: var(--primary); background: #fff3d6; }

/* ---------- Beskeder ---------- */

#toast {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: var(--primary-ink);
  font-weight: 600; text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  z-index: 10;
}
#toast.error { background: #8e2a1e; }
#offline {
  position: fixed; top: 0; left: 0; right: 0;
  padding: 8px; text-align: center; font-weight: 600;
  background: #8e2a1e; color: #fff; z-index: 11;
}

dialog {
  width: min(480px, calc(100% - 32px));
  max-height: calc(100% - 48px);
  border: 0; border-radius: 16px; padding: 18px;
  background: var(--card); color: var(--ink);
}
dialog::backdrop { background: rgba(40, 25, 10, .45); }
dialog form[method="dialog"] { margin-top: 12px; display: flex; }
dialog form[method="dialog"] button { flex: 1; }
#rules-list { padding-left: 1.2em; }
#rules-list li { margin-bottom: 8px; }

/* ---------- Effekter (se playHit i app.js) ---------- */

#fx { position: fixed; inset: 0; pointer-events: none; z-index: 9; overflow: hidden; }
.fx { position: fixed; transform: translate(-50%, -50%); line-height: 1; }
.fx-coin {
  display: grid; place-items: center;
  width: calc(var(--size) * .82); height: calc(var(--size) * .82);
  border-radius: 50%; background: var(--pc); color: #fff;
  border: calc(var(--size) * .05) solid rgba(0, 0, 0, .28);
  font-weight: 800; font-size: calc(var(--size) * .42);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .45);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.fx-coin.face { background: #fffaf0; border: calc(var(--size) * .07) solid var(--pc); font-size: calc(var(--size) * .5); text-shadow: none; }
.fx-coin.face.empty::after {
  content: ""; width: 52%; height: 52%; border-radius: 50%;
  border: calc(var(--size) * .045) dashed #b39a6c;
}
.fx-coin.sick { background: color-mix(in srgb, var(--pc) 35%, #8bc34a); border-color: #4f7f22; }
.fx-ring {
  width: var(--size); height: var(--size); border-radius: 50%;
  border: calc(var(--size) * .12) solid var(--gold); box-shadow: 0 0 18px var(--gold);
}
.fx-ring.green { border-color: var(--green); box-shadow: 0 0 18px var(--green); }
.fx-spark { font-size: calc(var(--size) * .5); }
.fx-egg { font-size: calc(var(--size) * .9); filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .35)); }
.fx-big { font-size: calc(var(--size) * 1.7); filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .35)); }
.fx-small { font-size: calc(var(--size) * .55); }
.fx-puff {
  width: var(--size); height: var(--size); border-radius: 50%;
  background: radial-gradient(circle, rgba(118, 176, 52, .85) 0, rgba(118, 176, 52, .45) 45%, rgba(118, 176, 52, 0) 70%);
}
.fx-puff.dust {
  background: radial-gradient(circle, rgba(165, 140, 100, .7) 0, rgba(165, 140, 100, .3) 45%, rgba(165, 140, 100, 0) 70%);
}
.fx-flash {
  width: var(--size); height: var(--size); border-radius: 50%;
  background: radial-gradient(circle, rgba(110, 170, 40, .5), rgba(110, 170, 40, 0) 70%);
}

/* ---------- Mailliste ---------- */

hr.split { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.signup label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: .92rem; }
.signup label.check input { width: 22px; height: 22px; flex: none; margin: 2px 0 0; accent-color: var(--primary); }

/* ---------- Feedback og braetspilsspoergsmaalet ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { min-height: 40px; padding: 6px 12px; font-size: .92rem; border-color: var(--line); }
.chips button.on { border-color: var(--primary); background: #fff3d6; box-shadow: inset 0 0 0 1px var(--primary); }
.chips button:disabled:not(.on) { opacity: .45; }
.chips button.on:disabled { opacity: 1; }
.interest .signup { margin-top: 12px; }

/* ---------- Hurtig feedback efter et spil ---------- */

.survey .chips.faces { gap: 4px; }
.survey .chips.faces button { flex: 1; font-size: 1.6rem; padding: 4px 0; min-height: 52px; }
.survey .survey-progress { display: flex; gap: 6px; margin: 0 0 8px; }
.survey .survey-progress i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--muted); }
.survey .survey-progress i.on { background: var(--muted); }
.survey textarea { min-height: 72px; }

/* ---------- Ventehumor: hoenen med talebobblen ---------- */

.hen-talk { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 14px 0 6px; }
.hen-talk-hen { font-size: 2.8rem; line-height: 1; transform-origin: 50% 90%; animation: bob 1.8s ease-in-out infinite; }
.hen-talk-bubble {
  position: relative; max-width: 70%;
  padding: 9px 14px; border-radius: 16px;
  background: #fff; border: 2px solid var(--line);
  font-weight: 700; text-align: center;
}
/* Halen paa bobblen, der peger ind mod hoenen: en kant og en hvid indermand. */
.hen-talk-bubble::before, .hen-talk-bubble::after {
  content: ""; position: absolute; top: 50%; transform: translateY(-50%);
  border: 9px solid transparent; border-left: 0;
}
.hen-talk-bubble::before { left: -10px; border-right-color: var(--line); }
.hen-talk-bubble::after { left: -7px; border-right-color: #fff; }
.hen-talk-bubble.pop { animation: pop .35s ease-out; }

@keyframes bob {
  0%, 100% { transform: rotate(-5deg) translateY(0); }
  50% { transform: rotate(5deg) translateY(-3px); }
}
@keyframes pop { from { transform: scale(.85); opacity: .3; } to { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .hen-talk-hen, .hen-talk-bubble.pop { animation: none; }
}
