:root {
  --bg: #141B3D;
  --bg-deep: #0C1029;
  --gold: #E8B04B;
  --coral: #E8604C;
  --ice: #C7D4F2;
  --text: #F3F5FC;
  --muted: #7C86AD;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

input {
  font-family: inherit;
}

.screen-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--bg);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.card h1 {
  font-size: 24px;
  margin: 0 0 28px;
  color: var(--gold);
  letter-spacing: 0.02em;
}

.card label {
  display: block;
  font-size: 15px;
  color: var(--ice);
  margin-bottom: 12px;
}

.name-input {
  width: 100%;
  padding: 16px 14px;
  font-size: 18px;
  border-radius: 12px;
  border: 2px solid #2A335E;
  background: #0F1530;
  color: var(--text);
  text-align: center;
  outline: none;
}

.name-input:focus {
  border-color: var(--gold);
}

.primary-btn {
  margin-top: 24px;
  width: 100%;
  padding: 16px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 12px;
  background: var(--gold);
  color: #1A1300;
}

.primary-btn:disabled {
  background: #4A4634;
  color: #8A8674;
}

.error-text {
  margin-top: 12px;
  color: var(--coral);
  font-size: 14px;
  min-height: 18px;
}

/* --- vote screen --- */

.vote-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-deep);
  padding: 16px 20px 12px;
  font-size: 15px;
  color: var(--ice);
  border-bottom: 1px solid #202750;
}

.vote-header strong { color: var(--gold); }

.guide-box {
  margin: 14px 20px;
  padding: 16px 18px;
  background: var(--bg);
  border-radius: 14px;
  border-left: 4px solid var(--gold);
}

.guide-box p {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.guide-box ul {
  margin: 0;
  padding-left: 18px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}

.item-list {
  padding: 4px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-row {
  border-radius: 16px;
  padding: 16px 18px;
  background: var(--bg);
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
}

.item-row.locked {
  opacity: 0.45;
}

.item-row.open {
  border-color: var(--coral);
  animation: pulse 1.6s ease-in-out infinite;
}

.item-row.closed {
  opacity: 0.85;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232,96,76,0.35); }
  50% { box-shadow: 0 0 0 8px rgba(232,96,76,0); }
}

.item-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.item-name {
  font-size: 17px;
  font-weight: 700;
}

.item-tag {
  font-size: 12px;
  color: var(--muted);
}

.item-row.open .item-tag {
  color: var(--coral);
  font-weight: 700;
}

.stars {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.star-btn {
  flex: 1;
  min-width: 44px;
  min-height: 56px;
  font-size: 30px;
  background: #0F1530;
  border-radius: 10px;
  color: #3A4270;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, color 0.15s;
}

.item-row.open .star-btn {
  min-height: 64px;
  font-size: 34px;
  background: rgba(232,96,76,0.08);
}

.star-btn.filled {
  color: var(--gold);
}

.star-btn:active {
  transform: scale(0.9);
}

.score-readout {
  font-size: 15px;
  color: var(--gold);
  font-weight: 700;
  margin-top: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--gold);
  color: #1A1300;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 50;
}

.toast.error {
  background: var(--coral);
  color: #2A0A05;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- admin --- */

.admin-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px;
  width: 100%;
}

.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.agg-toggle {
  display: flex;
  gap: 6px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
}

.agg-toggle button {
  padding: 8px 16px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.agg-toggle button.active {
  background: var(--gold);
  color: #1A1300;
}

.admin-row {
  display: grid;
  grid-template-columns: 60px 90px 1fr 130px 110px;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: 12px;
  margin-bottom: 8px;
}

.admin-row .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.status-locked .status-dot { background: var(--muted); }
.status-open .status-dot { background: var(--coral); }
.status-closed .status-dot { background: var(--ice); }

.admin-btn {
  padding: 12px 10px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
}

.admin-btn.open-btn {
  background: var(--coral);
  color: #2A0A05;
  padding: 16px 10px;
}

.admin-btn.close-btn {
  background: #2A335E;
  color: var(--text);
}

.reveal-btn {
  width: 100%;
  padding: 18px;
  margin-top: 20px;
  border-radius: 14px;
  background: var(--gold);
  color: #1A1300;
  font-size: 18px;
  font-weight: 800;
}

.admin-meta {
  font-size: 14px;
  color: var(--ice);
}

.warn-banner {
  background: var(--coral);
  color: #2A0A05;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  margin-bottom: 14px;
}

.bulk-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.bulk-actions .admin-btn {
  flex: 1;
  padding: 14px;
}

.guide-editor {
  background: var(--bg);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 18px;
  text-align: left;
}

.guide-editor label {
  display: block;
  margin-bottom: 8px;
  color: var(--ice);
  font-size: 14px;
}

.guide-editor textarea {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 2px solid #2A335E;
  background: #0F1530;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
}

.guide-editor textarea:focus {
  outline: none;
  border-color: var(--gold);
}

.guide-save-btn {
  margin-top: 10px;
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  background: var(--gold);
  color: #1A1300;
  font-weight: 700;
}

.guide-status {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  min-height: 16px;
}

.danger-zone {
  border: 2px solid var(--coral);
  border-radius: 14px;
  padding: 18px 20px;
  margin-top: 36px;
}

.danger-zone label {
  display: block;
  margin-bottom: 10px;
  color: var(--coral);
  font-size: 13px;
  font-weight: 700;
}

.reset-btn {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  background: var(--coral);
  color: #2A0A05;
  font-weight: 700;
}

/* --- results (LED wall) --- */

.results-body {
  background: var(--bg-deep);
  overflow: hidden;
  height: 100vh;
}

.results-stage {
  position: relative;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.results-title {
  font-size: 56px;
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0.03em;
  text-align: center;
}

.results-sub {
  font-size: 22px;
  color: var(--ice);
  margin-top: 16px;
}

.rank-stack {
  position: absolute;
  bottom: 6vh;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 0 40px;
}

.rank-row {
  display: flex;
  align-items: baseline;
  gap: 28px;
  background: rgba(255,255,255,0.03);
  padding: 14px 32px;
  border-radius: 16px;
  min-width: 480px;
  justify-content: space-between;
  opacity: 0;
  transform: translateY(40px);
  animation: rankIn 0.5s ease-out forwards;
}

@keyframes rankIn {
  to { opacity: 1; transform: translateY(0); }
}

.rank-num {
  font-size: 28px;
  color: var(--muted);
  font-weight: 800;
  width: 60px;
}

.rank-name {
  font-size: 30px;
  font-weight: 700;
  flex: 1;
  text-align: left;
}

.rank-score {
  font-size: 26px;
  color: var(--gold);
  font-weight: 700;
}

.top3-stage {
  text-align: center;
}

.top3-rank-label {
  font-size: 34px;
  color: var(--ice);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.top3-name {
  font-size: 72px;
  font-weight: 900;
  color: var(--text);
  margin: 20px 0 10px;
  opacity: 0;
}

.top3-name.revealed {
  opacity: 1;
  animation: bigReveal 0.6s ease-out;
}

.top3-score {
  font-size: 40px;
  color: var(--gold);
  font-weight: 800;
  opacity: 0;
}

.top3-score.revealed {
  opacity: 1;
}

@keyframes bigReveal {
  0% { transform: scale(0.7); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.rank1 .top3-name { font-size: 96px; color: var(--gold); }

.top3-name.suspense {
  opacity: 0.6;
  color: var(--muted);
  animation: suspensePulse 0.5s ease-in-out infinite;
}

.top3-score.suspense {
  opacity: 0.9;
  animation: suspensePulse 0.18s ease-in-out infinite;
}

@keyframes suspensePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.final-table {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 70vw;
  max-width: 760px;
}

.hint {
  position: fixed;
  bottom: 16px;
  right: 20px;
  color: var(--muted);
  font-size: 13px;
}
