:root {
  --ink: #13202c;
  --muted: #647184;
  --paper: #f8fafc;
  --line: #d6deea;
  --blue: #2563eb;
  --red: #ef4444;
  --gold: #f4b63d;
  --green: #16a34a;
  --panel: rgba(255, 255, 255, 0.92);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.14), rgba(244, 182, 61, 0.12)),
    #eef3f8;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.lobby {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 24px;
  align-items: stretch;
  width: min(1120px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
}

.brand-panel,
.join-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(37, 52, 76, 0.12);
}

.brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 5vw, 56px);
  overflow: hidden;
  position: relative;
}

.brand-panel::after {
  content: "";
  position: absolute;
  inset: auto -80px -70px auto;
  width: 260px;
  height: 260px;
  background: conic-gradient(from 120deg, var(--red), var(--gold), var(--blue), var(--red));
  opacity: 0.18;
  transform: rotate(8deg);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 10ch;
  font-size: clamp(2.6rem, 6vw, 5.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.intro {
  max-width: 34rem;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.join-panel {
  display: grid;
  gap: 18px;
  align-content: center;
  padding: clamp(22px, 4vw, 40px);
}

label,
fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
  color: #243247;
  font-size: 0.9rem;
  font-weight: 700;
}

fieldset {
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: white;
  outline: none;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.character {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 8px;
  background: white;
  text-align: center;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.character[aria-pressed="true"] {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.character:hover {
  transform: translateY(-2px);
}

.avatar {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 8px;
  border-radius: 50%;
  color: white;
  font-weight: 900;
}

.character strong {
  display: block;
  min-height: 34px;
  font-size: 0.8rem;
  line-height: 1.2;
}

.character span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.primary,
.secondary,
.ghost {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
}

.primary {
  color: white;
  background: var(--blue);
}

.secondary {
  color: var(--ink);
  background: white;
  border-color: var(--line);
}

.ghost {
  color: #26364c;
  background: rgba(255, 255, 255, 0.84);
  border-color: rgba(255, 255, 255, 0.4);
}

.game {
  display: grid;
  grid-template-rows: auto auto minmax(280px, 1fr) auto auto;
  gap: 12px;
  min-height: 100vh;
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(10, 16, 25, 0.72), rgba(18, 25, 35, 0.18)),
    linear-gradient(135deg, #1d4ed8, #f1b332 48%, #e13f3f);
}

.topbar,
.hud,
.question-panel,
.event-strip {
  width: min(1280px, 100%);
  margin: 0 auto;
}

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

.room-pill {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 8px;
  padding: 0 14px;
  color: white;
  background: rgba(15, 23, 42, 0.72);
}

.room-pill strong {
  color: #ffdf75;
}

.hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px minmax(0, 1fr);
  gap: 12px;
}

.fighter-card {
  display: grid;
  gap: 8px;
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.94);
}

.fighter-card.right {
  text-align: right;
}

.fighter-card strong,
.fighter-card span {
  display: block;
}

.fighter-card span {
  color: var(--muted);
  font-size: 0.8rem;
}

.health {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #d9e1eb;
}

.health span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 260ms ease;
}

.round-clock {
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: white;
  background: rgba(15, 23, 42, 0.8);
}

.round-clock span {
  font-size: 0.75rem;
  font-weight: 800;
}

.round-clock strong {
  font-size: 2.1rem;
}

.arena-wrap {
  position: relative;
  width: min(1280px, 100%);
  margin: 0 auto;
  min-height: 280px;
  border: 4px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  overflow: hidden;
  background: #0e1726;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: min(48vh, 520px);
}

.waiting-banner {
  position: absolute;
  inset: 18px auto auto 50%;
  transform: translateX(-50%);
  border-radius: 8px;
  padding: 10px 14px;
  color: white;
  background: rgba(15, 23, 42, 0.76);
  font-weight: 800;
  text-align: center;
}

.question-panel {
  display: grid;
  grid-template-columns: 1.1fr 1.5fr;
  gap: 12px;
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.94);
}

.question-text {
  align-self: center;
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 800;
}

.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.option {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.option:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.feedback {
  grid-column: 1 / -1;
  min-height: 22px;
  color: var(--muted);
  font-weight: 700;
}

.event-strip {
  min-height: 40px;
  border-radius: 8px;
  padding: 10px 12px;
  color: white;
  background: rgba(15, 23, 42, 0.72);
  font-weight: 700;
}

@media (max-width: 860px) {
  .lobby {
    grid-template-columns: 1fr;
    padding: 16px 0;
  }

  .character-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hud {
    grid-template-columns: 1fr;
  }

  .round-clock {
    min-height: 76px;
    order: -1;
  }

  .question-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .game {
    padding: 8px;
  }

  .topbar,
  .action-row,
  .options {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .brand-panel,
  .join-panel {
    padding: 20px;
  }
}
