:root {
  --bg: #0f172a;
  --bg-soft: #16213e;
  --card: #1c2541;
  --card-2: #232e52;
  --accent: #22c55e;
  --accent-2: #6366f1;
  --danger: #ef4444;
  --warn: #f59e0b;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --border: #2f3b60;
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
}

a { color: var(--accent-2); }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 64px;
  width: 100%;
  flex: 1;
}

.wrap.wide { max-width: 1100px; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 12px; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
p { line-height: 1.5; color: var(--text-dim); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.center { text-align: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-2);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform .06s ease, opacity .15s ease;
}
.btn:hover { opacity: .92; }
.btn:active { transform: scale(.97); }
.btn.green { background: var(--accent); }
.btn.red { background: var(--danger); }
.btn.warn { background: var(--warn); color: #1c1c1c; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 8px 14px; font-size: .85rem; }
.btn.block { width: 100%; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; }
.row.end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; gap: 10px; }

input[type=text], input[type=password], input[type=number], select, textarea {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
  width: 100%;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); }
label { font-size: .85rem; color: var(--text-dim); display: block; margin-bottom: 4px; }
.field { margin-bottom: 14px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  background: var(--card-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.badge.green { background: rgba(34,197,94,.15); color: var(--accent); border-color: rgba(34,197,94,.4); }
.badge.red { background: rgba(239,68,68,.15); color: var(--danger); border-color: rgba(239,68,68,.4); }
.badge.warn { background: rgba(245,158,11,.15); color: var(--warn); border-color: rgba(245,158,11,.4); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.topbar .logo { font-weight: 800; font-size: 1.1rem; }

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 560px) { .choice-grid { grid-template-columns: 1fr; } }

.choice-btn {
  background: var(--card-2);
  border: 2px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 18px 16px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all .12s ease;
}
.choice-btn:hover { border-color: var(--accent-2); }
.choice-btn.selected { border-color: var(--accent-2); background: rgba(99,102,241,.18); }
.choice-btn.correct { border-color: var(--accent); background: rgba(34,197,94,.2); }
.choice-btn.wrong { border-color: var(--danger); background: rgba(239,68,68,.2); }
.choice-btn .key { display: inline-block; width: 26px; height: 26px; line-height: 26px; text-align: center; border-radius: 50%; background: var(--border); margin-right: 10px; font-size: .85rem; }

.timer-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--card-2);
  overflow: hidden;
  margin-bottom: 16px;
}
.timer-bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 1s linear;
}

.qr-box {
  background: white;
  padding: 16px;
  border-radius: 12px;
  display: inline-block;
}

.scoreboard { list-style: none; margin: 0; padding: 0; }
.scoreboard li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--card-2);
  margin-bottom: 8px;
  font-weight: 600;
}
.scoreboard li .rank { color: var(--text-dim); width: 28px; }
.scoreboard li:nth-child(1) { border: 1px solid #facc15; }
.scoreboard li:nth-child(2) { border: 1px solid #cbd5e1; }
.scoreboard li:nth-child(3) { border: 1px solid #b45309; }

.word-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 560px) { .word-grid { grid-template-columns: repeat(2, 1fr); } }
.word-btn {
  background: var(--card-2);
  border: 2px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 14px 8px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  font-size: .95rem;
}
.word-btn.selected { border-color: var(--accent-2); background: rgba(99,102,241,.25); }
.word-btn.locked { opacity: .35; cursor: default; }
.word-btn.group-0.locked { border-color: #22c55e; }
.word-btn.group-1.locked { border-color: #6366f1; }
.word-btn.group-2.locked { border-color: #f59e0b; }
.word-btn.group-3.locked { border-color: #ec4899; }

.timeline-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.timeline-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-2);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  cursor: grab;
  user-select: none;
}
.timeline-item.dragging { opacity: .4; }
.timeline-item img { width: 64px; height: 64px; object-fit: contain; background: white; border-radius: 8px; }
.timeline-item .pos { font-weight: 800; color: var(--text-dim); width: 22px; }
.timeline-item .handle { margin-left: auto; color: var(--text-dim); font-size: 1.3rem; }

.photo-frame {
  width: 100%;
  max-height: 320px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--card-2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.photo-frame img { max-width: 100%; max-height: 320px; object-fit: contain; }
.photo-frame .placeholder { color: var(--text-dim); padding: 40px; text-align: center; }

.present-stage {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
}
.present-stage h1 { font-size: 2.6rem; margin-bottom: 24px; }
.present-stage .prompt { font-size: 2rem; margin-bottom: 28px; max-width: 900px; }
.present-controls {
  position: sticky;
  bottom: 0;
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.count-pill {
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--card-2);
  border-radius: 999px;
  padding: 8px 18px;
}

.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tab-btn {
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
}
.tab-btn.active { background: var(--accent-2); color: white; border-color: var(--accent-2); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: .9rem; }
th { color: var(--text-dim); font-weight: 600; }

.muted { color: var(--text-dim); font-size: .85rem; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.hidden { display: none !important; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-2);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 10px;
  z-index: 50;
}
