:root {
  --ink: #1a2433;
  --dim: #4a5a70;
  --hope: #1f9a55;
  --fear: #d63a4a;
  --accent: #1a6fd4;
  --warn: #e09010;
  --panel: rgba(255, 255, 255, 0.82);
  --font: "Outfit", system-ui, sans-serif;
  --display: "Orbitron", "Outfit", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #87b8e8;
  color: var(--ink);
  font-family: var(--font);
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

#vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  background: radial-gradient(ellipse at center, transparent 65%, rgba(30, 50, 80, 0.12) 100%);
}

#crosshair {
  pointer-events: none;
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(20, 40, 70, 0.75);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
}

#crosshair::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 3px;
  margin: -1.5px 0 0 -1.5px;
  border-radius: 50%;
  background: #1a6fd4;
}

#speed-lines {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent 40%,
    rgba(92, 225, 255, 0.04) 50%,
    transparent 60%,
    transparent 100%
  );
  mix-blend-mode: screen;
  transition: opacity 0.15s;
}

#speed-lines.on {
  opacity: 1;
  animation: streak 0.35s linear infinite;
}

@keyframes streak {
  from { background-position: 0 0; }
  to { background-position: 120px 0; }
}

.mute-btn,
.pause-btn {
  position: absolute;
  top: calc(0.7rem + env(safe-area-inset-top));
  z-index: 20;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid rgba(20, 40, 70, 0.2);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent);
  font-size: 1rem;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(20, 40, 70, 0.12);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mute-btn {
  right: 0.7rem;
}

.pause-btn {
  right: calc(0.7rem + 2.9rem);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

.pause-btn.hidden {
  display: none;
}

.howto-mobile {
  display: none;
}

.pick-label {
  margin: 0 0 0.75rem;
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-transform: uppercase;
}

.quality-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.4rem;
  margin: 0 0 0.9rem;
}

.qbtn {
  padding: 0.45rem 0.3rem;
  border: 1px solid rgba(20, 40, 70, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--dim);
  font-family: var(--display);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.qbtn.selected {
  border-color: #1a6fd4;
  color: #143056;
  background: rgba(26, 111, 212, 0.14);
  font-weight: 700;
}

.char-pick {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.55rem;
  margin-bottom: 1.1rem;
}

@media (max-width: 640px) {
  .char-pick {
    grid-template-columns: 1fr;
  }
}

.char-card {
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem 0.6rem;
  border: 2px solid rgba(20, 40, 70, 0.15);
  border-radius: 8px;
  background: rgba(26, 111, 212, 0.06);
  cursor: pointer;
  text-align: center;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.char-card:hover {
  transform: translateY(-1px);
}

.char-card.selected {
  border-color: #1a6fd4;
  background: rgba(26, 111, 212, 0.16);
  box-shadow: 0 0 0 1px rgba(26, 111, 212, 0.25);
}

.char-card[data-char="simlight"].selected {
  border-color: #e02020;
  background: rgba(224, 32, 32, 0.12);
  box-shadow: 0 0 0 1px rgba(224, 32, 32, 0.3);
}

.char-card[data-char="grodzilla"].selected {
  border-color: #2a8a5a;
  background: rgba(42, 138, 90, 0.14);
  box-shadow: 0 0 0 1px rgba(42, 138, 90, 0.35);
}

.char-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

.char-desc {
  font-size: 0.75rem;
  color: var(--dim);
  line-height: 1.3;
}

.flash-overlay {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0;
  background:
    linear-gradient(90deg, rgba(140, 210, 255, 0.4), transparent 28%, transparent 72%, rgba(140, 210, 255, 0.4)),
    radial-gradient(ellipse at center, transparent 35%, rgba(180, 230, 255, 0.18) 100%);
  transition: opacity 0.08s;
  mix-blend-mode: screen;
}

.flash-overlay.on {
  opacity: 1;
  animation: flashBolt 0.12s steps(2) infinite;
}

@keyframes flashBolt {
  from { filter: brightness(1); }
  to { filter: brightness(1.35); }
}

.mute-btn[aria-pressed="true"] {
  color: var(--dim);
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(120, 170, 220, 0.28);
  backdrop-filter: blur(4px);
}

.screen.hidden {
  display: none;
}

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255, 255, 255, 0.06) 3px
  );
}

.title-panel {
  position: relative;
  max-width: 28rem;
  width: 100%;
  padding: 2rem 1.75rem;
  border: 1px solid rgba(20, 40, 70, 0.15);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 20px 50px rgba(30, 50, 90, 0.25);
  text-align: center;
}

.title-panel.card {
  background: rgba(255, 255, 255, 0.95);
}

.kicker {
  margin: 0 0 0.5rem;
  font-family: var(--display);
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  color: var(--accent);
}

.brand {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  letter-spacing: 0.08em;
  line-height: 1;
  color: #143056;
}

.tagline {
  margin: 1rem 0 1.25rem;
  color: var(--dim);
  font-size: 1rem;
  line-height: 1.45;
}

.howto {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  text-align: left;
  font-size: 0.92rem;
  color: var(--ink);
  display: grid;
  gap: 0.55rem;
}

.howto li {
  padding: 0.55rem 0.7rem;
  border-left: 3px solid #1a6fd4;
  background: rgba(26, 111, 212, 0.06);
}

kbd {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border: 1px solid rgba(20, 40, 70, 0.2);
  border-radius: 3px;
  background: #eef3f8;
  font-family: var(--display);
  font-size: 0.72rem;
  color: var(--accent);
}

.cta {
  width: 100%;
  padding: 0.95rem 1.2rem;
  border: none;
  border-radius: 4px;
  background: linear-gradient(90deg, #1a6fd4, #3da0f0);
  color: #fff;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.18em;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(26, 111, 212, 0.35);
  transition: transform 0.15s, filter 0.15s;
}

.cta:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.hint {
  margin: 0.85rem 0 0;
  font-size: 0.8rem;
  color: var(--dim);
}

.back-line {
  margin: 1rem 0 0;
  font-size: 0.85rem;
}

.back-line a,
.linkish {
  color: var(--dim);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
}

.back-line a:hover,
.linkish:hover {
  color: var(--accent);
}

.linkish {
  display: block;
  margin: 0.75rem auto 0;
}

.hud {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  padding: calc(0.85rem + env(safe-area-inset-top)) 1rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hud.hidden {
  display: none;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.mission-block,
.score-block {
  padding: 0.7rem 0.9rem;
  background: var(--panel);
  border: 1px solid rgba(20, 40, 70, 0.12);
  border-radius: 6px;
  backdrop-filter: blur(12px);
  box-shadow: 0 6px 20px rgba(30, 50, 80, 0.12);
  max-width: min(22rem, 70vw);
}

.mission-tag,
.score-tag,
.bar-label {
  font-family: var(--display);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  color: var(--accent);
}

.mission {
  margin: 0.25rem 0 0.15rem;
  font-weight: 700;
  font-size: 1.05rem;
}

.howto-live {
  margin: 0;
  font-size: 0.85rem;
  color: var(--dim);
}

.score-block {
  text-align: right;
  min-width: 5.5rem;
}

.score {
  margin: 0.2rem 0 0;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  color: #143056;
}

.bars {
  position: absolute;
  left: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  width: min(16rem, 48vw);
  display: grid;
  gap: 0.45rem;
}

.sandbox-stats {
  padding: 0.65rem 0.85rem;
  background: var(--panel);
  border: 1px solid rgba(20, 40, 70, 0.12);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(30, 50, 80, 0.12);
  backdrop-filter: blur(12px);
  width: auto;
  min-width: 9rem;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--dim);
}

.stat-line b {
  color: var(--ink);
  font-family: var(--display);
  font-size: 0.9rem;
}

.laser-hud {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  box-shadow: inset 0 0 80px rgba(255, 40, 20, 0.25);
  opacity: 0;
  transition: opacity 0.1s;
}

.laser-hud.on {
  opacity: 1;
}

.punch-flash {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  background: radial-gradient(circle at 50% 55%, rgba(255, 255, 255, 0.35), transparent 45%);
  opacity: 0;
  transition: opacity 0.05s;
}

.punch-flash.on {
  opacity: 1;
}

.chaos-title {
  font-size: clamp(1.8rem, 6vw, 2.6rem) !important;
  letter-spacing: 0.02em !important;
  margin-bottom: 1.25rem;
}

.title-panel.chaos .howto {
  margin-bottom: 1.25rem;
}

.bar-label {
  display: block;
  margin-bottom: 0.2rem;
}

.hope-l { color: var(--hope); }
.fear-l { color: var(--fear); }

.track {
  height: 6px;
  border-radius: 2px;
  background: rgba(20, 40, 70, 0.12);
  overflow: hidden;
  border: 1px solid rgba(20, 40, 70, 0.08);
}

.fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 0.25s ease;
}

.fill.hope {
  background: linear-gradient(90deg, #1a8a4c, #3dcc78);
}

.fill.fear {
  background: linear-gradient(90deg, #c02838, #f06070);
}

.compass {
  position: absolute;
  top: 50%;
  right: 1.2rem;
  transform: translateY(-50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(224, 144, 16, 0.75);
  background: rgba(255, 255, 255, 0.85);
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(30, 50, 80, 0.15);
}

.compass.hidden {
  display: none;
}

.compass span {
  position: absolute;
  bottom: -1.3rem;
  font-family: var(--display);
  font-size: 0.55rem;
  letter-spacing: 0.15em;
  color: var(--warn);
}

.needle {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 22px solid var(--warn);
  transform-origin: 50% 70%;
  filter: drop-shadow(0 0 6px rgba(255, 193, 74, 0.8));
  transition: transform 0.08s linear;
}

.hold-ring {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
}

.hold-ring.hidden {
  display: none;
}

.hold-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.hold-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 5;
}

.hold-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 213.6;
  stroke-dashoffset: 213.6;
  filter: drop-shadow(0 0 6px rgba(92, 225, 255, 0.8));
  transition: stroke-dashoffset 0.05s linear;
}

.hold-ring span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.2rem;
  color: #fff;
}

.toast {
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translateX(-50%);
  padding: 0.55rem 1.1rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(20, 40, 70, 0.15);
  box-shadow: 0 8px 24px rgba(30, 50, 80, 0.18);
  font-family: var(--display);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: #143056;
  animation: toastIn 0.35s ease;
}

.toast.ok { color: var(--hope); border-color: rgba(31, 154, 85, 0.4); }
.toast.bad { color: var(--fear); border-color: rgba(214, 58, 74, 0.4); }
.toast.hidden { display: none; }

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.touch {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.touch.hidden {
  display: none;
}

.look-zone {
  pointer-events: auto;
  position: absolute;
  top: 0;
  right: 0;
  width: 58%;
  height: 100%;
  touch-action: none;
}

.stick-zone {
  pointer-events: auto;
  position: absolute;
  left: max(0.8rem, env(safe-area-inset-left));
  bottom: calc(1.1rem + env(safe-area-inset-bottom));
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 2px solid rgba(26, 111, 212, 0.35);
  background: rgba(255, 255, 255, 0.22);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: rgba(26, 111, 212, 0.45);
  border: 2px solid rgba(26, 111, 212, 0.75);
  box-shadow: 0 4px 14px rgba(20, 40, 70, 0.2);
}

.touch-right {
  pointer-events: auto;
  position: absolute;
  right: max(0.7rem, env(safe-area-inset-right));
  bottom: calc(0.9rem + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  width: 10.5rem;
  z-index: 2;
}

.tbtn {
  min-height: 3rem;
  padding: 0.75rem 0.35rem;
  border: 1px solid rgba(20, 40, 70, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 14px rgba(20, 40, 70, 0.14);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.tbtn:active {
  transform: scale(0.96);
  background: rgba(26, 111, 212, 0.25);
}

.tbtn.act {
  grid-column: 1 / -1;
  background: linear-gradient(90deg, #1a6fd4, #3da0f0);
  border-color: transparent;
  color: #fff;
  font-size: 0.95rem;
  min-height: 3.3rem;
  padding: 0.9rem;
}

@media (max-width: 900px), (pointer: coarse) {
  .howto-desk { display: none; }
  .howto-mobile { display: grid; }
  .sandbox-stats {
    left: 0.6rem;
    bottom: calc(10.5rem + env(safe-area-inset-bottom));
    font-size: 0.8rem;
    min-width: 7.5rem;
  }
  .hud-top {
    padding-right: 5.5rem;
  }
  .mission-block {
    max-width: min(14rem, 52vw);
    padding: 0.5rem 0.65rem;
  }
  .mission { font-size: 0.95rem; }
  .howto-live { font-size: 0.75rem; }
  .score-block { min-width: 4.2rem; padding: 0.5rem 0.6rem; }
  .score { font-size: 1.2rem; }
  .crosshair { opacity: 0.55; }
}

@media (max-width: 640px) {
  .howto { font-size: 0.82rem; }
  .title-panel { padding: 1.35rem 1.1rem; }
  .stick-zone {
    width: 118px;
    height: 118px;
  }
  .touch-right { width: 9.6rem; }
}
