:root {
  color-scheme: dark;
  --ink: #f9f3ff;
  --muted: #bdb3cc;
  --panel: rgba(21, 16, 31, 0.82);
  --panel-strong: rgba(35, 24, 48, 0.94);
  --edge: rgba(255, 255, 255, 0.16);
  --hot: #ff3d8e;
  --kiss: #ff7a45;
  --mint: #28f6c9;
  --blue: #61a8ff;
  --shadow: rgba(0, 0, 0, 0.46);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 26% 10%, rgba(255, 61, 142, 0.28), transparent 30rem),
    radial-gradient(circle at 76% 82%, rgba(40, 246, 201, 0.22), transparent 28rem),
    linear-gradient(138deg, #09070d 0%, #140c1a 42%, #111f28 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at center, black, transparent 78%);
}

button,
input {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.stage {
  width: min(1360px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 330px);
  align-items: center;
  gap: 24px;
}

.play-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.portrait-panel {
  position: relative;
  align-self: stretch;
  min-height: 520px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 26px 90px rgba(0, 0, 0, 0.42),
    0 0 90px rgba(40, 246, 201, 0.16);
}

.portrait-panel::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(9, 7, 13, 0) 54%, rgba(9, 7, 13, 0.38)),
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.1), transparent 18rem);
}

.portrait-panel img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--mint);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 610px;
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.6rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: 10px;
  min-width: min(100%, 410px);
}

.stat {
  min-height: 76px;
  padding: 14px 16px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  box-shadow: 0 18px 60px var(--shadow);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 3px;
  font-size: 2rem;
  line-height: 1;
}

.game-wrap {
  position: relative;
  width: min(78vh, 100%);
  max-width: 760px;
  aspect-ratio: 1;
  justify-self: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  overflow: hidden;
  background: #0a0810;
  box-shadow:
    0 26px 90px rgba(0, 0, 0, 0.5),
    0 0 90px rgba(255, 61, 142, 0.16),
    inset 0 0 36px rgba(255, 255, 255, 0.04);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
  background:
    linear-gradient(rgba(10, 8, 16, 0.54), rgba(10, 8, 16, 0.74)),
    radial-gradient(circle at center, rgba(255, 61, 142, 0.22), transparent 24rem);
  opacity: 1;
  transition: opacity 240ms ease, visibility 240ms ease;
}

.screen.hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.mark {
  display: grid;
  place-items: center;
  width: 74px;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  color: var(--mint);
  font-weight: 900;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 34px rgba(40, 246, 201, 0.25);
}

.screen h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 0.98;
}

.screen p {
  max-width: 470px;
  margin-bottom: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

button,
.toggle,
.speed-group {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

button:hover,
.toggle:hover,
.speed-group:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.13);
}

.speed-group {
  padding: 4px;
  cursor: default;
}

.speed-group span {
  padding: 0 8px 0 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.speed-option {
  min-height: 34px;
  padding: 0 11px;
  border-color: transparent;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
}

.speed-option:hover {
  transform: none;
  border-color: rgba(255, 255, 255, 0.18);
}

.speed-option.active {
  color: #12070c;
  font-weight: 900;
  background: linear-gradient(135deg, var(--mint), var(--blue));
}

.primary {
  min-width: 156px;
  border-color: rgba(255, 122, 69, 0.48);
  color: #14070c;
  font-weight: 900;
  background: linear-gradient(135deg, var(--hot), var(--kiss));
  box-shadow: 0 20px 58px rgba(255, 61, 142, 0.32);
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--hot);
}

@media (max-width: 760px) {
  .shell {
    padding: 18px;
  }

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

  .portrait-panel {
    width: min(100%, 360px);
    min-height: 0;
    aspect-ratio: 0.78;
    justify-self: center;
    order: 2;
  }

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

  .stats {
    min-width: 0;
  }

  .stat {
    min-height: 64px;
    padding: 12px;
  }

  .stat strong {
    font-size: 1.5rem;
  }

  .game-wrap {
    width: 100%;
  }
}

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