/* =========================================================================
   Alles op 1 Kaart — vormgeving
   Mobiel-eerst, donkere "spelbord bij avond" look met warm accent.
   ========================================================================= */

:root {
  --bg: #0c1a23;
  --bg-2: #10202b;
  --surface: #162b38;
  --surface-2: #1d3644;

  --line: rgba(255, 255, 255, 0.1);
  --text: #eaf3f7;
  --muted: #9fb6c2;
  --accent: #ffb43d;
  --accent-ink: #2a1a00;
  --ok: #43d6a3;

  --die-R: #e8493f;
  --die-B: #3a8ddd;
  --die-G: #4bbf5c;
  --die-Y: #f2ca3c;
  --die-O: #f08a2c;
  --die-P: #9b6bd8;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100dvh;
  background: radial-gradient(120% 80% at 50% 0%, var(--bg-2) 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3 {
  margin: 0 0 0.4em;
  letter-spacing: 0.01em;
}

p {
  margin: 0 0 0.8em;
  line-height: 1.5;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ------------------------------ topbar --------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(12, 26, 35, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  margin: 0;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.brand span {
  color: var(--accent);
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.92);
}

/* ------------------------------ screens -------------------------------- */

.screen {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 14px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.field {
  display: block;
  margin: 14px 0;
}

.field > span {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 8px;
}

.segmented {
  display: flex;
  gap: 6px;
}

.segmented button {
  flex: 1;
  padding: 10px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.segmented button.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.setup-players {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.setup-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setup-row input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
}

.setup-row .cpu-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.primary-btn,
.ghost-btn {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.primary-btn {
  background: linear-gradient(180deg, #ffc662, var(--accent));
  color: var(--accent-ink);
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.primary-btn:active,
.ghost-btn:active {
  transform: scale(0.98);
}

.primary-btn:disabled,
.ghost-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

.scoreboard {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.scoreboard::-webkit-scrollbar {
  display: none;
}

.pill {
  flex: 1 0 auto;
  min-width: 92px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
}

.pill.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.pill .name {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill .score {
  font-size: 1.25rem;
  font-weight: 800;
}

.pill .meta {
  font-size: 0.7rem;
  color: var(--muted);
}

/* ------------------------------- stage --------------------------------- */

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
  min-height: 1.4em;
}

.status strong {
  color: var(--text);
}

.cards {
  display: grid;
  gap: 12px;
}

.card {
  position: relative;
  background: linear-gradient(180deg, #f7f2e6, #ece3d1);
  color: #23303a;
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  text-align: left;
  font: inherit;
  width: 100%;
  cursor: default;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.card.selectable {
  cursor: pointer;
}

.card.selectable:hover,
.card.selectable:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  outline: none;
}

.card.blocked {
  opacity: 0.6;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #6b7b87;
}

.card-head b {
  color: #23303a;
}

.row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}

.row + .row {
  border-top: 1px dashed rgba(35, 48, 58, 0.18);
}

.row.done .row-pts {
  background: var(--ok);
  color: #06231a;
}

.cells {
  display: flex;
  gap: 5px;
  flex: 1;
  flex-wrap: wrap;
}

.cell {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  position: relative;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.cell.marked::after,
.cell.preview::after {
  content: "";
  position: absolute;
  inset: 4px;
  background: linear-gradient(45deg, transparent 43%, #fff 43%, #fff 57%, transparent 57%),
    linear-gradient(-45deg, transparent 43%, #fff 43%, #fff 57%, transparent 57%);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
}

.cell.marked::after {
  animation: pop 0.25s ease;
}

.cell.preview {
  outline: 2px dashed #23303a;
  outline-offset: 1px;
}

.cell.preview::after {
  opacity: 0.55;
}

@keyframes pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.row-pts {
  min-width: 34px;
  text-align: center;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(35, 48, 58, 0.1);
}

.star {
  color: #d19100;
  font-size: 0.9rem;
  width: 14px;
}

.card-foot {
  margin-top: 8px;
  font-size: 0.76rem;
  color: #6b7b87;
  display: flex;
  justify-content: space-between;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--accent);
  color: var(--accent-ink);
}

/* -------------------------------- tray --------------------------------- */

.tray {
  position: sticky;
  bottom: 0;
  background: rgba(16, 32, 43, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dice {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.die {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.22), 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.die .pip {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
}

.die.kept {
  transform: translateY(-6px);
  box-shadow: 0 0 0 3px var(--accent), 0 6px 14px rgba(0, 0, 0, 0.35);
}

.die.rolling {
  animation: tumble 0.5s ease;
}

.die.dead {
  opacity: 0.35;
  filter: grayscale(0.6);
}

@keyframes tumble {
  0% {
    transform: rotate(0) translateY(0) scale(1);
  }
  35% {
    transform: rotate(-140deg) translateY(-16px) scale(1.08);
  }
  70% {
    transform: rotate(120deg) translateY(6px) scale(0.96);
  }
  100% {
    transform: rotate(0) translateY(0) scale(1);
  }
}

.tray-hint {
  margin: 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  min-height: 1.2em;
}

.tray-actions {
  display: flex;
  gap: 8px;
}

/* -------------------------------- end ---------------------------------- */

.end-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.end-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  border: 1px solid var(--line);
}

.end-list li.win {
  border-color: var(--accent);
}

.end-list .rank {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--surface);
  font-weight: 800;
  font-size: 0.8rem;
}

.end-list .who {
  flex: 1;
  min-width: 0;
}

.end-list .who small {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.end-list .pts {
  font-size: 1.3rem;
  font-weight: 800;
}

/* ------------------------------ overlay -------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(4, 10, 14, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.overlay[hidden],
.screen[hidden] {
  display: none;
}



.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 86dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  border-top: 1px solid var(--line);
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  animation: rise 0.25s ease;
}

@keyframes rise {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-body h3 {
  margin-top: 16px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.sheet-body ul {
  margin: 0 0 8px;
  padding-left: 20px;
  line-height: 1.5;
}

#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}

@media (min-width: 620px) {
  .cards {
    grid-template-columns: 1fr 1fr;
  }
  .screen {
    max-width: 720px;
  }
  .sheet {
    border-radius: var(--radius);
    margin-bottom: 24px;
  }
  .overlay {
    align-items: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
