:root {
  color-scheme: dark;
  --ink: #08090a;
  --paper: #f3efe4;
  --paper-dim: #cbc4b4;
  --cyan: #00e7ff;
  --magenta: #ff3f9a;
  --amber: #ffb23d;
  --lime: #9aff2f;
  --white: #fffaf0;
  --panel: rgba(8, 9, 10, 0.56);
  --line: rgba(255, 250, 240, 0.78);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
}

body {
  color: var(--white);
}

button {
  font: inherit;
}

#game-shell {
  position: relative;
  width: 100vw;
  height: 100svh;
  min-height: 520px;
  overflow: hidden;
  background:
    linear-gradient(115deg, rgba(243, 239, 228, 0.08), transparent 36%),
    radial-gradient(circle at 70% 48%, rgba(0, 231, 255, 0.18), transparent 24%),
    var(--ink);
  isolation: isolate;
}

#scene-root,
#scene-root canvas,
#ink-fx,
#paper-fold,
#speed-vignette {
  position: absolute;
  inset: 0;
}

#scene-root canvas,
#ink-fx {
  width: 100%;
  height: 100%;
  display: block;
}

#ink-fx,
#paper-fold,
#speed-vignette {
  pointer-events: none;
}

#ink-fx {
  z-index: 2;
  mix-blend-mode: screen;
}

#paper-fold {
  z-index: 3;
  opacity: 0;
  transform: perspective(900px) rotateY(0deg) scaleX(0.96);
  background:
    linear-gradient(90deg, rgba(8, 9, 10, 0) 0 16%, rgba(255, 250, 240, 0.44) 50%, rgba(8, 9, 10, 0) 84%),
    repeating-linear-gradient(90deg, rgba(8, 9, 10, 0.34) 0 1px, transparent 1px 26px);
}

#game-shell.is-switching #paper-fold {
  animation: fold-sweep 760ms cubic-bezier(0.2, 0.82, 0.18, 1) both;
}

#speed-vignette {
  z-index: 1;
  background:
    radial-gradient(ellipse at center, transparent 42%, rgba(8, 9, 10, 0.36) 72%, rgba(8, 9, 10, 0.82) 100%),
    linear-gradient(90deg, rgba(255, 250, 240, 0.12), transparent 18% 82%, rgba(255, 178, 61, 0.12));
  mix-blend-mode: multiply;
}

.hud {
  position: absolute;
  z-index: 4;
  display: flex;
  align-items: center;
  pointer-events: none;
}

.hud-top {
  top: clamp(14px, 2.2vw, 26px);
  left: clamp(14px, 2.4vw, 32px);
  right: clamp(14px, 2.4vw, 32px);
  justify-content: space-between;
  gap: 16px;
}

.brand-lockup {
  display: grid;
  grid-template-columns: 38px auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 250, 240, 0.76);
  border-radius: 8px;
  background:
    linear-gradient(135deg, transparent 0 42%, var(--cyan) 43% 47%, transparent 48%),
    linear-gradient(45deg, var(--magenta), transparent 48% 52%, var(--amber));
  box-shadow:
    0 0 22px rgba(0, 231, 255, 0.28),
    inset 0 0 0 1px rgba(8, 9, 10, 0.52);
}

.kicker,
h1,
.meter-label,
.mode-button span {
  margin: 0;
  letter-spacing: 0;
  line-height: 1;
}

.kicker {
  font-size: clamp(0.68rem, 1.4vw, 0.78rem);
  color: rgba(255, 250, 240, 0.68);
  font-weight: 700;
}

h1 {
  margin-top: 4px;
  font-size: clamp(1.3rem, 3vw, 2.4rem);
  font-weight: 900;
  color: var(--white);
}

.status-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: min(54vw, 430px);
  justify-content: flex-end;
}

.meter-block {
  width: min(46vw, 320px);
  padding: 10px 12px;
  border: 1px solid rgba(255, 250, 240, 0.2);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(16px);
}

.meter-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: rgba(255, 250, 240, 0.78);
  font-size: 0.72rem;
  font-weight: 800;
}

.meter-track {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.16);
}

.meter-track span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--magenta), var(--amber), var(--lime));
  box-shadow: 0 0 24px rgba(255, 63, 154, 0.58);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 250, 240, 0.26);
  border-radius: 8px;
  color: var(--white);
  background: rgba(8, 9, 10, 0.56);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(16px);
  pointer-events: auto;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
  touch-action: manipulation;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: rgba(0, 231, 255, 0.82);
  background: rgba(0, 231, 255, 0.16);
  outline: none;
  transform: translateY(-1px);
}

.icon-button:active {
  transform: translateY(1px) scale(0.98);
}

.icon-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mode-button {
  grid-template-columns: 24px auto;
  width: auto;
  min-width: 86px;
  padding: 0 13px;
  gap: 8px;
}

.mode-button span {
  min-width: 2ch;
  font-size: 0.78rem;
  font-weight: 900;
}

.hud-bottom {
  right: clamp(14px, 2.4vw, 32px);
  bottom: clamp(16px, 4vw, 34px);
  flex-direction: column;
  gap: 8px;
}

.drive-button {
  width: clamp(46px, 10vw, 58px);
  height: clamp(46px, 10vw, 58px);
}

.switch-button {
  border-color: rgba(255, 178, 61, 0.46);
}

@keyframes fold-sweep {
  0% {
    opacity: 0;
    transform: perspective(900px) rotateY(-80deg) scaleX(0.2);
  }
  22% {
    opacity: 0.9;
  }
  52% {
    opacity: 0.7;
    transform: perspective(900px) rotateY(8deg) scaleX(1.04);
  }
  100% {
    opacity: 0;
    transform: perspective(900px) rotateY(82deg) scaleX(0.2);
  }
}

@media (max-width: 700px) {
  #game-shell {
    min-height: 460px;
  }

  .hud-top {
    align-items: flex-start;
  }

  .brand-lockup {
    grid-template-columns: 30px auto;
    gap: 8px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 7px;
  }

  .status-cluster {
    min-width: 0;
    gap: 8px;
  }

  .meter-block {
    width: min(46vw, 210px);
    padding: 8px;
  }

  .mode-button {
    min-width: 62px;
    padding: 0 9px;
  }
}
