:root {
  --bg-1: #030712;
  --bg-2: #071425;
  --panel: #1f2937;
  --ink: #e5e7eb;
  --muted: #9ca3af;
  --accent: #ef4444;
  --accent-2: #22d3ee;
  --ok: #22c55e;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: 'Orbitron', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 20% 20%, rgba(34, 211, 238, 0.22), transparent 70%),
    radial-gradient(1000px 500px at 80% 0%, rgba(15, 118, 110, 0.18), transparent 70%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2));
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.app {
  width: min(1280px, 100%);
  flex: 1;
  margin: 0 auto;
  padding: 16px;
  min-height: 0;
  display: flex;
}

.site-footer {
  flex: 0 0 auto;
  padding: 0 16px 12px;
  text-align: center;
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-footer a:hover {
  color: var(--accent-2);
}

.screen {
  display: none;
  min-height: 0;
  width: 100%;
}

.screen.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#character-select {
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  padding: 28px 16px 16px;
  min-height: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.subtitle {
  margin: 8px 0 24px;
  color: var(--muted);
}

.mode-switch {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.mode-option {
  background: #111827;
  color: var(--ink);
  border: 1px solid #334155;
  min-width: 160px;
}

.mode-option.active {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px #22d3ee33;
}

.hidden {
  display: none !important;
}

.online-panel {
  max-width: 980px;
  margin: 0 auto 20px;
  width: 100%;
}

.room-card {
  background: linear-gradient(180deg, #111827, #0b1220);
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 16px;
  text-align: left;
}

.room-title {
  font-size: 0.95rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.room-status {
  margin: 0 0 14px;
  color: var(--muted);
}

.room-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

.room-inline {
  justify-content: space-between;
}

.room-input {
  flex: 1 1 220px;
  min-width: 180px;
  border: 1px solid #334155;
  background: #020617;
  color: var(--ink);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.room-input::placeholder {
  color: #64748b;
}

.room-code-wrap {
  display: grid;
  gap: 4px;
}

.room-label {
  color: var(--muted);
  font-size: 0.78rem;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(110px, 12vw, 170px), 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 10px;
  margin: 0 auto 20px;
  max-width: 980px;
  width: 100%;
  flex: 1;
  min-height: 0;
}

.character-card {
  background: linear-gradient(180deg, #111827, #0b1220);
  border: 2px solid #334155;
  border-radius: 12px;
  padding: 8px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  cursor: pointer;
  transition: 0.2s ease;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.character-card:hover,
.character-card.selected {
  transform: translateY(-2px);
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px #22d3ee33;
}

.character-card.selected-player {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px #22d3ee55;
}

.character-card.selected-cpu {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #ef444455;
}


.character-card .character-sprite,
.character-card canvas.character-sprite,
.character-preview {
  width: 100%;
  display: block;
  flex: none;
  min-height: 0;
  height: 100%;
  object-fit: contain;
  background: #020617;
  border-radius: 8px;
}

.character-preview {
  display: grid;
  place-items: center;
  color: #475569;
  font-weight: 900;
}

.card-title {
  margin: 0;
  align-self: end;
  justify-self: center;
  width: 100%;
  font-weight: 700;
  font-size: clamp(0.7rem, 0.85vw, 0.98rem);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  padding: 0 4px 2px;
}

button {
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 10px;
  border: none;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
}

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

.primary {
  background: linear-gradient(90deg, var(--accent), #f97316);
  color: #fff;
}

.secondary {
  margin-top: 12px;
  background: #1f2937;
  color: var(--ink);
  border: 1px solid #334155;
}

.hint {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

#fight-screen.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  min-height: 0;
}

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  background: #020617cc;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 10px 14px;
}

.player-side .name {
  font-size: 0.95rem;
  margin-bottom: 5px;
}

.player-side.right {
  text-align: right;
}

.bar {
  width: 100%;
  height: 20px;
  background: #334155;
  border-radius: 99px;
  overflow: hidden;
}

.fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #84cc16);
  transition: width 0.2s linear;
}

.fill.enemy {
  background: linear-gradient(90deg, #f97316, #ef4444);
}

.rounds {
  min-height: 12px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.round-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #64748b;
  display: inline-block;
  margin-right: 5px;
}

.round-dot.win {
  background: #facc15;
  border-color: #facc15;
}

.round-learning {
  color: #cbd5e1;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.center-info {
  text-align: center;
}

.label {
  color: var(--muted);
  font-size: 0.75rem;
}

.value {
  font-size: 1.2rem;
  font-weight: 900;
}

.timer {
  margin-top: 3px;
  font-size: 1.2rem;
  color: var(--accent-2);
}

.arena-wrap {
  position: relative;
  margin-top: 12px;
  min-height: 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  width: 100%;
  height: 100%;
  max-height: 100%;
  background: linear-gradient(#1e293b, #0f172a);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 14px;
  border: 1px solid #334155;
  display: block;
  object-fit: contain;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(1.4rem, 3vw, 2.6rem);
  font-weight: 900;
  text-shadow: 0 4px 20px #000;
  color: #f8fafc;
  pointer-events: none;
}

.touch-controls {
  display: none;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.9), rgba(2, 6, 23, 0.88));
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(10px);
}

.touch-cluster {
  display: grid;
  gap: 10px;
}

.touch-cluster.movement {
  grid-template-columns: repeat(2, minmax(64px, 1fr));
  align-self: stretch;
}

.touch-cluster.actions {
  justify-items: center;
  min-width: 42%;
  gap: 12px;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(56px, 1fr));
  gap: 12px;
  width: 100%;
}

.touch-btn {
  min-height: 60px;
  min-width: 60px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #334155, #0f172a 72%);
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 18px rgba(15, 23, 42, 0.35);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.touch-btn:active,
.touch-btn.is-pressed {
  border-color: #22d3ee;
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transform: translateY(1px) scale(0.98);
}

.touch-btn.dpad-left,
.touch-btn.dpad-right {
  min-width: 72px;
  background: linear-gradient(180deg, #1e293b, #0f172a);
}

.touch-btn.action-jump {
  min-width: 72px;
  min-height: 72px;
}

.touch-btn.action-hit,
.touch-btn.action-kick {
  min-width: 64px;
  min-height: 64px;
}

.touch-btn.dpad-left {
  border-radius: 20px 12px 12px 20px;
}

.touch-btn.dpad-right {
  border-radius: 12px 20px 20px 12px;
}

@media (min-width: 901px) {
  #character-select {
    padding: 28px 24px 18px;
  }

  .character-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    max-width: 1240px;
    margin: 0 auto 20px;
  }

  .character-card {
    padding: 10px 12px;
    min-height: 180px;
  }

  .character-card .character-sprite,
  .character-card canvas.character-sprite,
  .character-preview {
    height: 100%;
  }

  .card-title {
    font-size: 0.92rem;
  }
}

@media (min-width: 1440px) {
  .character-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    max-width: 1360px;
  }

  .character-card {
    min-height: 190px;
    padding: 12px 14px;
  }

  .character-card .character-sprite,
  .character-card canvas.character-sprite,
  .character-preview {
    height: 100%;
  }

  .card-title {
    font-size: 0.98rem;
    letter-spacing: 0.04em;
  }
}

@media (max-width: 900px) {
  .app {
    padding: 12px;
  }

  #character-select {
    padding: 16px 12px 12px;
    gap: 12px;
  }

  .character-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
  }

  .hud {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 8px;
    padding: 8px 10px;
  }

  .player-side {
    min-width: 0;
  }

  .player-side .name {
    font-size: 0.74rem;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bar {
    height: 10px;
  }

  .rounds {
    min-height: 10px;
    margin-top: 4px;
  }

  .round-dot {
    width: 9px;
    height: 9px;
    margin-right: 4px;
  }

  .round-learning {
    font-size: 0.6rem;
  }

  .center-info {
    align-self: center;
  }

  .label {
    font-size: 0.64rem;
  }

  .value,
  .timer {
    font-size: 0.96rem;
  }

  .arena-wrap {
    margin-top: 0;
    min-height: 0;
  }

  canvas {
    aspect-ratio: 1200 / 620;
  }

  .player-side.right {
    text-align: right;
  }
}

@media (max-width: 600px) {
  .app {
    padding: 10px 8px;
  }

  #character-select {
    padding: 12px 8px 8px;
    gap: 10px;
  }

  .mode-switch {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }

  .mode-option {
    min-width: 0;
    width: 100%;
  }

  .online-panel {
    max-width: 100%;
    margin: 0 0 16px;
  }

  .room-card {
    padding: 14px;
  }

  .room-row {
    flex-direction: column;
    align-items: stretch;
  }

  .room-row > * {
    width: 100%;
  }

  .character-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    max-width: 100%;
  }

  .character-card {
    padding: 6px 4px;
    min-height: 0;
  }

  .character-card .character-sprite,
  .character-card canvas.character-sprite,
  .character-preview {
    height: 100%;
  }

  .card-title {
    font-size: 0.52rem;
    line-height: 0.95;
  }

  #start-fight {
    width: 100%;
  }

  .hint {
    font-size: 0.8rem;
    margin-top: 6px;
  }

  .touch-controls {
    width: 100%;
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .touch-cluster.movement {
    grid-template-columns: repeat(2, minmax(52px, 1fr));
  }

  .touch-cluster.actions {
    justify-items: stretch;
    gap: 12px;
  }

  .touch-btn {
    min-width: 52px;
    min-height: 52px;
  }
}

@media (max-width: 600px) and (orientation: portrait) {
  .character-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .character-card {
    padding: 6px 4px;
  }

  .character-card .character-sprite,
  .character-card canvas.character-sprite,
  .character-preview {
    height: 100%;
  }

  .card-title {
    font-size: 0.5rem;
    line-height: 0.95;
  }
}

@media (max-height: 720px) and (orientation: landscape) {
  .app {
    padding: 10px;
  }

  #character-select {
    padding: 10px 8px 8px;
    gap: 8px;
    justify-content: flex-start;
  }

  h1 {
    font-size: clamp(1.5rem, 3vw, 2.4rem);
  }

  .subtitle {
    margin: 4px 0 12px;
  }

  .mode-switch {
    margin-bottom: 10px;
  }

  .online-panel {
    margin-bottom: 12px;
  }

  .room-card {
    padding: 12px;
  }

  .character-grid {
    gap: 8px;
    margin-bottom: 12px;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .character-card {
    padding: 6px;
  }

  .character-card .character-sprite,
  .character-card canvas.character-sprite,
  .character-preview {
    height: 100%;
  }

  .card-title {
    font-size: 0.62rem;
  }

  .hint {
    margin-top: 8px;
    font-size: 0.72rem;
  }

  #fight-screen.active {
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 8px;
  }

  .hud {
    gap: 10px;
    padding: 8px 10px;
  }

  .player-side .name {
    font-size: 0.72rem;
    margin-bottom: 3px;
  }

  .bar {
    height: 10px;
  }

  .rounds {
    margin-top: 3px;
    min-height: 8px;
    gap: 6px;
  }

  .round-dot {
    width: 8px;
    height: 8px;
    margin-right: 3px;
  }

  .round-learning {
    font-size: 0.56rem;
  }

  .label,
  .value,
  .timer {
    font-size: 0.8rem;
  }

  .arena-wrap {
    margin-top: 0;
  }

  .touch-controls {
    margin-top: 8px;
    padding: 10px 12px;
    width: min(460px, 100%);
  }

  .touch-cluster.movement {
    grid-template-columns: repeat(2, minmax(52px, 1fr));
  }

  .touch-cluster.actions {
    gap: 10px;
  }

  .action-row {
    gap: 8px;
  }

  .touch-btn {
    min-width: 50px;
    min-height: 50px;
  }

  .touch-btn.action-jump {
    min-width: 60px;
    min-height: 60px;
  }

  .touch-btn.action-hit,
  .touch-btn.action-kick {
    min-width: 54px;
    min-height: 54px;
  }
}

@media (pointer: coarse), (max-width: 900px) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .app {
    padding-bottom: 8px;
  }

  .touch-controls {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    width: min(520px, 100%);
    margin: 12px auto 0;
  }

  canvas {
    min-height: 0;
  }

  .touch-cluster.movement {
    grid-template-columns: repeat(2, minmax(60px, 1fr));
  }

  .touch-cluster.actions {
    min-width: 0;
    gap: 14px;
  }

  .action-row {
    grid-template-columns: repeat(2, minmax(56px, 1fr));
    gap: 10px;
  }

  .touch-btn {
    min-height: 56px;
    min-width: 56px;
  }

  .touch-btn.action-jump {
    min-width: 66px;
    min-height: 66px;
  }

  .touch-btn.action-hit,
  .touch-btn.action-kick {
    min-width: 58px;
    min-height: 58px;
  }
}

.marketing,
.llm-briefing,
.faq {
  padding: 48px 16px 64px;
  background: rgba(15, 23, 42, 0.65);
}

.marketing__container,
.llm-briefing__container,
.faq__container {
  width: min(1200px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.marketing__intro {
  display: grid;
  gap: 20px;
  text-align: left;
}

.marketing__eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.75rem;
  color: var(--accent-2);
  margin: 0;
}

.marketing__intro h2 {
  font-size: clamp(2rem, 4vw, 3.25rem);
  margin: 0;
}

.marketing__intro p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.marketing__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
}

.cta-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 28px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cta-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(239, 68, 68, 0.35);
}

.cta-button.cta-secondary {
  background: transparent;
  border-color: var(--accent-2);
  color: var(--accent-2);
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.4) inset;
}

.cta-button.cta-secondary:hover {
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.6) inset;
}

.marketing__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.marketing-card {
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 20px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 16px 40px rgba(2, 6, 23, 0.45);
}

.marketing-card h3 {
  font-size: 1.25rem;
  margin: 0;
}

.marketing-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.marketing-list {
  margin: 0;
  padding-left: 20px;
  color: var(--ink);
  display: grid;
  gap: 8px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.marketing__facts {
  background: rgba(8, 18, 35, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 20px;
  padding: 32px;
}

.marketing__facts h3 {
  margin: 0 0 20px;
  letter-spacing: 0.14em;
}

.marketing__facts dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 24px;
}

.marketing__facts dt {
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.marketing__facts dd {
  margin: 6px 0 0;
  color: var(--muted);
}

.marketing-card code,
.llm-briefing__list code,
.faq-item code {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  background: rgba(148, 163, 184, 0.16);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--ink);
}

.llm-briefing {
  background: rgba(8, 15, 30, 0.7);
}

.llm-briefing__list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin: 0;
}

.llm-briefing__list dt {
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.llm-briefing__list dd {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.faq {
  background: rgba(6, 11, 25, 0.65);
}

.faq__container {
  gap: 24px;
}

.faq-item {
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 12px 32px rgba(2, 6, 23, 0.36);
}

.faq-item h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.faq-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.faq-item a {
  color: var(--accent-2);
}

.faq-item a:hover {
  text-decoration: underline;
}

@media (max-width: 1100px) {
  .marketing__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

@media (max-width: 720px) {
  .marketing__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .marketing__facts dl {
    grid-template-columns: minmax(0, 1fr);
  }

  .marketing,
  .llm-briefing,
  .faq {
    padding: 40px 16px 48px;
  }
}
