:root {
  color-scheme: dark;
  --bg: #080706;
  --panel: rgba(17, 14, 12, 0.82);
  --panel-strong: rgba(25, 20, 17, 0.94);
  --text: #f6eee4;
  --muted: #b9a99a;
  --steel: #c6cbd0;
  --blood: #9b1d22;
  --ember: #d18a38;
  --line: rgba(246, 238, 228, 0.16);
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.52);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #080706;
  color: var(--text);
}

body {
  background:
    linear-gradient(rgba(8, 7, 6, 0.68), rgba(8, 7, 6, 0.9)),
    url("assets/images/cover.jpg") center / cover fixed;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  position: relative;
  width: min(100vw, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 0%, rgba(209, 138, 56, 0.18), transparent 34%),
    linear-gradient(180deg, rgba(10, 8, 7, 0.78), rgba(7, 6, 5, 0.96));
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.72);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
}

.screen.is-active {
  display: flex;
}

.loading-screen,
.start-screen,
.game-over-screen {
  flex-direction: column;
  justify-content: center;
}

.brand-mark {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 18px;
  right: 18px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--muted);
}

.loading-card,
.result-panel,
.score-block {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.loading-card {
  padding: 22px;
}

.progress {
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(198, 203, 208, 0.34);
  background: rgba(0, 0, 0, 0.38);
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--blood), var(--ember), var(--steel));
  transition: width 180ms ease;
}

.asset-list {
  display: none;
}

.cover-haze {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(8, 7, 6, 0.58) 44%, rgba(8, 7, 6, 0.95)),
    url("assets/images/cover.jpg") center top / cover;
  filter: saturate(0.82) contrast(1.08);
}

.hero {
  position: relative;
  z-index: 1;
  align-self: stretch;
  margin-top: auto;
  padding-bottom: 9dvh;
  text-align: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--ember);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 800;
  font-size: 0.72rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.55rem, 12vw, 4.4rem);
  line-height: 0.9;
  text-transform: uppercase;
  text-wrap: balance;
}

h2 {
  margin-bottom: 0;
  font-size: 1.45rem;
  line-height: 1.1;
}

h3 {
  margin-bottom: 12px;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.tagline {
  max-width: 15rem;
  margin: 0 auto 18px;
  color: var(--steel);
  font-size: 1.1rem;
  font-weight: 700;
}

.music-choice {
  display: grid;
  gap: 9px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid rgba(246, 238, 228, 0.16);
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(10px);
}

.music-choice p {
  margin: 0;
  color: var(--steel);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
}

.music-choice small {
  color: var(--muted);
  line-height: 1.35;
}

.music-choice-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.music-choice .primary-btn,
.music-choice .ghost-btn {
  min-height: 40px;
  padding: 0 10px;
  font-size: 0.72rem;
}

.music-choice.is-set {
  border-color: rgba(209, 138, 56, 0.5);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}


.field-error {
  min-height: 1rem;
  color: #f0a35d;
  font-size: 0.74rem;
  text-transform: none;
  letter-spacing: 0;
}

.field input.is-invalid {
  border-color: rgba(209, 138, 56, 0.92);
  box-shadow: 0 0 0 2px rgba(209, 138, 56, 0.16);
}

.primary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none;
}

.field input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(246, 238, 228, 0.24);
  border-radius: 0;
  outline: 0;
  background: rgba(0, 0, 0, 0.48);
  color: var(--text);
  font-size: 1rem;
  text-transform: none;
  letter-spacing: 0;
}

.primary-btn,
.ghost-btn,
.hud-btn {
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid transparent;
  color: var(--text);
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.primary-btn {
  width: 100%;
  background: linear-gradient(135deg, #8f171d, #d18a38);
  box-shadow: 0 12px 28px rgba(155, 29, 34, 0.32);
}

.ghost-btn,
.hud-btn {
  background: rgba(0, 0, 0, 0.42);
  border-color: rgba(246, 238, 228, 0.2);
}

.character-screen {
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

.topline {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
}

.topline .ghost-btn {
  min-height: 40px;
}

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

.character-card {
  position: relative;
  min-height: 214px;
  overflow: hidden;
  border: 1px solid rgba(246, 238, 228, 0.14);
  background:
    linear-gradient(180deg, rgba(26, 19, 15, 0.7), rgba(7, 6, 5, 0.96)),
    url("assets/backgrounds/arena-bg.png") center / cover;
  color: var(--text);
  text-align: left;
}

.character-card img {
  position: absolute;
  inset: 8px 8px 34px;
  width: calc(100% - 16px);
  height: calc(100% - 42px);
  object-fit: contain;
  object-position: center bottom;
  filter: saturate(0.95) contrast(1.04);
  transition: transform 180ms ease;
}

.character-card span {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  padding: 9px 10px;
  background: rgba(0, 0, 0, 0.62);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.character-card:focus-visible,
.primary-btn:focus-visible,
.ghost-btn:focus-visible,
.hud-btn:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}

.character-card:active img {
  transform: scale(1.04);
}

.game-screen {
  padding: 0;
  background: #060504;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100dvh;
  touch-action: none;
}

.hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: stretch;
  pointer-events: none;
}

.hud > div,
.hud-btn {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(246, 238, 228, 0.14);
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(10px);
}

.hud-btn {
  min-height: 0;
  pointer-events: auto;
  font-size: 0.7rem;
}

.hud-label {
  display: block;
  color: var(--muted);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hud strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.15rem;
}

.touch-zones {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  pointer-events: none;
}

.touch-zones span:first-child {
  border-right: 1px solid rgba(246, 238, 228, 0.04);
}

.result-panel {
  padding: 22px;
}

.game-over-screen {
  gap: 14px;
  overflow-y: auto;
  justify-content: flex-start;
  padding-top: max(22px, env(safe-area-inset-top));
}

.final-score {
  margin-bottom: 4px;
  font-size: 1.35rem;
  font-weight: 900;
}

.final-score span {
  color: var(--ember);
}

.final-character,
.share-status,
.api-status,
.rank-status {
  color: var(--muted);
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.scores {
  display: grid;
  gap: 12px;
  width: min(100%, 420px);
  margin: 0 auto;
}

.score-block {
  padding: 16px;
}

.rank-block {
  border-color: rgba(209, 138, 56, 0.42);
  background: rgba(209, 138, 56, 0.08);
}

.rank-status {
  margin: 0;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 850;
}

.score-block ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 24px;
}

.score-block li {
  color: var(--steel);
}

.score-block small {
  color: var(--muted);
}

@media (min-width: 720px) {
  body {
    display: grid;
    place-items: center;
  }

  .shell {
    min-height: min(100dvh, 900px);
    aspect-ratio: 9 / 16;
  }

  .screen {
    min-height: 100%;
  }

  #gameCanvas {
    height: 100%;
  }
}

.spotify-player {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 4;
  display: none;
  height: 82px;
  overflow: hidden;
  border: 1px solid rgba(246, 238, 228, 0.14);
  background: rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.spotify-player.is-visible {
  display: block;
}

.spotify-player iframe {
  display: block;
  width: 100%;
  height: 82px;
  border: 0;
}

.spotify-consent {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 4, 3, 0.72);
  backdrop-filter: blur(12px);
}

.spotify-consent[hidden] {
  display: none;
}

.spotify-consent-panel {
  width: min(100%, 440px);
  padding: 22px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.spotify-consent-panel p {
  color: var(--steel);
  line-height: 1.45;
}

.text-btn {
  display: block;
  margin: 14px auto 0;
  padding: 8px 10px;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
}

.spotify-login-link {
  display: block;
  margin-top: 14px;
  color: var(--ember);
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
}

.spotify-login-link:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 3px;
}

.spotify-actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.spotify-actions .text-btn {
  margin-top: 0;
}

.spotify-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.spotify-status {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--ember);
  font-size: 0.88rem;
  font-weight: 750;
}
