* {
  box-sizing: border-box;
}

:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --shadow: 0 18px 45px rgba(31, 41, 55, 0.12);
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 237, 213, 0.9), transparent 32%),
    radial-gradient(circle at bottom right, rgba(219, 234, 254, 0.9), transparent 32%),
    var(--bg);
  color: var(--ink);
}

.app {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 22px;
  padding: 22px;
  min-height: 100vh;
}

.sidebar,
.board-panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 18px;
  align-self: start;
}

.brand-card {
  padding: 14px 4px 8px;
}

.eyebrow {
  color: #9a3412;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(1.9rem, 4vw, 2.55rem);
  letter-spacing: -0.04em;
  line-height: 0.95;
}

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

.panel-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  margin-top: 14px;
}

label,
.section-title,
.status-label {
  display: block;
  font-weight: 800;
  margin-bottom: 8px;
}

select,
button {
  width: 100%;
  padding: 13px 15px;
  border-radius: 15px;
  border: 1px solid #d1d5db;
  font-size: 1rem;
  font-family: inherit;
}

select {
  background: #fff;
  margin-bottom: 12px;
}

button {
  font-weight: 800;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(31, 41, 55, 0.12);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  margin-bottom: 10px;
}

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

.turn-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 900;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
}

.turn-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.45), 0 0 0 3px rgba(0,0,0,0.06);
}

.status-text {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.player-list {
  display: grid;
  gap: 8px;
}

.player-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  color: #374151;
  font-weight: 750;
}

.player-chip.active {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px #dbeafe;
}

.player-name {
  display: flex;
  align-items: center;
  gap: 9px;
}

.player-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.45);
}

.player-progress {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

summary {
  font-weight: 850;
  cursor: pointer;
}

.rules ul {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.5;
}

.game-log {
  margin-top: 12px;
  max-height: 170px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.log-entry {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 9px 10px;
  color: #4b5563;
  line-height: 1.35;
  font-size: 0.92rem;
}

.board-panel {
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
  padding: 20px;
}

.board-shell {
  width: min(100%, 980px);
}

.board-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 2px 4px;
}

.board-title {
  font-weight: 900;
  font-size: 1.15rem;
}

.board-subtitle {
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 3px;
}

.small-button {
  width: auto;
  min-width: 112px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

canvas {
  display: block;
  width: 100%;
  max-width: 920px;
  height: auto;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.85), rgba(248,250,252,0.95));
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 28px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 12px 35px rgba(31,41,55,0.1);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(92vw, 390px);
  background: #fff;
  border-radius: 28px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0,0,0,0.28);
}

.winner-icon {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  margin: 0 auto 14px;
  box-shadow: inset 0 5px 10px rgba(255,255,255,0.4), 0 10px 20px rgba(0,0,0,0.18);
}

.modal-card h2 {
  margin: 0 0 6px;
  font-size: 2rem;
  letter-spacing: -0.03em;
}

.modal-card p {
  color: var(--muted);
  margin: 0 0 20px;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .board-panel {
    padding: 12px;
  }

  .board-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .small-button {
    width: 100%;
  }
}

button.hop-ready {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #111827;
  box-shadow: 0 10px 22px rgba(245, 158, 11, 0.24);
}

button.hop-ready::after {
  content: "  →";
}

.setup-hint {
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.ai-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.human-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.turn-badge.ai-thinking {
  background: #eef2ff;
  border-style: dashed;
}


.back-link {
  display: inline-block;
  margin: 8px 0 12px;
  color: #2563eb;
  font-weight: 800;
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }
