:root {
  --bg: #0c0a14;
  --bg-elev: #161028;
  --bg-card: #1d1733;
  --border: #322a4d;
  --text: #ece5ff;
  --muted: #9c91c2;
  --accent: #ffba49;
  --accent-2: #ff5d8f;
  --good: #57e389;
  --bad: #ff6b6b;
  --magic: #b18cff;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: radial-gradient(ellipse at top, #1a1330, var(--bg) 70%);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 10, 20, 0.7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.who {
  font-size: 14px;
  color: var(--muted);
}

main {
  max-width: 1024px;
  margin: 0 auto;
  padding: 24px 16px 96px;
  display: grid;
  gap: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.card h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

.center {
  text-align: center;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.row.between {
  justify-content: space-between;
}

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 16px;
  margin: 12px 0;
}

input[type="text"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.06s, background 0.2s;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a1133;
  border: none;
  font-weight: 700;
}

button.primary.big {
  padding: 16px 28px;
  font-size: 20px;
  width: 100%;
  margin-top: 12px;
}

button.ghost {
  background: transparent;
}

.countdown {
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
}

.countdown.urgent {
  color: var(--bad);
  animation: pulse 0.6s infinite alternate;
}

@keyframes pulse {
  to {
    transform: scale(1.05);
  }
}

.word-section {
  margin: 14px 0;
  display: grid;
  gap: 8px;
}

.word-section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (max-width: 520px) {
  .word-grid {
    grid-template-columns: 1fr;
  }
}

.word-picks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

@media (max-width: 520px) {
  .word-picks {
    grid-template-columns: repeat(2, 1fr);
  }
}

.word-chip {
  padding: 12px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  user-select: none;
  transition: transform 0.1s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.word-chip:hover:not(.disabled):not(.selected) {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.word-chip.selected {
  background: rgba(255, 186, 73, 0.18);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.word-chip.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.word-chip.struck {
  text-decoration: line-through;
  color: var(--bad);
  border-color: var(--bad);
  background: rgba(255, 107, 107, 0.12);
}

.word-chip.locked-in {
  animation: lockedInPulse 0.9s ease-out;
  border-color: var(--good);
  background: rgba(87, 227, 137, 0.22);
  color: var(--good);
}

.word-cell input {
  margin: 0;
  text-align: center;
  font-size: 16px;
  text-transform: lowercase;
}

.word-cell.struck input {
  text-decoration: line-through;
  color: var(--bad);
  background: rgba(255, 107, 107, 0.12);
}

.word-cell.used input {
  background: rgba(87, 227, 137, 0.07);
  border-color: var(--good);
}

.word-cell.locked-in input {
  border-color: var(--good);
  background: rgba(87, 227, 137, 0.18);
  animation: lockedInPulse 0.9s ease-out;
}

@keyframes lockedInPulse {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.08);
    box-shadow: 0 0 22px rgba(87, 227, 137, 0.65);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(87, 227, 137, 0);
  }
}

button.primary.celebrating {
  background: linear-gradient(135deg, var(--good), var(--accent));
  color: #1a1133;
  animation: btnCelebrate 0.7s ease-out;
}

@keyframes btnCelebrate {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.1) rotate(-1deg);
  }
  60% {
    transform: scale(0.97);
  }
  100% {
    transform: scale(1);
  }
}

.confetti {
  position: fixed;
  top: -40px;
  pointer-events: none;
  user-select: none;
  z-index: 1000;
  animation: confettiFall linear forwards;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 24px auto;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.banlist-result {
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
}

.banlist-result .struck {
  color: var(--bad);
  text-decoration: line-through;
  margin: 0 4px;
}

.banlist-result .used {
  color: var(--good);
  margin: 0 4px;
}

.arena {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: stretch;
  perspective: 800px;
}

@media (max-width: 720px) {
  .arena {
    grid-template-columns: 1fr;
  }
  .vs {
    order: 0;
  }
}

.fighter {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transform-origin: center center;
  transition: transform 320ms cubic-bezier(0.2, 0.85, 0.2, 1.1), box-shadow 240ms ease, border-color 200ms ease;
  will-change: transform;
}

.arena.is-round-live .fighter {
  transform: scale(0.92);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  border-color: var(--accent);
}

.fighter.round-pulse {
  animation: roundPulse 720ms cubic-bezier(0.2, 0.85, 0.2, 1.1);
}

@keyframes roundPulse {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(0.86) rotateY(-6deg);
  }
  70% {
    transform: scale(0.95) rotateY(2deg);
  }
  100% {
    transform: scale(0.92);
  }
}

.fighter .portrait {
  aspect-ratio: 1 / 1;
  background: var(--bg-elev);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  max-height: 180px;
}

.fighter .portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.portrait-skel {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, var(--bg-elev) 30%, var(--border) 50%, var(--bg-elev) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.fighter .fname {
  margin: 4px 0 0;
  font-size: 18px;
}

.fighter .twist-tag {
  display: inline-block;
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(177, 140, 255, 0.15);
  border: 1px solid var(--magic);
  color: var(--magic);
  font-size: 12px;
  font-weight: 600;
}

.fighter .hp {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hp-bar {
  flex: 1;
  height: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--good), var(--accent));
  width: 100%;
  transition: width 0.45s ease-out;
}

.hp-text {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--muted);
}

.fighter.is-hit .portrait {
  animation: shake 0.45s;
}

@keyframes shake {
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-3px);
  }
  100% {
    transform: translateX(0);
  }
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 4px;
}

.stat-pill {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  text-align: center;
  font-size: 11px;
}

.stat-pill .val {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.abilities {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.abilities li {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
}

.abilities li strong {
  color: var(--accent);
}

.abilities li.fired {
  border-color: var(--accent);
  background: rgba(255, 186, 73, 0.12);
  animation: flash 0.6s;
}

@keyframes flash {
  0% {
    background: rgba(255, 186, 73, 0.4);
  }
  100% {
    background: rgba(255, 186, 73, 0.12);
  }
}

.vs {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.vs-label {
  font-size: 32px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.1em;
}

.round-indicator {
  font-size: 14px;
  color: var(--muted);
}

.battle-log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.battle-log li {
  padding: 0;
  margin: 0;
  list-style: none;
}

.round-entry {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  overflow: hidden;
  animation: slideIn 0.4s ease-out;
}

.round-entry[open] {
  border-left-color: var(--accent-2);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
}

.round-entry > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  user-select: none;
}

.round-entry > summary::-webkit-details-marker {
  display: none;
}

.round-entry > summary::after {
  content: "▾";
  color: var(--muted);
  transition: transform 200ms ease;
  margin-left: 6px;
}

.round-entry[open] > summary::after {
  transform: rotate(180deg);
}

.round-entry .round-label {
  font-weight: 700;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.round-entry .round-winner {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 186, 73, 0.15);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.round-entry .round-body {
  padding: 0 14px 14px;
  display: grid;
  gap: 10px;
  font-size: 14px;
  line-height: 1.45;
}

.round-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 420px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.round-actions {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.round-actions .crit-tag {
  color: var(--accent-2);
  font-weight: 700;
  font-size: 11px;
}

.prompt-toggle {
  font-size: 12px;
  color: var(--muted);
}

.prompt-toggle > summary {
  cursor: pointer;
  padding: 4px 0;
  list-style: none;
}

.prompt-toggle > summary::-webkit-details-marker {
  display: none;
}

.prompt-toggle > summary::before {
  content: "▸ ";
  color: var(--accent);
}

.prompt-toggle[open] > summary::before {
  content: "▾ ";
}

.prompt-toggle pre {
  margin: 6px 0 0;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.scene-banner {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--bg-card);
  animation: slideIn 0.4s ease-out;
}

.scene-banner img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
}

.scene-meta {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 14px 18px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scene-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.scene-location {
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
}

.round-controls {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

#skip-round {
  font-variant-numeric: tabular-nums;
  min-width: 200px;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.leaderboard,
.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.leaderboard li,
.history li {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.leaderboard li .rank {
  color: var(--accent);
  font-weight: 700;
  margin-right: 6px;
}

.history li.win {
  border-left: 3px solid var(--good);
}

.history li.loss {
  border-left: 3px solid var(--bad);
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: 90%;
  font-size: 14px;
}
