/* Chicken — styles
   Warm farmhouse palette, built for a desktop browser and an iPad.
   Everything tappable is at least 44px tall. */

:root {
  --ink:        #1c1917;
  --ink-soft:   #3f3a35;
  --paper:      #f7f3ec;
  --paper-dim:  #e8e1d5;
  --card:       #fffdf9;
  --felt:       #2f4739;
  --felt-dark:  #243629;
  --barn:       #a33a2a;
  --barn-dark:  #8a2f21;
  --wheat:      #d9a227;
  --wheat-soft: #f3e2b4;
  --good:       #2f6f4e;
  --line:       rgba(28, 25, 23, .14);
  --radius:     14px;
  --shadow:     0 1px 2px rgba(28,25,23,.08), 0 6px 20px rgba(28,25,23,.09);
}

* { box-sizing: border-box; }

/* Author rules that set `display` (.btn-block, for one) would otherwise beat
   the UA stylesheet and leave hidden elements on screen. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-image:
    radial-gradient(1100px 580px at 50% -8%, #40332a 0%, transparent 70%),
    linear-gradient(180deg, #221f1c 0%, #1a1715 100%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: -webkit-fill-available;
}

.shell {
  max-width: 44rem;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2.25rem) clamp(.85rem, 3vw, 1.5rem) 3rem;
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
}

/* ----------------------------- brand ----------------------------- */

.brand { text-align: center; margin: .5rem 0 1.5rem; }

.brand h1 {
  margin: 0;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: clamp(2.6rem, 11vw, 3.9rem);
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--paper);
  text-shadow: 0 2px 0 rgba(0,0,0,.25);
}

.brand h1::after {
  content: "";
  display: block;
  width: 3.5rem;
  height: 3px;
  margin: .55rem auto 0;
  border-radius: 2px;
  background: var(--wheat);
}

.brand-sm h1 { font-size: clamp(1.7rem, 7vw, 2.2rem); }
.brand-sm h1::after { display: none; }

.tagline {
  margin: .7rem 0 0;
  color: #c6bcae;
  font-size: .98rem;
}

/* ----------------------------- cards ----------------------------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.1rem, 4vw, 1.6rem);
}

.center { text-align: center; }
.muted  { color: #7b736a; font-size: .95rem; }
.fine   { color: #7b736a; font-size: .86rem; }

.label-sm {
  margin: 1.4rem 0 .5rem;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: #8d8478;
}
.label-sm:first-child { margin-top: 0; }

/* ----------------------------- fields ---------------------------- */

.field { display: block; margin-bottom: 1rem; }

.field > span {
  display: block;
  margin-bottom: .35rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.field input {
  width: 100%;
  min-height: 48px;
  padding: .7rem .85rem;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 10px;
}

.field input:focus {
  outline: none;
  border-color: var(--barn);
  box-shadow: 0 0 0 3px rgba(163,58,42,.16);
}

.code-input {
  text-transform: uppercase;
  letter-spacing: .3em;
  font-weight: 700;
  font-size: 1.3rem !important;
  text-align: center;
}

/* ----------------------------- buttons --------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 50px;
  padding: .7rem 1.2rem;
  font: 600 1rem/1.2 inherit;
  color: var(--ink);
  background: var(--paper-dim);
  border: 1.5px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  transition: transform .06s ease, filter .12s ease, background .12s ease;
  touch-action: manipulation;
}

.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-block { display: flex; width: 100%; }
.btn-block + .btn-block { margin-top: .6rem; }

.btn-primary {
  background: var(--barn);
  color: #fff6f2;
  box-shadow: 0 2px 0 var(--barn-dark);
}
.btn-primary:hover:not(:disabled) { background: #b14234; }

.btn-go {
  background: var(--good);
  color: #f2fbf5;
  box-shadow: 0 2px 0 #245840;
}
.btn-go:hover:not(:disabled) { background: #37805a; }

.btn-bank {
  background: var(--wheat);
  color: #3a2c08;
  box-shadow: 0 2px 0 #b2831c;
}
.btn-bank:hover:not(:disabled) { background: #e5ae33; }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}
.btn-ghost:hover:not(:disabled) { background: rgba(28,25,23,.05); }

/* Ghost buttons sitting on the dark felt page rather than inside a card. */
.controls .btn-ghost {
  color: #ded6c9;
  border-color: rgba(255, 255, 255, .22);
}
.controls .btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .08); }

.btn-quiet {
  margin-top: 1rem;
  min-height: 42px;
  color: #a79c8e;
  border-color: rgba(255,255,255,.14);
  font-weight: 500;
  font-size: .9rem;
}
.btn-quiet:hover { background: rgba(255,255,255,.06); }

.btn-copy {
  min-height: 40px;
  padding: .4rem .85rem;
  font-size: .88rem;
  flex: none;
  color: var(--wheat-soft);
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .25);
}
.btn-copy:hover:not(:disabled) { background: rgba(255, 255, 255, .2); }

/* ----------------------------- divider --------------------------- */

.divider {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin: 1.4rem 0;
  color: #9b9287;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ----------------------------- room code ------------------------- */

.code-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .9rem 1rem;
  background: var(--felt);
  border-radius: 12px;
}

.code-display span {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: clamp(1.8rem, 8vw, 2.5rem);
  font-weight: 700;
  letter-spacing: .22em;
  color: var(--wheat-soft);
}

.copy-note {
  margin: .45rem 0 0;
  font-size: .85rem;
  color: var(--good);
  font-weight: 600;
}

/* ----------------------------- players --------------------------- */

.player-list { list-style: none; margin: 0; padding: 0; }

.player-list li {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem .25rem;
  border-bottom: 1px solid var(--line);
  font-weight: 500;
}
.player-list li:last-child { border-bottom: none; }

.pill {
  margin-left: auto;
  padding: .15rem .55rem;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  border-radius: 999px;
  background: var(--paper-dim);
  color: #6f675d;
}
.pill-you  { background: var(--wheat-soft); color: #6b5212; }
.pill-host { background: #e3ece5;           color: #2d5f45; }

/* ----------------------------- scoreboard ------------------------ */

.scoreboard {
  list-style: none;
  margin: 0 0 1rem;
  padding: .35rem;
  display: grid;
  gap: .3rem;
  background: rgba(255,255,255,.055);
  border-radius: 12px;
}

.scoreboard li {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .7rem;
  border-radius: 8px;
  color: #ded6c9;
  font-size: .97rem;
}

.scoreboard li.is-turn {
  background: var(--wheat);
  color: #39290a;
  font-weight: 700;
  box-shadow: 0 1px 0 #b2831c;
}

.scoreboard li .sb-name  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scoreboard li .sb-score { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; }

.sb-tag {
  font-size: .66rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: .1rem .4rem;
  border-radius: 999px;
  background: rgba(0,0,0,.18);
  color: inherit;
  opacity: .75;
}

.scoreboard-final { background: var(--paper); margin-top: 1.2rem; }
.scoreboard-final li { color: var(--ink-soft); }
.scoreboard-final li.is-winner {
  background: var(--wheat-soft);
  color: #4a3708;
  font-weight: 700;
}

/* ----------------------------- turn banner ----------------------- */

.turn-banner {
  text-align: center;
  padding: .7rem 1rem;
  margin-bottom: .75rem;
  border-radius: 10px;
  background: rgba(255,255,255,.07);
  color: var(--paper);
  font-weight: 600;
}
.turn-banner.is-mine {
  background: var(--good);
  color: #effaf2;
  box-shadow: 0 2px 0 #1f4e39;
}

.banner {
  padding: .75rem 1rem;
  margin-bottom: .75rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: .95rem;
  text-align: center;
}
.banner-warn { background: var(--wheat-soft); color: #5b4209; }
.banner-bust { background: #f6ded9;           color: #7c2718; }

/* ----------------------------- the felt -------------------------- */

.table-felt {
  background: linear-gradient(170deg, var(--felt) 0%, var(--felt-dark) 100%);
  border-radius: var(--radius);
  padding: clamp(.9rem, 3.5vw, 1.4rem);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), var(--shadow);
  min-height: 11rem;
}

.kept-strip {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .9rem;
  padding-bottom: .9rem;
  border-bottom: 1px dashed rgba(255,255,255,.16);
}
.kept-strip:empty { display: none; }

.kept-group {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .5rem .3rem .35rem;
  background: rgba(0,0,0,.22);
  border-radius: 9px;
}
.kept-group .kept-points {
  font-size: .8rem;
  font-weight: 700;
  color: var(--wheat);
  font-variant-numeric: tabular-nums;
}

.dice-area {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(.45rem, 2vw, .75rem);
  justify-content: center;
  align-items: center;
  min-height: 5.5rem;
}

.dice-hint {
  margin: .9rem 0 0;
  text-align: center;
  font-size: .89rem;
  color: #a9bfae;
  min-height: 1.3em;
}

/* ----------------------------- dice ------------------------------ */

.die {
  --size: clamp(3.1rem, 13vw, 4.1rem);
  width: var(--size);
  height: var(--size);
  /* Percentages here would resolve against the parent's width, not the die,
     so everything is derived from --size instead. */
  padding: calc(var(--size) * .14);
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  gap: calc(var(--size) * .04);
  background: linear-gradient(160deg, #fffdf8 0%, #ece4d4 100%);
  border: none;
  border-radius: 18%;
  box-shadow: 0 3px 0 #b8ab93, 0 5px 12px rgba(0,0,0,.3);
  cursor: default;
  transition: transform .09s ease, box-shadow .12s ease;
  touch-action: manipulation;
}

.die .pip {
  border-radius: 50%;
  background: #27221d;
  box-shadow: inset 0 -1px 1px rgba(255,255,255,.22);
}

/* pip placement on the 3x3 grid */
.die .p-tl { grid-area: 1 / 1; }
.die .p-tr { grid-area: 1 / 3; }
.die .p-ml { grid-area: 2 / 1; }
.die .p-c  { grid-area: 2 / 2; }
.die .p-mr { grid-area: 2 / 3; }
.die .p-bl { grid-area: 3 / 1; }
.die .p-br { grid-area: 3 / 3; }

.die-sm {
  --size: 1.9rem;
  padding: calc(var(--size) * .15);
  border-radius: 22%;
  box-shadow: 0 1px 0 #b8ab93;
}
.die-sm .pip { background: #3a332b; }

.die-pickable { cursor: pointer; }
.die-pickable:hover { transform: translateY(-2px); }

.die-selected {
  background: linear-gradient(160deg, #fdf0c8 0%, #f2dc9e 100%);
  box-shadow: 0 0 0 3px var(--wheat), 0 4px 12px rgba(0,0,0,.32);
  transform: translateY(-4px);
}

.die-dead { opacity: .42; }

/* Waiting-to-be-rolled placeholder: an empty slot, not a die showing 1. */
.die-blank {
  background: rgba(255, 255, 255, .07);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .1);
}

.die-rolling { animation: tumble .42s ease-out; }

@keyframes tumble {
  0%   { transform: translateY(-14px) rotate(-18deg) scale(.86); opacity: .35; }
  60%  { transform: translateY(2px)   rotate(6deg)   scale(1.04); opacity: 1; }
  100% { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .die-rolling { animation: none; }
  .die, .btn { transition: none; }
}

/* ----------------------------- tally ----------------------------- */

.tally {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
  margin: .9rem 0;
}

.tally > div {
  background: rgba(255,255,255,.07);
  border-radius: 10px;
  padding: .6rem .8rem;
  text-align: center;
}

.tally-label {
  display: block;
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #a79c8e;
  margin-bottom: .1rem;
}

.tally strong {
  font-size: 1.5rem;
  color: var(--wheat-soft);
  font-variant-numeric: tabular-nums;
}

/* ----------------------------- controls -------------------------- */

.controls { display: grid; gap: .6rem; }

@media (min-width: 30rem) {
  .controls.two-up { grid-template-columns: 1fr 1fr; }
}

.controls .btn { min-height: 56px; font-size: 1.05rem; }

.waiting-note {
  text-align: center;
  color: #a79c8e;
  padding: 1rem;
  font-size: .95rem;
}

/* ----------------------------- rules + log ----------------------- */

.rules-box, .log-box {
  margin-top: 1.1rem;
  background: rgba(255,255,255,.055);
  border-radius: 12px;
  overflow: hidden;
}

.rules-box summary, .log-box summary {
  padding: .85rem 1rem;
  min-height: 46px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 600;
  color: var(--paper);
  font-size: .94rem;
}
.rules-box summary::marker, .log-box summary::marker { color: var(--wheat); }

.rules-body {
  padding: 0 1rem 1.1rem;
  color: #d8d0c4;
  font-size: .92rem;
}
.rules-body p { margin: .6rem 0; }
.rules-body strong { color: var(--wheat-soft); }
.rules-body .fine { color: #a39a8d; }

.score-table {
  width: 100%;
  margin: .8rem 0;
  border-collapse: collapse;
  font-size: .9rem;
}
.score-table td {
  padding: .3rem .5rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  color: #ded6c9;
}
.score-table td:last-child {
  text-align: right;
  font-weight: 700;
  color: var(--wheat);
  font-variant-numeric: tabular-nums;
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 0 1rem 1rem;
  font-size: .88rem;
  color: #c3baad;
}
.log-list li {
  padding: .35rem 0;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.log-list li:last-child { border-bottom: none; }

/* ----------------------------- chat ----------------------------- */

.chat-panel {
  margin-top: 1.1rem;
  background: rgba(255, 255, 255, .055);
  border-radius: 12px;
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1rem;
}

.chat-title {
  margin: 0;
  font-size: .94rem;
  font-weight: 600;
  color: var(--paper);
}

.chat-unread {
  min-width: 1.4rem;
  padding: .05rem .4rem;
  border-radius: 999px;
  background: var(--barn);
  color: #fff4f1;
  font-size: .74rem;
  font-weight: 700;
  text-align: center;
}

.chat-toggle {
  margin-left: auto;
  min-height: 34px;
  padding: .25rem .7rem;
  font: 600 .82rem/1 inherit;
  color: #c3baad;
  background: transparent;
  border: 1.5px solid rgba(255, 255, 255, .2);
  border-radius: 8px;
  cursor: pointer;
}
.chat-toggle:hover { background: rgba(255, 255, 255, .08); }

.chat-body { padding: 0 .75rem .75rem; }

.chat-list {
  list-style: none;
  margin: 0 0 .6rem;
  padding: .25rem;
  max-height: 14rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.chat-list:empty { display: none; }

.chat-msg {
  max-width: 86%;
  padding: .45rem .7rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, .09);
  color: #e4ddd2;
  font-size: .92rem;
  overflow-wrap: anywhere;
}

.chat-msg .chat-who {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--wheat);
  margin-bottom: .1rem;
}

.chat-msg.is-mine {
  align-self: flex-end;
  background: var(--felt);
  color: #e9f1ea;
}
.chat-msg.is-mine .chat-who { color: #9fc4ac; }

.chat-empty {
  margin: .2rem .25rem .7rem;
  font-size: .87rem;
  color: #8f877b;
}

.chat-form { display: flex; gap: .5rem; }

.chat-form input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: .6rem .8rem;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid transparent;
  border-radius: 10px;
}
.chat-form input:focus {
  outline: none;
  border-color: var(--wheat);
  box-shadow: 0 0 0 3px rgba(217, 162, 39, .22);
}

.chat-send { min-height: 46px; flex: none; padding: .6rem 1.1rem; }

/* ----------------------------- misc ----------------------------- */

.trophy { font-size: 3rem; margin: 0 0 .3rem; }

#done-title {
  margin: 0 0 .3rem;
  font-family: ui-serif, Georgia, serif;
  font-size: 1.9rem;
  font-weight: 600;
}

.error-bar {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(92vw, 30rem);
  margin: 0;
  padding: .8rem 1rem;
  background: var(--barn);
  color: #fff4f1;
  border-radius: 10px;
  font-size: .92rem;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  z-index: 50;
}

.conn-note {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: .3rem 1rem;
  background: var(--wheat);
  color: #3a2c08;
  font-size: .8rem;
  font-weight: 700;
  border-radius: 0 0 8px 8px;
  z-index: 50;
}
