:root {
  color-scheme: dark;
  --ink: #f6f7fb;
  --muted: #9aa6ba;
  --panel: rgba(13, 20, 34, .88);
  --line: rgba(255, 255, 255, .12);
  --crimson: #e03b4f;
  --crimson-deep: #8f1834;
  --gold: #ffd76a;
  --night: #080d18;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--night);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 0%, rgba(178, 27, 63, .22), transparent 34rem),
    radial-gradient(circle at 85% 110%, rgba(33, 93, 128, .2), transparent 38rem),
    linear-gradient(145deg, #0b101d 0%, #050810 100%);
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.game-app {
  width: min(100%, 1500px);
  margin: 0 auto;
  padding: 18px clamp(12px, 2.6vw, 38px) max(18px, env(safe-area-inset-bottom));
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}

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

.brand-orb {
  position: relative;
  width: 46px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 15px;
  background: linear-gradient(145deg, #ec4457, #7d102a);
  box-shadow: 0 8px 28px rgba(191, 31, 65, .32), inset 0 1px rgba(255, 255, 255, .35);
}

.brand-orb::before,
.brand-orb::after,
.brand-orb span {
  content: "";
  width: 4px;
  border-radius: 99px;
  background: white;
  box-shadow: 0 0 10px rgba(255, 255, 255, .45);
}

.brand-orb::before {
  height: 12px;
  transform: translateX(-8px);
}

.brand-orb span {
  height: 23px;
  position: absolute;
}

.brand-orb::after {
  height: 16px;
  transform: translateX(8px);
}

.identity p,
.identity h1 {
  margin: 0;
}

.identity p {
  color: #f06a77;
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: .17em;
}

.identity h1 {
  margin-top: 2px;
  font-size: clamp(1.05rem, 2vw, 1.32rem);
  line-height: 1;
  letter-spacing: -.02em;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.utility-btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  color: #dfe5ee;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .055);
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.utility-btn:hover {
  background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .22);
}

.utility-btn:active {
  transform: translateY(1px);
}

.utility-btn[aria-pressed="true"] {
  color: white;
  border-color: rgba(224, 59, 79, .55);
  background: rgba(224, 59, 79, .2);
}

.hud {
  display: grid;
  grid-template-columns: .7fr .8fr 1.35fr 1.35fr;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  overflow: hidden;
  background: rgba(6, 11, 21, .88);
  backdrop-filter: blur(14px);
}

.hud-item {
  min-width: 0;
  padding: 11px 16px 10px;
  border-right: 1px solid var(--line);
}

.hud-item:last-child {
  border-right: 0;
}

.hud-label {
  display: block;
  margin-bottom: 2px;
  color: #7d899c;
  font-size: .68rem;
  font-weight: 850;
  letter-spacing: .14em;
}

.hud-value {
  display: block;
  overflow: hidden;
  color: #edf1f7;
  font-size: .93rem;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-value.gold {
  color: var(--gold);
}

.lives .hud-value {
  color: #ff5366;
  letter-spacing: .12em;
}

.game-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 0 0 22px 22px;
  background: #111a25;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .52);
  isolation: isolate;
}

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

#gameCanvas:focus-visible {
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .75);
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, transparent 48%, rgba(3, 6, 12, .25) 100%);
  box-shadow: inset 0 0 90px rgba(0, 0, 0, .28);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 54px);
  background: linear-gradient(90deg, rgba(3, 7, 14, .93) 0%, rgba(3, 7, 14, .8) 46%, rgba(3, 7, 14, .25) 100%);
  transition: opacity .32s ease, visibility .32s ease;
}

.overlay:not(.active) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-card {
  width: min(630px, 100%);
  justify-self: start;
}

.overlay-card.compact {
  justify-self: center;
  text-align: center;
}

.kicker {
  margin: 0 0 10px;
  color: #f36673;
  font-size: clamp(.68rem, 1.4vw, .82rem);
  font-weight: 900;
  letter-spacing: .18em;
}

.overlay h2 {
  margin: 0;
  font-size: clamp(2.05rem, 5.4vw, 4.8rem);
  line-height: .96;
  letter-spacing: -.055em;
  text-wrap: balance;
}

.overlay h2 span {
  color: #f05667;
}

.overlay-card > p:not(.kicker):not(.desktop-help) {
  max-width: 560px;
  margin: 20px 0;
  color: #c4ccd8;
  font-size: clamp(.92rem, 1.7vw, 1.1rem);
  line-height: 1.55;
}

.milestones {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0 24px;
}

.milestones span {
  padding: 8px 12px;
  color: #e9edf4;
  font-size: .82rem;
  font-weight: 720;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
}

.milestones b {
  margin-right: 5px;
  color: var(--gold);
}

.play-button {
  min-height: 50px;
  padding: 0 20px;
  color: white;
  font-weight: 900;
  letter-spacing: .04em;
  border: 1px solid #f06b78;
  border-radius: 14px;
  background: linear-gradient(135deg, #e34155, #9f1735);
  box-shadow: 0 12px 32px rgba(181, 26, 60, .42), inset 0 1px rgba(255, 255, 255, .3);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.play-button span {
  margin-left: 12px;
}

.desktop-help {
  margin: 16px 0 0;
  color: #8994a6;
  font-size: .76rem;
  font-weight: 650;
}

.result {
  background: rgba(4, 8, 15, .86);
  backdrop-filter: blur(10px);
}

.result[hidden] {
  display: none;
}

.toast {
  position: absolute;
  left: 50%;
  top: 18%;
  z-index: 7;
  max-width: min(90%, 560px);
  padding: 11px 16px;
  color: white;
  font-size: .88rem;
  font-weight: 800;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px;
  background: rgba(5, 10, 19, .88);
  box-shadow: 0 12px 38px rgba(0, 0, 0, .35);
  opacity: 0;
  transform: translate(-50%, -10px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.mobile-controls {
  display: none;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
}

.direction-pad,
.action-pad {
  display: flex;
  gap: 10px;
}

.control-btn {
  width: 62px;
  height: 56px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 1.35rem;
  font-weight: 900;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 17px;
  background: rgba(255, 255, 255, .08);
  box-shadow: inset 0 1px rgba(255, 255, 255, .12);
  touch-action: none;
  user-select: none;
}

.control-btn:active,
.control-btn.pressed {
  background: rgba(255, 255, 255, .18);
  transform: translateY(2px);
}

.control-btn.jump {
  border-color: rgba(224, 59, 79, .55);
  background: rgba(190, 34, 65, .25);
}

.control-btn.attack:disabled {
  opacity: .34;
}

.control-btn.attack:not(:disabled) {
  color: #251b00;
  border-color: #ffe39a;
  background: linear-gradient(145deg, #ffe492, #d69a23);
}

.game-notes {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 4px 0;
  color: #7f8b9d;
  font-size: .8rem;
  line-height: 1.45;
}

.game-notes p {
  margin: 0;
}

.status-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 7px;
  border-radius: 50%;
  background: #50d68b;
  box-shadow: 0 0 10px rgba(80, 214, 139, .7);
}

@media (pointer: coarse), (max-width: 900px) {
  .game-app {
    padding-top: 10px;
  }

  .mobile-controls {
    display: flex;
  }

  .desktop-help {
    display: none;
  }

  .game-notes {
    display: none;
  }
}

@media (max-width: 720px) {
  .topbar {
    min-height: 54px;
    margin-bottom: 8px;
  }

  .brand-orb {
    width: 39px;
    border-radius: 12px;
  }

  .identity p {
    font-size: .6rem;
  }

  .identity h1 {
    font-size: 1rem;
  }

  .utility-btn {
    min-width: 42px;
    padding: 0 10px;
  }

  .utility-btn span:last-child {
    display: none;
  }

  .hud {
    grid-template-columns: .72fr .78fr 1.5fr;
    border-radius: 14px 14px 0 0;
  }

  .hud-item {
    padding: 8px 9px 7px;
  }

  .power-cell {
    display: none;
  }

  .hud-label {
    font-size: .55rem;
  }

  .hud-value {
    font-size: .74rem;
  }

  .game-frame {
    border-radius: 0 0 16px 16px;
  }

  .overlay {
    padding: 13px 18px;
  }

  .overlay h2 {
    font-size: clamp(1.55rem, 8vw, 2.7rem);
  }

  .overlay-card > p:not(.kicker):not(.desktop-help) {
    margin: 10px 0;
    font-size: .77rem;
    line-height: 1.4;
  }

  .milestones {
    margin: 10px 0 12px;
  }

  .milestones span {
    padding: 5px 8px;
    font-size: .65rem;
  }

  .play-button {
    min-height: 39px;
    padding: 0 14px;
    font-size: .74rem;
    border-radius: 11px;
  }
}

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

  .season-cell .hud-value {
    max-width: 31vw;
  }

  .mobile-controls {
    padding-inline: 5px;
  }

  .control-btn {
    width: 58px;
    height: 54px;
  }

  .overlay h2 br {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}
