:root {
  --red: #d7263d;
  --green: #2a9d3b;
  --yellow: #f2c200;
  --blue: #1f6feb;
  --bg: #140d04;
  --bg2: #241803;
  --panel: #2a1e0e;
  --panel2: #35270f;
  --ink: #f7efdc;
  --accent: #f2c200;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, #3a2a0e 0%, transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  color: var(--ink);
  text-align: center;
  display: flex;
  flex-direction: column;
}

header {
  padding: 1.2rem 1rem;
  background: linear-gradient(90deg, var(--red), var(--yellow), var(--green));
  color: #1a1206;
  box-shadow: 0 2px 20px rgba(0,0,0,0.4);
}
header h1 { margin: 0; font-size: 2rem; letter-spacing: 2px; font-weight: 800; }
.tagline { margin: 0.3rem 0 0; font-size: 0.95rem; }
.soon { opacity: 0.75; font-style: italic; }

main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Setup screen ---------- */
.setup-screen { width: 100%; display: flex; justify-content: center; }
.setup-card {
  background: var(--panel);
  padding: 2.5rem;
  border-radius: var(--radius);
  box-shadow: 0 12px 50px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 280px;
}
.setup-card h2 { margin: 0; color: var(--accent); }
.setup-card label { font-size: 0.95rem; opacity: 0.9; }
.setup-card .toggle {
  display: flex; align-items: center; gap: 0.5rem;
  justify-content: center; cursor: pointer; user-select: none;
}
.setup-card .toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.ai-tag {
  font-size: 0.7rem;
  background: var(--accent);
  color: #1a1206;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 700;
  margin-left: 4px;
}

select, button {
  font-size: 1rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
button {
  background: var(--accent);
  color: #1a1206;
  font-weight: 700;
  transition: transform 0.08s ease, filter 0.2s, opacity 0.2s;
}
button:hover { transform: translateY(-2px); filter: brightness(1.05); }
button:active { transform: translateY(0); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
button.secondary { background: var(--panel2); color: var(--ink); }
button.big { font-size: 1.15rem; padding: 0.9rem 1.4rem; width: 100%; }
select { background: var(--ink); color: #1a1206; }

/* ---------- Game layout ---------- */
.game-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
}

.board-wrap {
  position: relative;
  flex: 0 1 620px;
  max-width: 620px;
  width: 100%;
}

canvas#board {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 12px 50px rgba(0,0,0,0.5), inset 0 0 0 3px rgba(242,194,0,0.15);
  touch-action: manipulation;
  display: block;
}
canvas.fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* side panel */
.panel {
  flex: 0 0 260px;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  align-items: stretch;
}

.status-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1rem;
  font-weight: 700;
  font-size: 1.05rem;
  min-height: 3.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.dice-area {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* 3D-ish dice */
.dice3d {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: linear-gradient(145deg, #fffef7, #d8cfb4);
  color: #1a1206;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 800;
  box-shadow: 0 6px 0 #b4a373, 0 10px 18px rgba(0,0,0,0.4);
  transition: transform 0.1s;
}
.dice3d.rolling { animation: tumble 0.6s cubic-bezier(.36,.07,.19,.97); }
@keyframes tumble {
  0%   { transform: rotate(0)      scale(1); }
  20%  { transform: rotate(-90deg) scale(1.15); }
  40%  { transform: rotate(120deg) scale(0.95); }
  60%  { transform: rotate(-160deg)scale(1.15); }
  80%  { transform: rotate(210deg) scale(1); }
  100% { transform: rotate(360deg) scale(1); }
}

/* legend */
.legend {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.legend .chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  background: var(--panel);
  font-size: 0.95rem;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  transition: outline 0.2s, transform 0.2s, background 0.2s;
}
.legend .dot {
  width: 18px; height: 18px; border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.3);
}
.legend .active {
  outline: 3px solid var(--accent);
  transform: scale(1.04);
  background: var(--panel2);
}
.legend .count { margin-left: auto; opacity: 0.8; font-size: 0.85rem; }

/* banner */
.banner {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  padding: 1rem 2rem;
  border-radius: 14px;
  font-size: 1.5rem;
  font-weight: 800;
  color: #1a1206;
  background: var(--accent);
  box-shadow: 0 12px 44px rgba(0,0,0,0.55);
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.hidden { display: none !important; }

footer { padding: 1rem; font-size: 0.8rem; opacity: 0.75; }
footer a { color: var(--accent); }

/* ---------- Responsive: stack on narrow screens ---------- */
@media (max-width: 820px) {
  main { padding: 1rem; }
  .game-layout { flex-direction: column; align-items: center; gap: 1rem; }
  .board-wrap { flex: 1 1 auto; max-width: 560px; }
  .panel { flex: 1 1 auto; width: 100%; max-width: 560px; flex-direction: row; flex-wrap: wrap; }
  .status-card { flex: 1 1 100%; }
  .dice-area { flex: 1 1 160px; flex-direction: row; }
  .legend { flex: 2 1 240px; flex-direction: column; }
  button.secondary { flex: 1 1 100%; }
}
@media (max-width: 480px) {
  header h1 { font-size: 1.5rem; }
  .tagline { font-size: 0.8rem; }
  .dice-area { flex-direction: column; }
  .dice3d { width: 60px; height: 60px; font-size: 2rem; }
  .banner { font-size: 1.15rem; padding: 0.8rem 1.3rem; }
}
