:root {
  --display:
    'Avenir Next Condensed', 'DIN Condensed', 'Bahnschrift', 'PingFang SC',
    'Microsoft YaHei', sans-serif;
  --mono:
    'SF Mono', 'JetBrains Mono', ui-monospace, Menlo, Consolas, 'PingFang SC',
    monospace;
  --cyan: #5cf2ff;
  --magenta: #ff4fd8;
  --ink: #04050c;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: #e8eeff;
  font-family: var(--mono);
}
body {
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  cursor: default;
  background: radial-gradient(
    ellipse at center,
    rgba(4, 5, 12, 0.35) 0%,
    rgba(4, 5, 12, 0.86) 75%
  );
  animation: screenIn 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.hidden {
  display: none !important;
}
@keyframes screenIn {
  from {
    opacity: 0;
    transform: scale(1.03);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.6em;
  color: rgba(160, 190, 255, 0.7);
  padding-left: 0.6em;
}
.logo {
  position: relative;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(56px, 13vw, 168px);
  line-height: 0.9;
  letter-spacing: 0.04em;
  background: linear-gradient(
    100deg,
    #fff 0%,
    var(--cyan) 35%,
    var(--magenta) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 28px rgba(92, 242, 255, 0.45));
}
.logo::before,
.logo::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  mix-blend-mode: screen;
}
.logo::before {
  background-image: linear-gradient(#ff2e7e, #ff2e7e);
  animation: logoGlitch 3.2s infinite steps(1);
}
.logo::after {
  background-image: linear-gradient(#2ef0ff, #2ef0ff);
  animation: logoGlitch 3.2s infinite steps(1) reverse;
}
@keyframes logoGlitch {
  0%,
  86%,
  100% {
    clip-path: inset(0 0 100% 0);
    transform: none;
  }
  88% {
    clip-path: inset(12% 0 62% 0);
    transform: translateX(-9px);
  }
  91% {
    clip-path: inset(58% 0 18% 0);
    transform: translateX(11px);
  }
  94% {
    clip-path: inset(34% 0 44% 0);
    transform: translateX(-5px);
  }
  97% {
    clip-path: inset(76% 0 6% 0);
    transform: translateX(7px);
  }
}
.logoSub {
  font-family: var(--display);
  font-size: clamp(16px, 2.4vw, 26px);
  letter-spacing: 1.1em;
  padding-left: 1.1em;
  color: #fff;
  opacity: 0.9;
}
.tagline {
  max-width: 34em;
  font-size: clamp(13px, 1.5vw, 16px);
  line-height: 1.9;
  color: rgba(214, 226, 255, 0.82);
}
.tagline b {
  color: var(--cyan);
  font-weight: 600;
}
.controls {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
  justify-content: center;
  font-size: 12px;
  color: rgba(190, 205, 240, 0.75);
}
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 3px 7px;
  margin-right: 3px;
  border-radius: 5px;
  border: 1px solid rgba(140, 170, 255, 0.4);
  background: rgba(120, 150, 255, 0.1);
  font: inherit;
  color: #fff;
}
.primaryButton {
  margin-top: 8px;
  padding: 16px 54px;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.35em;
  padding-left: calc(54px + 0.35em);
  color: var(--ink);
  background: linear-gradient(100deg, var(--cyan), #fff 55%, var(--magenta));
  background-size: 200% 100%;
  border: 0;
  border-radius: 2px;
  cursor: pointer;
  clip-path: polygon(14px 0, 100% 0, calc(100% - 14px) 100%, 0 100%);
  transition:
    transform 0.15s,
    background-position 0.4s,
    filter 0.2s;
  filter: drop-shadow(0 0 18px rgba(92, 242, 255, 0.55));
}
.primaryButton:hover {
  transform: scale(1.06);
  background-position: 100% 0;
  filter: drop-shadow(0 0 30px rgba(255, 79, 216, 0.7));
}
.primaryButton:active {
  transform: scale(0.97);
}
.best {
  font-size: 12px;
  letter-spacing: 0.25em;
  color: rgba(160, 190, 255, 0.6);
}

.loopReport {
  font-size: 13px;
  letter-spacing: 0.3em;
  color: var(--cyan);
}
.loopReport.damaged {
  color: #ff6a8a;
}
.screen h2 {
  font-family: var(--display);
  font-size: clamp(26px, 4.4vw, 46px);
  font-weight: 800;
  letter-spacing: 0.14em;
}
#upgradeCards {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  margin: 8px 0;
}
.card {
  position: relative;
  width: 208px;
  padding: 26px 18px 22px;
  text-align: center;
  cursor: pointer;
  color: inherit;
  font: inherit;
  background: linear-gradient(
    180deg,
    rgba(30, 38, 84, 0.94),
    rgba(8, 10, 24, 0.96)
  );
  border: 1px solid hsla(var(--hue), 100%, 70%, 0.55);
  border-radius: 4px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 0 26px hsla(var(--hue), 100%, 60%, 0.18),
    inset 0 0 30px hsla(var(--hue), 100%, 60%, 0.08);
  transition:
    transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 0.18s,
    border-color 0.18s;
  animation: cardIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}
.card:nth-child(2) {
  animation-delay: 0.07s;
}
.card:nth-child(3) {
  animation-delay: 0.14s;
}
@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(26px);
  }
}
.card:hover {
  transform: translateY(-8px) scale(1.03);
  border-color: hsl(var(--hue), 100%, 78%);
  box-shadow:
    0 0 44px hsla(var(--hue), 100%, 60%, 0.5),
    inset 0 0 40px hsla(var(--hue), 100%, 60%, 0.16);
}
.cardKey {
  position: absolute;
  top: 8px;
  left: 10px;
  font-size: 11px;
  color: rgba(190, 205, 240, 0.6);
}
.cardIcon {
  font-size: 40px;
  line-height: 1.1;
  color: hsl(var(--hue), 100%, 72%);
  text-shadow: 0 0 18px hsl(var(--hue), 100%, 60%);
}
.cardName {
  margin-top: 10px;
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.cardDetail {
  margin-top: 8px;
  min-height: 3.2em;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(214, 226, 255, 0.78);
}
.cardOwned {
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: 0.15em;
  color: hsl(var(--hue), 100%, 72%);
  min-height: 1.2em;
}
.hint {
  font-size: 12px;
  color: rgba(160, 190, 255, 0.6);
  letter-spacing: 0.1em;
}

.stats {
  display: flex;
  gap: 38px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 6px 0;
}
.stat b {
  display: block;
  font-family: var(--display);
  font-size: clamp(34px, 6vw, 64px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 22px rgba(92, 242, 255, 0.6);
}
.stat span {
  font-size: 11px;
  letter-spacing: 0.35em;
  color: rgba(160, 190, 255, 0.7);
}
.verdict {
  font-size: 14px;
  color: var(--magenta);
  letter-spacing: 0.2em;
  min-height: 1.4em;
}

#dashButton {
  position: fixed;
  right: 26px;
  bottom: 150px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 2px solid rgba(92, 242, 255, 0.7);
  background: rgba(92, 242, 255, 0.12);
  color: #fff;
  font: 700 14px var(--display);
  letter-spacing: 0.1em;
  display: none;
}
@media (pointer: coarse) {
  #dashButton.inPlay {
    display: block;
  }
  .controls {
    display: none;
  }
}

button {
  touch-action: manipulation;
}
button:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: -3px;
}
.screen {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: max(64px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom));
}
.logoSub {
  letter-spacing: 0.32em;
  padding-left: 0.32em;
}
#toolbar {
  position: fixed;
  z-index: 10;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  white-space: nowrap;
}
#toolbar button {
  min-height: 44px;
  padding: 8px 12px;
  background: rgba(4, 5, 12, 0.88);
  border: 1px solid rgba(140, 170, 255, 0.3);
  border-radius: 6px;
  color: #d6e2ff;
  font: 12px var(--mono);
  cursor: pointer;
}
#toolbar button[hidden] {
  display: none;
}
#pauseScreen {
  z-index: 9;
  background: rgba(4, 5, 12, 0.85);
}
.touchHelp {
  display: none;
  color: #b9cbea;
  font-size: 12px;
  line-height: 1.8;
  max-width: 34em;
}
.lowFx .logo::before,
.lowFx .logo::after {
  display: none;
}
.lowFx *,
.lowFx *::before,
.lowFx *::after {
  animation: none !important;
}
@media (pointer: coarse) {
  .touchHelp {
    display: block;
  }
}
@media (max-width: 600px) {
  .screen {
    gap: 14px;
  }
  .primaryButton {
    padding: 14px 30px;
    letter-spacing: 0.16em;
    font-size: 20px;
  }
  .screen h2 {
    font-size: 25px;
    letter-spacing: 0.06em;
  }
  #upgradeCards {
    width: min(100%, 400px);
    display: grid;
    gap: 10px;
  }
  .card {
    width: 100%;
    padding: 12px 14px 12px 62px;
    text-align: left;
    min-height: 94px;
  }
  .cardIcon {
    position: absolute;
    left: 18px;
    top: 30px;
    font-size: 28px;
  }
  .cardName {
    margin-top: 0;
    font-size: 21px;
  }
  .cardDetail {
    margin-top: 4px;
    min-height: 0;
  }
  .cardOwned {
    margin-top: 4px;
  }
  .stats {
    gap: 18px;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .stat span {
    letter-spacing: 0.1em;
  }
  .hint {
    font-size: 11px;
    line-height: 1.6;
  }
  .loopReport {
    letter-spacing: 0.06em;
    line-height: 1.6;
  }
}
@media (max-height: 520px) {
  .screen {
    gap: 9px;
    padding-top: 56px;
    padding-bottom: 10px;
  }
  .logo {
    font-size: min(14vw, 64px);
  }
  .eyebrow,
  .logoSub {
    display: none;
  }
  .tagline {
    font-size: 12px;
    line-height: 1.5;
  }
  .touchHelp {
    font-size: 11px;
    line-height: 1.5;
  }
  .primaryButton {
    padding: 10px 28px;
    font-size: 18px;
    margin-top: 0;
  }
  #upgradeCards {
    flex-wrap: nowrap;
    gap: 10px;
    margin: 0;
  }
  .card {
    width: min(27vw, 208px);
    padding: 16px 10px 10px;
  }
  .cardIcon {
    font-size: 25px;
  }
  .cardName {
    font-size: 19px;
    margin-top: 5px;
  }
  .cardDetail {
    font-size: 11px;
    line-height: 1.4;
    min-height: 32px;
  }
  .cardOwned {
    margin-top: 5px;
  }
  .loopReport {
    font-size: 11px;
  }
  .screen h2 {
    font-size: 25px;
  }
  .stats {
    gap: 24px;
    margin: 0;
  }
  .stat b {
    font-size: 34px;
  }
  .verdict {
    font-size: 12px;
  }
  #dashButton {
    width: 60px;
    height: 60px;
    right: max(18px, env(safe-area-inset-right));
    bottom: 105px;
  }
}
