:root {
  --aubergine: #2e1a47;
  --magenta: #e5327e;
  --red: #e23a24;
  --cheese: #f5a623;
  --lime: #a8d62c;
  --cream: #f6ebd9;
  --cam: #6b7480;
  --ink: #141018;
  --edge: 10px;
  --vf: clamp(26px, 3.3vmax, 44px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  font-family: "Chakra Petch", "Trebuchet MS", sans-serif;
  color: var(--cream);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 3px;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
}

.world {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

#bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 52%;
  filter: saturate(1.0) brightness(1.0) contrast(1.0) blur(0.1px);
  transform: scale(1.004);
}

.bg-wash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 46% at 66% 40%, rgba(245, 166, 35, 0.06), transparent 70%),
    radial-gradient(130% 105% at 50% 38%, transparent 60%, rgba(20, 16, 24, 0.08) 92%, rgba(20, 16, 24, 0.16) 100%),
    linear-gradient(180deg, rgba(46, 26, 71, 0.03) 0%, transparent 30%, transparent 74%, rgba(20, 16, 24, 0.1) 100%);
}

.grain {
  position: absolute;
  inset: -25%;
  pointer-events: none;
  opacity: 0.1;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.goal {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  transform-origin: 50% 100%;
  transition: transform 0.6s steps(5);
  will-change: transform;
}

.goal img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 0 14px rgba(255, 196, 80, 0.82)) drop-shadow(0 0 48px rgba(245, 166, 35, 0.42));
}

.goal-ground {
  position: absolute;
  z-index: 0;
  left: -15%;
  right: -14%;
  bottom: -8%;
  height: 34%;
  background: radial-gradient(ellipse at 50% 45%, rgba(255, 196, 90, 0.4), rgba(245, 166, 35, 0.16) 40%, rgba(20, 16, 24, 0.5) 66%, transparent 80%);
  filter: blur(4px);
  transform: skewX(-8deg);
  pointer-events: none;
}

.goal-tag {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.goal-tag-plate {
  order: 1;
  padding: 2px 7px;
  background: rgba(20, 16, 24, 0.74);
  border: 1px solid rgba(246, 235, 217, 0.42);
  border-radius: 2px;
  font-family: "Chakra Petch", sans-serif;
  font-size: clamp(6px, 1.05vw, 9px);
  font-weight: 600;
  letter-spacing: 0.1em;
  color: rgba(246, 235, 217, 0.86);
  white-space: nowrap;
  text-shadow: 0 1px 0 #000;
}

.goal-tag-plate b {
  color: var(--cheese);
  font-weight: 700;
}

.goal-tag-stem {
  order: 2;
  width: 1px;
  height: 12px;
  background: rgba(246, 235, 217, 0.5);
}

.goal-glow {
  position: absolute;
  inset: -60% -48%;
  background: radial-gradient(closest-side, rgba(255, 190, 90, 0.55), rgba(245, 166, 35, 0.18) 45%, transparent 72%);
  filter: blur(5px);
  animation: goalBreathe 6.5s ease-in-out infinite;
}

@keyframes goalBreathe {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.07); }
}

#stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
}

.vf {
  position: absolute;
  z-index: 45;
  width: var(--vf);
  height: auto;
  opacity: 0.96;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(20, 16, 24, 0.7));
}

.vf-tl { top: calc(var(--edge) + env(safe-area-inset-top, 0px)); left: calc(var(--edge) + env(safe-area-inset-left, 0px)); transform: rotate(0deg); }
.vf-tr { top: calc(var(--edge) + env(safe-area-inset-top, 0px)); right: calc(var(--edge) + env(safe-area-inset-right, 0px)); transform: rotate(90deg); }
.vf-br { bottom: calc(var(--edge) + env(safe-area-inset-bottom, 0px)); right: calc(var(--edge) + env(safe-area-inset-right, 0px)); transform: rotate(180deg); }
.vf-bl { bottom: calc(var(--edge) + env(safe-area-inset-bottom, 0px)); left: calc(var(--edge) + env(safe-area-inset-left, 0px)); transform: rotate(270deg); }

.ar-frame {
  position: fixed;
  z-index: 44;
  inset: calc(var(--edge) + 4px);
  border: 1px solid rgba(246, 235, 217, 0.22);
  border-radius: 9px;
  pointer-events: none;
}

.ar-frame::before,
.ar-frame::after {
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  height: 5px;
  background: repeating-linear-gradient(90deg, rgba(246, 235, 217, 0.5) 0 1px, transparent 1px 15px);
  opacity: 0.55;
}

.ar-frame::before { top: -1px; }
.ar-frame::after { bottom: -1px; }

.ar-cam {
  position: fixed;
  z-index: 44;
  top: calc(4px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border: 1px solid rgba(246, 235, 217, 0.35);
  border-radius: 2px;
  background: rgba(20, 16, 24, 0.66);
  font-family: "Chakra Petch", sans-serif;
  font-size: clamp(6px, 1.05vw, 8px);
  font-weight: 600;
  letter-spacing: 0.16em;
  color: rgba(246, 235, 217, 0.88);
  white-space: nowrap;
  pointer-events: none;
}

.ar-rec {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 1px rgba(20, 16, 24, 0.6);
  flex: none;
}

.hud {
  position: absolute;
  z-index: 20;
  top: calc(var(--edge) + 14px + env(safe-area-inset-top, 0px));
  left: calc(var(--edge) + 14px + env(safe-area-inset-left, 0px));
  right: calc(var(--edge) + 14px + env(safe-area-inset-right, 0px));
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 8px;
  pointer-events: none;
}

.hud-left {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  filter: drop-shadow(0 4px 10px rgba(20, 16, 24, 0.45));
}

.portrait {
  width: clamp(44px, 5.6vw, 64px);
  aspect-ratio: 1;
  padding: 2px;
  background: #0b0910;
  border: 2px solid #000;
  border-radius: 7px;
  box-shadow: 0 0 0 1px rgba(246, 235, 217, 0.75), 0 4px 0 rgba(0, 0, 0, 0.5);
  overflow: hidden;
  flex: none;
}

.portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 16%;
  border-radius: 4px;
}

.left-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-top: 2px;
}

.lives {
  display: flex;
  align-items: center;
  gap: 2px;
}

.lives img {
  display: block;
  width: clamp(32px, 8.2vw, 52px);
  height: auto;
  filter: drop-shadow(0 2px 0 #000);
  transition: opacity 0.15s;
}

.lives img.lost {
  opacity: 0.62;
  filter: drop-shadow(0 2px 0 #000) saturate(0.2) brightness(0.72);
}

.lives img.pop {
  animation: lifePop 0.3s steps(3);
}

@keyframes lifePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.28) rotate(-5deg); }
  100% { transform: scale(1); }
}

.cam-tag {
  font-size: clamp(6px, 1.4vw, 8px);
  letter-spacing: 0.17em;
  font-weight: 600;
  color: rgba(246, 235, 217, 0.52);
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 2px;
  white-space: nowrap;
}

.cam-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--cream);
  opacity: 0.7;
  flex: none;
}

.hud-title {
  position: absolute;
  top: 1px;
  left: 50%;
  width: clamp(190px, 26vw, 420px);
  transform: translateX(-50%) rotate(-1.4deg);
  filter: drop-shadow(0 5px 0 rgba(0, 0, 0, 0.3));
  pointer-events: none;
}

.hud-title img {
  display: block;
  width: 100%;
  height: auto;
}

.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.score-plate {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: clamp(94px, 11vw, 158px);
  padding: 2px 10px 4px;
  background: #0d0a12;
  border: 2px solid #000;
  border-radius: 5px;
  box-shadow: 0 0 0 1px rgba(246, 235, 217, 0.66), 0 4px 0 rgba(0, 0, 0, 0.55);
}

.score-label {
  font-size: clamp(6px, 1.2vw, 8px);
  letter-spacing: 0.2em;
  color: rgba(246, 235, 217, 0.5);
  line-height: 1.2;
}

#score {
  font-family: "Share Tech Mono", monospace;
  font-size: clamp(18px, 3.1vw, 30px);
  line-height: 1;
  color: var(--cream);
  text-shadow: 0 2px 0 #000;
  letter-spacing: 0.02em;
}

#score.tick {
  animation: scoreTick 0.18s steps(2);
}

@keyframes scoreTick {
  50% { color: var(--cheese); }
}

.combo {
  visibility: hidden;
  opacity: 0;
  padding: 2px 10px 3px;
  background: var(--magenta);
  color: #fff;
  font-family: "Bungee", "Arial Black", sans-serif;
  font-size: clamp(13px, 1.8vw, 19px);
  line-height: 1;
  border: 2px solid #000;
  box-shadow: 0 3px 0 #000;
  transform: rotate(-7deg);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.combo.on {
  visibility: visible;
  opacity: 1;
  animation: comboPop 0.22s steps(2);
}

@keyframes comboPop {
  0% { transform: rotate(-7deg) scale(1.4); }
  100% { transform: rotate(-7deg) scale(1); }
}

.announce {
  position: absolute;
  z-index: 26;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Bungee", "Arial Black", sans-serif;
  font-size: clamp(24px, 5.4vw, 62px);
  line-height: 1;
  color: var(--cheese);
  text-shadow: 3px 3px 0 #000, 7px 7px 0 rgba(0, 0, 0, 0.32);
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}

.announce.show {
  animation: announcePop 1.15s steps(6) forwards;
}

@keyframes announcePop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.7) rotate(-4deg); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
  72% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(1) rotate(-2deg); }
}

.hitflash {
  position: absolute;
  inset: 0;
  z-index: 24;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(95% 85% at 18% 76%, rgba(226, 58, 36, 0.6), transparent 58%);
  transition: opacity 0.22s ease-out;
}

.hitflash.on {
  opacity: 1;
  transition: opacity 0.03s;
}

.controls {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: ". attacks system";
  align-items: end;
  gap: 6px 12px;
  padding: 0 calc(var(--edge) + env(safe-area-inset-right, 0px)) calc(var(--edge) + 12px + env(safe-area-inset-bottom, 0px)) calc(var(--edge) + env(safe-area-inset-left, 0px));
  pointer-events: none;
}

.attack-row {
  grid-area: attacks;
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(5px, 1.2vw, 14px);
  width: min(100%, 560px);
  pointer-events: auto;
}

.atk {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--cream);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.atk-face {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(120% 120% at 34% 22%, #4c2b72 0%, var(--aubergine) 54%, #170c25 100%);
  border: 3px solid var(--ink);
  box-shadow:
    0 0 0 2px var(--accent, var(--cam)),
    0 5px 0 #000,
    inset 0 0 0 3px rgba(0, 0, 0, 0.38);
  overflow: hidden;
  transition: transform 0.06s;
}

.atk-face img {
  position: absolute;
  inset: 7%;
  width: 86%;
  height: 86%;
  object-fit: contain;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.4));
  pointer-events: none;
}

.atk-key {
  position: absolute;
  z-index: 2;
  top: 3%;
  left: 5%;
  min-width: 15px;
  padding: 1px 3px;
  font-family: "Share Tech Mono", monospace;
  font-size: clamp(8px, 1.3vw, 12px);
  line-height: 1.05;
  color: var(--cream);
  background: rgba(20, 16, 24, 0.82);
  border: 1px solid rgba(246, 235, 217, 0.28);
  border-radius: 3px;
  text-align: center;
  pointer-events: none;
}

.atk-cool {
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: 50%;
  background: conic-gradient(rgba(10, 7, 14, 0.8) calc(var(--cool, 0) * 1turn), transparent 0);
  opacity: 0;
  pointer-events: none;
}

.atk.cooling .atk-cool {
  opacity: 1;
}

.atk.cooling .atk-face {
  filter: saturate(0.55) brightness(0.85);
}

.atk-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(9px, 1.6vw, 11px);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  color: rgba(246, 235, 217, 0.82);
  text-shadow: 0 1px 0 #000, 0 2px 0 rgba(0, 0, 0, 0.4);
}

.atk:active .atk-face {
  transform: translateY(3px) scale(0.96);
  box-shadow:
    0 0 0 2px var(--accent, var(--cam)),
    0 2px 0 #000,
    inset 0 0 0 3px rgba(0, 0, 0, 0.38);
}

.atk.no-target .atk-face {
  animation: nope 0.26s steps(3);
}

@keyframes nope {
  0%, 100% { transform: translateX(0); }
  33% { transform: translateX(-4px); }
  66% { transform: translateX(4px); }
}

.commute {
  width: 100%;
  margin-top: 3px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
}

.commute-top {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  font-size: clamp(7px, 1.3vw, 9px);
  font-weight: 600;
  letter-spacing: 0.1em;
  color: rgba(246, 235, 217, 0.68);
  text-shadow: 0 1px 0 #000;
}

.commute-bar {
  position: relative;
  height: 8px;
  background: rgba(20, 16, 24, 0.62);
  border: 1px solid rgba(246, 235, 217, 0.4);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.commute-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--magenta), var(--cheese));
  transition: width 0.45s steps(6);
}

.commute-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(100% / 12 - 1px), rgba(20, 16, 24, 0.68) calc(100% / 12 - 1px) calc(100% / 12));
}

.system {
  grid-area: system;
  justify-self: end;
  display: flex;
  align-items: flex-end;
  gap: clamp(4px, 0.8vw, 8px);
  pointer-events: auto;
}

.sys {
  display: block;
  width: clamp(38px, 6.4vw, 56px);
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.sys img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.5));
  transition: transform 0.06s, filter 0.12s;
}

.sys:active img {
  transform: translateY(2px) scale(0.96);
}

.sys.dim img {
  filter: grayscale(0.8) brightness(0.58) drop-shadow(0 3px 0 rgba(0, 0, 0, 0.5));
}

.sys.muted img {
  filter: grayscale(1) brightness(0.62) drop-shadow(0 3px 0 rgba(0, 0, 0, 0.5));
}

.sys.help {
  aspect-ratio: 266 / 278;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: #141018;
  border: 2px solid #000;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(246, 235, 217, 0.45), 0 3px 0 rgba(0, 0, 0, 0.5);
  color: var(--cream);
}

.help-mark {
  font-family: "Bungee", "Arial Black", sans-serif;
  font-size: clamp(15px, 2.6vw, 22px);
  line-height: 1;
  color: var(--cheese);
}

.help-label {
  font-family: "Chakra Petch", sans-serif;
  font-size: clamp(5px, 1vw, 8px);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(246, 235, 217, 0.8);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: radial-gradient(90% 80% at 50% 44%, rgba(20, 16, 24, 0.18), rgba(20, 16, 24, 0.62));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s, visibility 0.18s;
}

.overlay.show {
  opacity: 1;
  visibility: visible;
}

.card {
  position: relative;
  width: min(92vw, 530px);
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(14px, 3.2vw, 28px) clamp(14px, 3.4vw, 30px) clamp(16px, 3vw, 26px);
  background: linear-gradient(180deg, #1c1227 0%, #120e18 100%);
  border: 2px solid #000;
  border-radius: 8px;
  box-shadow:
    0 0 0 2px rgba(246, 235, 217, 0.7),
    0 10px 0 rgba(0, 0, 0, 0.5),
    0 26px 70px rgba(0, 0, 0, 0.6);
  text-align: center;
  animation: cardIn 0.26s steps(3);
}

.card::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(246, 235, 217, 0.14);
  border-radius: 4px;
  pointer-events: none;
}

@keyframes cardIn {
  0% { transform: scale(1.15) rotate(-1deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.card-kicker {
  font-size: clamp(7px, 1.2vw, 10px);
  font-weight: 600;
  letter-spacing: 0.26em;
  color: rgba(246, 235, 217, 0.55);
}

.card-title {
  margin: 10px 0 7px;
  font-family: "Bungee", "Arial Black", sans-serif;
  font-weight: 400;
  font-size: clamp(28px, 6vw, 54px);
  line-height: 0.92;
  color: var(--magenta);
  text-shadow: 3px 3px 0 #000, 6px 6px 0 rgba(0, 0, 0, 0.32);
  transform: rotate(-2deg);
  letter-spacing: 0.01em;
}

.card-title.win {
  color: var(--cheese);
}

.card-title.help-title {
  color: var(--cream);
  font-size: clamp(24px, 4.6vw, 42px);
}

.card-sub {
  margin: 0 0 4px;
  font-size: clamp(8px, 1.4vw, 12px);
  font-weight: 600;
  letter-spacing: 0.17em;
  color: rgba(246, 235, 217, 0.72);
}

.bestline {
  margin: 2px 0 10px;
  font-family: "Share Tech Mono", monospace;
  font-size: clamp(9px, 1.4vw, 12px);
  letter-spacing: 0.12em;
  color: var(--cream);
  opacity: 0.62;
}

.stats {
  display: flex;
  justify-content: center;
  gap: clamp(12px, 4vw, 28px);
  margin: 12px 0 14px;
}

.stat span {
  display: block;
  font-size: clamp(6px, 1.1vw, 8px);
  font-weight: 600;
  letter-spacing: 0.16em;
  color: rgba(246, 235, 217, 0.5);
  margin-bottom: 2px;
}

.stat b {
  font-family: "Share Tech Mono", monospace;
  font-size: clamp(16px, 2.8vw, 24px);
  font-weight: 400;
  color: var(--cream);
  text-shadow: 0 2px 0 #000;
}

.start-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 8px 0 4px;
  padding: 8px 18px 9px;
  background: var(--magenta);
  color: #fff;
  font-family: "Bungee", "Arial Black", sans-serif;
  font-size: clamp(13px, 2.2vw, 19px);
  line-height: 1;
  letter-spacing: 0.02em;
  border: 2px solid #000;
  border-radius: 4px;
  box-shadow: 0 4px 0 #000, inset 0 0 0 2px rgba(255, 255, 255, 0.24);
  transform: rotate(-1deg);
  cursor: pointer;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

.start-btn img {
  width: clamp(22px, 3.4vw, 30px);
  height: auto;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.4));
}

.start-btn:active {
  transform: translateY(3px) rotate(-1deg);
  box-shadow: 0 1px 0 #000, inset 0 0 0 2px rgba(255, 255, 255, 0.24);
}

.howto {
  list-style: none;
  display: grid;
  gap: 6px;
  margin: 14px 0 10px;
  padding: 0;
  text-align: left;
}

.howto li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: clamp(9px, 1.45vw, 12px);
  line-height: 1.3;
  color: rgba(246, 235, 217, 0.8);
}

.howto .n {
  font-family: "Share Tech Mono", monospace;
  font-size: clamp(9px, 1.2vw, 11px);
  color: var(--cheese);
  opacity: 0.8;
  flex: none;
}

.howto b {
  color: var(--cream);
  font-weight: 600;
}

.howto.hide,
.card-keys.hide,
.bestline.hide,
.stats.hide,
.board.hide {
  display: none;
}

.card-keys {
  font-size: clamp(7px, 1.15vw, 9px);
  letter-spacing: 0.08em;
  color: rgba(246, 235, 217, 0.42);
  line-height: 1.4;
}

.board {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(246, 235, 217, 0.14);
}

.board-title {
  font-size: clamp(7px, 1.1vw, 9px);
  font-weight: 600;
  letter-spacing: 0.22em;
  color: rgba(246, 235, 217, 0.5);
  margin-bottom: 5px;
}

.board ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.board li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: clamp(9px, 1.3vw, 11px);
  color: rgba(246, 235, 217, 0.78);
}

.board .who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.board a {
  color: var(--cream);
  text-decoration: none;
  border-bottom: 1px dotted rgba(246, 235, 217, 0.4);
}

.board li.mine .who {
  color: var(--cream);
}

.board li.mine .pts {
  color: var(--lime);
}

.board .pts {
  font-family: "Share Tech Mono", monospace;
  color: var(--cheese);
  flex: none;
}

.board-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 9px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--cheese);
}

.board-note.hide {
  display: none;
}

.board-note button {
  padding: 2px;
  background: none;
  border: 0;
  color: var(--cream);
  font-family: "Chakra Petch", sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.overlay.pause-mode {
  justify-content: center;
  align-items: flex-end;
  padding: 14px 14px calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(20, 16, 24, 0.02);
}

.overlay.pause-mode .card {
  width: min(84vw, 320px);
  max-height: none;
  padding: 8px 16px 10px;
}

.overlay.pause-mode .card-title {
  font-size: clamp(20px, 4.6vw, 30px);
  margin: 4px 0 2px;
}

.overlay.pause-mode .card-sub {
  margin-bottom: 6px;
}

.overlay.pause-mode .start-btn {
  margin: 3px 0 2px;
  padding: 6px 14px 7px;
}

.loading {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ink);
  transition: opacity 0.3s, visibility 0.3s;
}

.loading.hide {
  opacity: 0;
  visibility: hidden;
}

.load-title {
  font-family: "Bungee", "Arial Black", sans-serif;
  font-size: clamp(24px, 5vw, 48px);
  color: var(--cheese);
  text-shadow: 3px 3px 0 #000, 6px 6px 0 rgba(229, 50, 126, 0.55);
  transform: rotate(-1.5deg);
}

.load-sub {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: rgba(246, 235, 217, 0.5);
}

.load-bar {
  width: 130px;
  height: 4px;
  margin-top: 6px;
  background: rgba(246, 235, 217, 0.14);
  overflow: hidden;
}

.load-bar span {
  display: block;
  width: 40%;
  height: 100%;
  background: var(--magenta);
  animation: loadSlide 0.9s steps(6) infinite;
}

@keyframes loadSlide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(360%); }
}

@media (min-aspect-ratio: 1.15) {
  .overlay {
    align-items: flex-end;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-aspect-ratio: 0.95) {
  .hud-title {
    top: calc(100% + 4px);
    width: min(38vw, 200px);
  }
}

@media (max-width: 760px) and (max-aspect-ratio: 0.95) {
  .controls {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "attacks"
      "system";
    row-gap: 6px;
  }

  .attack-row {
    width: 100%;
  }

  .system {
    justify-self: end;
  }

  .sys {
    width: clamp(34px, 9.4vw, 56px);
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .hud-title {
    width: clamp(150px, 20vw, 270px);
  }

  .attack-row {
    width: min(100%, 440px);
  }

  .sys {
    width: clamp(34px, 5vw, 46px);
  }

  .commute {
    width: clamp(76px, 9vw, 110px);
  }
}

@media (max-aspect-ratio: 0.95) {
  .overlay {
    align-items: flex-end;
    padding-bottom: calc(156px + env(safe-area-inset-bottom, 0px));
  }

  .card {
    max-height: calc(100dvh - 366px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .goal-glow,
  .load-bar span {
    animation: none;
  }
}
