*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #0a0e18;
  --panel: #121a2b;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #f59e0b;
  --radius: 14px;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse 120% 80% at 50% 0%, #1a2744 0%, var(--bg) 55%);
}

.ludo-app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

.ludo-header {
  text-align: center;
  margin-bottom: 1rem;
}

.ludo-header h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.ludo-header .tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.ludo-header a {
  color: #93c5fd;
  text-decoration: none;
}

.ludo-header a:hover {
  text-decoration: underline;
}

.ludo-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.ludo-toolbar label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.ludo-toolbar select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  font: inherit;
}

.btn {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: linear-gradient(165deg, #fbbf24, #d97706);
  color: #1a1208;
  font-weight: 600;
}

.btn.primary:hover {
  filter: brightness(1.06);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.14);
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn.dice {
  min-width: 5.5rem;
  font-weight: 700;
  font-size: 1.1rem;
}

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

.ludo-main {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: flex-start;
  justify-content: center;
}

.ludo-canvas-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow:
    0 12px 48px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}

#ludo-canvas {
  display: block;
  width: min(92vw, 520px);
  height: auto;
  vertical-align: middle;
  background: #0f1624;
  cursor: pointer;
  touch-action: manipulation;
}

.ludo-side {
  width: min(100%, 320px);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.ludo-status {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  min-height: 1.5em;
}

.ludo-status strong {
  color: var(--accent);
}

.ludo-log {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.ludo-log p {
  margin: 0 0 0.35rem;
}

.ludo-rules {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.ludo-rules h3 {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: var(--text);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  max-width: 360px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.overlay-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
}

.overlay-card p {
  margin: 0 0 1.25rem;
  color: var(--muted);
}
