:root {
  --bg: #0f1729;
  --panel: #1b2540;
  --panel-light: #243152;
  --accent: #ff8a3d;
  --accent-dark: #e06f1f;
  --text: #e8ecf6;
  --muted: #8a96b3;
  --good: #4caf78;
  --die-face: #f7f9ff;
  --die-pip: #1b2540;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at top, #16203c, var(--bg));
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
}

header { text-align: center; margin-bottom: 1rem; }
header h1 { margin: 0; font-size: 2.2rem; }
.tagline { color: var(--muted); margin: 0.25rem 0 0; font-size: 0.9rem; }

main {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.players, .turn-info, .controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.turn-info {
  background: var(--panel);
  border-radius: 12px;
  padding: 0.6rem 1rem;
  font-weight: 600;
}
.turn-info #current-player { color: var(--accent); }
.turn-info #rolls-left { color: var(--muted); font-weight: 500; }

select {
  background: var(--panel-light);
  color: var(--text);
  border: 1px solid var(--muted);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  background: var(--panel-light);
  color: var(--text);
  transition: transform 0.08s ease, background 0.15s ease;
}
button:hover:not(:disabled) { background: #2c3a60; }
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.primary { background: var(--accent); color: #1b1206; }
button.primary:hover:not(:disabled) { background: var(--accent-dark); }

.dice {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-height: 70px;
}

.die {
  width: 64px;
  height: 64px;
  background: var(--die-face);
  border-radius: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 8px;
  cursor: pointer;
  box-shadow: 0 4px 0 #c4ccdf;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.die.held {
  background: #ffe9d6;
  box-shadow: 0 0 0 3px var(--accent), 0 4px 0 var(--accent-dark);
  transform: translateY(2px);
}
.die.rolling { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-6px) rotate(-8deg); }
  75% { transform: translateY(-4px) rotate(8deg); }
}

.pip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--die-pip);
  align-self: center;
  justify-self: center;
}
/* pip grid positions */
.p1 { grid-area: 1 / 1; } .p2 { grid-area: 1 / 2; } .p3 { grid-area: 1 / 3; }
.p4 { grid-area: 2 / 1; } .p5 { grid-area: 2 / 2; } .p6 { grid-area: 2 / 3; }
.p7 { grid-area: 3 / 1; } .p8 { grid-area: 3 / 2; } .p9 { grid-area: 3 / 3; }

.hint { color: var(--muted); font-size: 0.8rem; width: 100%; text-align: center; margin: 0; }

.scoreboard-wrap { overflow-x: auto; }
.scoreboard {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border-radius: 12px;
  overflow: hidden;
}
.scoreboard th, .scoreboard td {
  padding: 0.5rem 0.75rem;
  text-align: center;
  border-bottom: 1px solid #2a3760;
}
.scoreboard th { background: var(--panel-light); font-size: 0.85rem; }
.scoreboard td.cat { text-align: left; font-weight: 500; }
.scoreboard .section-row td {
  background: #14203c;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
}
.scoreboard .subtotal td, .scoreboard .total td { font-weight: 700; }
.scoreboard .total td { color: var(--accent); }

.cell-score { min-width: 56px; }
.cell-score.available {
  cursor: pointer;
  color: var(--good);
  background: rgba(76, 175, 120, 0.12);
}
.cell-score.available:hover { background: rgba(76, 175, 120, 0.28); }
.cell-score.filled { color: var(--text); }
.cell-score.active-col { box-shadow: inset 0 0 0 2px var(--accent); }

.result {
  text-align: center;
  background: var(--panel);
  border-radius: 12px;
  padding: 1.5rem;
}
.result h2 { margin-top: 0; color: var(--accent); }

footer { margin-top: 2rem; color: var(--muted); font-size: 0.8rem; }
