:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --x: #f472b6;
  --o: #34d399;
  --border: #334155;
}

* {
  box-sizing: border-box;
}

/*
 * The `hidden` attribute must win over any element's `display` rule
 * (e.g. `.setup { display: flex }`), otherwise toggling `el.hidden`
 * from JS has no visual effect.
 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1e293b, var(--bg));
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.container {
  width: 100%;
  max-width: 520px;
  text-align: center;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 28px;
  line-height: 1.5;
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 10px;
  background: var(--accent-strong);
  color: #04283a;
  transition: transform 0.05s ease, background 0.2s ease;
  text-decoration: none;
  display: inline-block;
}

.btn:hover {
  background: var(--accent);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.status {
  margin: 20px 0;
  min-height: 1.5em;
  font-size: 1.15rem;
  font-weight: 600;
}

.status .turn-x {
  color: var(--x);
}

.status .turn-o {
  color: var(--o);
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 auto 20px;
  max-width: 320px;
}

.cell {
  aspect-ratio: 1 / 1;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.cell:hover:not(:disabled) {
  background: #111a2e;
}

.cell:disabled {
  cursor: default;
}

.cell.x {
  color: var(--x);
}

.cell.o {
  color: var(--o);
}

.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.error {
  color: #fca5a5;
  min-height: 1.2em;
  margin-top: 12px;
  font-size: 0.95rem;
}

.footnote {
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.footnote code {
  background: #0b1220;
  padding: 2px 6px;
  border-radius: 6px;
}

.section-title {
  margin: 28px 0 8px;
  font-size: 1.1rem;
  color: var(--muted);
  text-align: left;
}

.standings {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 4px;
}

.standings th,
.standings td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.standings th {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.standings td:first-child,
.standings th:first-child {
  width: 60px;
}

.standings td:last-child,
.standings th:last-child {
  text-align: right;
}

.standings .turn-x,
.standings .turn-o,
.recent .turn-x,
.recent .turn-o {
  font-weight: 800;
}

.recent {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  text-align: left;
}

.recent li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

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

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.field-label {
  font-weight: 700;
  font-size: 0.9rem;
}

.setup input[type='text'] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  font-size: 1rem;
}

.setup input[type='text']:focus {
  outline: none;
  border-color: var(--accent);
}

.players {
  margin: 4px 0 12px;
  font-size: 1.05rem;
  font-weight: 600;
}

.players .turn-x,
.players .turn-o {
  font-weight: 800;
}

.player-name {
  font-weight: 600;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-row input[type='text'] {
  flex: 1;
}

.dice {
  flex: 0 0 auto;
  width: 48px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0b1220;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

.dice:hover:not(:disabled) {
  background: #111a2e;
}

.dice:active:not(:disabled) {
  transform: translateY(1px);
}

.dice:disabled {
  opacity: 0.5;
  cursor: default;
}

.xray-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.xray-link:hover {
  text-decoration: underline;
}
