:root {
  color-scheme: light;
  --bg: #f5f3ee;
  --panel: #ffffff;
  --text: #222;
  --muted: #666;
  --border: #ccc;
  --red: #d13b2f;
  --yellow: #e0b800;
  --green: #3f9142;
  --blue: #2f6fd1;
  --accent: #222;
}

* {
  box-sizing: border-box;
}

/* Must outrank any element's own `display` rule (e.g. `#landing { display: flex }`),
   otherwise setting the `hidden` attribute/property has no visual effect. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

h1, h2 {
  margin: 0 0 0.5em;
}

button {
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}

/* Landing */

#landing {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
}

#landing form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 220px;
  flex: 1;
}

#landing input {
  padding: 0.5rem;
  font-size: 1rem;
}

#landing button {
  padding: 0.5rem;
}

/* Lobby */

#lobby {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

#lobby-players {
  list-style: none;
  padding: 0;
}

#lobby-players li {
  padding: 0.25rem 0;
}

/* Game */

#game-header {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
}

#turn-banner {
  font-weight: 600;
  flex: 1 1 auto;
}

#dice-row {
  display: flex;
  gap: 0.35rem;
}

.die {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  font-weight: 700;
  color: #fff;
  background: #999;
}

.die-white {
  background: #eee;
  color: #222;
  border: 1px solid var(--border);
}

.die-red { background: var(--red); }
.die-yellow { background: var(--yellow); color: #222; }
.die-green { background: var(--green); }
.die-blue { background: var(--blue); }

#game-body {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

#board {
  flex: 1 1 500px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.4rem;
}

.row-label {
  width: 4.5rem;
  text-transform: capitalize;
  font-weight: 700;
}

.row-red .row-label { color: var(--red); }
.row-yellow .row-label { color: var(--yellow); }
.row-green .row-label { color: var(--green); }
.row-blue .row-label { color: var(--blue); }

.cell {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fafafa;
  color: var(--muted);
}

.cell.clickable {
  background: #fff;
  color: var(--text);
  border-color: var(--accent);
  font-weight: 700;
}

.cell.marked {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.row-red .cell.marked { background: var(--red); border-color: var(--red); }
.row-yellow .cell.marked { background: var(--yellow); border-color: var(--yellow); color: #222; }
.row-green .cell.marked { background: var(--green); border-color: var(--green); }
.row-blue .cell.marked { background: var(--blue); border-color: var(--blue); }

.cell.locked:not(.marked) {
  background: #eee;
  color: #bbb;
}

.cell.hint {
  color: var(--text);
}

.row-red .cell.hint { background: color-mix(in srgb, var(--red) 18%, #fafafa); }
.row-yellow .cell.hint { background: color-mix(in srgb, var(--yellow) 18%, #fafafa); }
.row-green .cell.hint { background: color-mix(in srgb, var(--green) 18%, #fafafa); }
.row-blue .cell.hint { background: color-mix(in srgb, var(--blue) 18%, #fafafa); }

.lock-cell {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.25;
}

.lock-cell.marked {
  opacity: 1;
}

#roster {
  flex: 0 1 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

#roster ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#roster li {
  padding: 0.25rem 0;
  border-bottom: 1px solid #eee;
}

#actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

#actions button {
  padding: 0.6rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

#game-over {
  margin-top: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

#final-scores {
  padding-left: 1.5rem;
}

/* Toast */

.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #b3261e;
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  z-index: 10;
}

/* Disconnected overlay */

#disconnected-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  z-index: 20;
}
