:root {
  color-scheme: light;
  --bg-1: #eff6ff;
  --bg-2: #dbeafe;
  --bg-3: #bfdbfe;
  --bg-4: #1d4ed8;
  --panel: rgba(255, 255, 255, 0.95);
  --panel-strong: rgba(255, 255, 255, 0.99);
  --text: #102a43;
  --muted: #486581;
  --brand: #2563eb;
  --brand-2: #60a5fa;
  --brand-3: #1d4ed8;
  --line: rgba(37, 99, 235, 0.14);
  --shadow: 0 22px 64px rgba(37, 99, 235, 0.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 12%, rgba(96, 165, 250, 0.22), transparent 18%),
    radial-gradient(circle at 86% 18%, rgba(37, 99, 235, 0.18), transparent 14%),
    linear-gradient(180deg, #f8fbff 0%, #edf4ff 42%, #dfeeff 100%);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 30px 30px, rgba(255,255,255,0.6) 0 2px, transparent 3px),
    radial-gradient(circle at 90px 70px, rgba(255,255,255,0.28) 0 1px, transparent 2px);
  background-size: 140px 140px, 220px 220px;
  opacity: 0.22;
}

a { color: inherit; }
button, input { font: inherit; }
button:disabled { cursor: not-allowed; opacity: 0.72; transform: none !important; }

.party-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.spark {
  position: absolute;
  border-radius: 50%;
  opacity: 0.22;
  animation: floatSpark 14s linear infinite;
}
.spark-1 { width: 240px; height: 240px; left: -80px; top: -50px; background: radial-gradient(circle, rgba(96,165,250,0.24), transparent 70%); }
.spark-2 { width: 180px; height: 180px; right: 4%; top: 14%; background: radial-gradient(circle, rgba(37,99,235,0.18), transparent 70%); animation-duration: 18s; }
.spark-3 { width: 220px; height: 220px; left: 32%; bottom: 10%; background: radial-gradient(circle, rgba(59,130,246,0.12), transparent 70%); animation-duration: 20s; }

.shell { width: min(1160px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 48px; position: relative; z-index: 1; }
.hero {
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 24px;
  background: rgba(255,255,255,0.94);
  box-shadow: var(--shadow);
}
.hero-party {
  background: linear-gradient(135deg, rgba(255,255,255,0.98), rgba(239,246,255,0.96));
}
.hero-party::after {
  content: '';
  position: absolute;
  inset: auto 18px 18px auto;
  width: 78px;
  height: 78px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(96,165,250,0.16), rgba(37,99,235,0.10));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.5);
  transform: rotate(8deg);
}
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--brand-3);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 12px;
}
.kicker::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.10);
}
h1 { margin: 0; font-size: clamp(34px, 5vw, 60px); line-height: 0.95; letter-spacing: -0.05em; }
.sub { margin: 0; max-width: 64ch; color: var(--muted); font-size: 16px; line-height: 1.8; }
.party-sub { color: #24415e; font-weight: 500; }
.muted-note { color: #50708e; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(12, 1fr); margin-top: 20px; }
.card {
  border: 1px solid rgba(37, 99, 235, 0.10);
  border-radius: 22px;
  background: var(--panel-strong);
  box-shadow: 0 14px 34px rgba(37, 99, 235, 0.08);
  overflow: hidden;
}
.card-party { background: linear-gradient(180deg, rgba(255,255,255,0.99), rgba(243,248,255,0.98)); }
.card-hd { padding: 18px 20px 0; }
.card-bd { padding: 18px 20px 22px; }
.card h2 { margin: 0; font-size: 20px; color: #16324f; }
.card p.small { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.badges { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.badge {
  padding: 10px 14px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid rgba(37, 99, 235, 0.12);
}
.badge-party { background: #eff6ff; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 14px 12px; border-bottom: 1px solid rgba(37, 99, 235, 0.10); text-align: left; font-size: 14px; }
.table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.table tr:last-child td { border-bottom: 0; }
.table input { width: 100%; padding: 10px 12px; border: 1px solid rgba(37, 99, 235, 0.14); border-radius: 14px; background: #fff; }
.btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}
.btn:hover { transform: translateY(-2px) scale(1.02); }
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #60a5fa 58%, #93c5fd 100%);
  box-shadow: 0 12px 22px rgba(37, 99, 235, 0.22);
}
.btn-ghost {
  background: rgba(255,255,255,0.92);
  color: #1d4ed8;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.06);
}
.btn-danger { background: #ffe9e5; color: #b42318; }
.btn-sm { padding: 10px 14px; border-radius: 14px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.layout-main { grid-column: span 8; }
.layout-side { grid-column: span 4; }
.form { display: grid; gap: 12px; }
.form input, .form textarea, .player-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(37, 99, 235, 0.14);
  border-radius: 18px;
  background: #fff;
  outline: none;
}
.player-input-party { font-size: 15px; }
.notice {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: #f8fbff;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}
.notice-party { background: #f8fbff; color: #43607b; }
.result {
  margin-top: 18px;
  padding: 22px;
  border-radius: 22px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1px solid rgba(37, 99, 235, 0.12);
}
.result-party { position: relative; overflow: hidden; }
.result-label { color: var(--brand-3); font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.result strong { display: block; font-size: clamp(24px, 4vw, 34px); margin-top: 6px; letter-spacing: -0.04em; color: #0f172a; }
.list { display: grid; gap: 12px; }
.list-item {
  padding: 14px 16px;
  border: 1px solid rgba(37, 99, 235, 0.10);
  border-radius: 18px;
  background: rgba(255,255,255,0.96);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.list-item .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.history-item { justify-content: flex-start; align-items: flex-start; }
.party-item { box-shadow: 0 8px 18px rgba(37, 99, 235, 0.04); }
.prize-tone-1 { border-left: 4px solid #2563eb; }
.prize-tone-2 { border-left: 4px solid #60a5fa; }
.prize-tone-3 { border-left: 4px solid #93c5fd; }
.history-tone-1 { border-left: 4px solid #2563eb; }
.history-tone-2 { border-left: 4px solid #60a5fa; }
.history-tone-3 { border-left: 4px solid #93c5fd; }
.party-title { font-weight: 800; color: #0f172a; }
.party-count { font-size: 22px; color: #1d4ed8; }
.footer-note { margin-top: 20px; color: var(--muted); font-size: 13px; }
.draw-topbar { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.rolling-board {
  margin-top: 18px;
  min-height: 210px;
  padding: 24px;
  border-radius: 22px;
  border: 1px solid rgba(37, 99, 235, 0.12);
  background:
    linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%);
  display: grid;
  place-items: center;
  text-align: center;
  gap: 10px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.4), 0 14px 28px rgba(37, 99, 235, 0.06);
  position: relative;
  overflow: hidden;
}
.rolling-board::before {
  content: '';
  position: absolute;
  inset: auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(96,165,250,0.16), transparent 68%);
  top: -60px;
  right: -60px;
  pointer-events: none;
}
.rolling-board::after {
  content: '';
  position: absolute;
  inset: auto;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(29,78,216,0.08), transparent 70%);
  bottom: -70px;
  left: -70px;
  pointer-events: none;
}
.rolling-board.is-drawing { animation: pulseGlow 0.9s ease-in-out infinite alternate; }
.rolling-label {
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.rolling-label-party { color: #1d4ed8; }
.rolling-emojis { font-size: 15px; letter-spacing: 0.26em; color: #60a5fa; }
.rolling-name {
  font-size: clamp(30px, 5vw, 48px);
  font-weight: 900;
  letter-spacing: -0.04em;
  color: #102a43;
}
.rolling-name-party { text-shadow: 0 6px 12px rgba(37, 99, 235, 0.06); }
.rolling-tip { color: #55708a; font-size: 14px; font-weight: 500; }
.rolling-tip-party { color: #55708a; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 15, 38, 0.36);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
  backdrop-filter: blur(3px);
}
.modal-backdrop.hidden { display: none; }
.winner-modal {
  width: min(480px, 100%);
  padding: 28px 26px 24px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.99), rgba(240,246,255,0.98));
  box-shadow: 0 24px 64px rgba(8, 15, 38, 0.18);
  text-align: center;
  animation: modalPop .24s ease-out;
  position: relative;
  overflow: hidden;
}
.winner-modal-party::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: radial-gradient(circle at 20% 0%, rgba(96,165,250,0.12), transparent 25%), radial-gradient(circle at 80% 0%, rgba(37,99,235,0.10), transparent 22%);
  pointer-events: none;
}
.confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.winner-kicker { color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; position: relative; z-index: 1; }
.winner-kicker-party { color: #1d4ed8; }
.winner-modal h2 { margin: 12px 0 10px; font-size: clamp(28px, 5vw, 42px); letter-spacing: -0.05em; position: relative; z-index: 1; color: #0f172a; }
.winner-modal p { margin: 0 0 18px; color: var(--muted); line-height: 1.8; position: relative; z-index: 1; }
.winner-modal .btn { position: relative; z-index: 1; }
.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px 0;
  color: #3b82f6;
  font-size: 12px;
  text-decoration: none;
}
.admin-link:hover { color: #1d4ed8; }
@keyframes pulseGlow {
  from { transform: scale(1); box-shadow: 0 0 0 rgba(37, 99, 235, 0.08); }
  to { transform: scale(1.008); box-shadow: 0 14px 28px rgba(37, 99, 235, 0.10); }
}
@keyframes modalPop {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes floatSpark {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(18px, -16px, 0) scale(1.05); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}
@media (max-width: 920px) {
  .layout-main, .layout-side { grid-column: span 12; }
}
@media (max-width: 640px) {
  .shell { width: min(100% - 20px, 1160px); padding-top: 14px; }
  .hero, .card, .rolling-board, .winner-modal { border-radius: 20px; }
  .table { display: block; overflow-x: auto; }
  .draw-topbar { grid-template-columns: 1fr; }
  .actions { width: 100%; }
  .actions .btn, .actions a.btn { flex: 1 1 auto; justify-content: center; text-align: center; }
}
