@font-face {
  font-family: "Titan One";
  src: url("/assets/fonts/TitanOne-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #0b2341;
  --ink-soft: #294a6b;
  --muted: #5d7892;
  --yellow: #ffd23f;
  --yellow-deep: #b88600;
  --mint: #2be3be;
  --red: #ff3d5a;
  --sky: #8fe3ff;
  --paper: #f3fbff;
  --display: "Titan One", "Arial Black", system-ui, sans-serif;
  --body: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100dvh;
  background:
    radial-gradient(80% 60% at 82% 0%, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0) 55%),
    radial-gradient(70% 50% at 8% 38%, rgba(255, 236, 150, 0.65) 0%, rgba(255, 236, 150, 0) 60%),
    radial-gradient(90% 70% at 50% 110%, rgba(255, 239, 173, 0.9) 0%, rgba(255, 239, 173, 0) 60%),
    linear-gradient(180deg, #69cfff 0%, #9fe7ff 32%, #d9f7ff 62%, #fff2c2 100%);
  color: var(--ink);
  font-family: var(--body);
  overflow: hidden;
  overscroll-behavior: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.55) 1px, transparent 1.4px);
  background-size: 26px 26px;
  opacity: 0.35;
  mask-image: linear-gradient(180deg, #000 0%, transparent 60%);
}

.page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage {
  position: relative;
  width: 390px;
  height: 693px;
  overflow: hidden;
  background: #9fe7ff;
  isolation: isolate;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 760px) {
  .stage {
    border-radius: 30px;
    box-shadow:
      0 0 0 3px rgba(11, 35, 65, 0.16),
      0 30px 80px rgba(11, 63, 96, 0.32);
  }
}

.sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(85% 45% at 78% 4%, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, #6fd3ff 0%, #9fe8ff 26%, #d6f7ff 55%, #fff3c9 100%);
}

.sky::after {
  content: "";
  position: absolute;
  inset: auto -20% -18% -20%;
  height: 48%;
  background: radial-gradient(60% 100% at 50% 100%, rgba(255, 211, 90, 0.35) 0%, rgba(255, 240, 180, 0) 70%);
}

.sky-sun {
  position: absolute;
  width: 76%;
  aspect-ratio: 1;
  top: -30%;
  right: -28%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0%, rgba(255, 247, 200, 0.55) 38%, rgba(255, 240, 160, 0) 70%);
  filter: blur(2px);
}

.sky-haze {
  position: absolute;
  width: 90%;
  height: 34%;
  left: -35%;
  bottom: 2%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 65%);
  filter: blur(6px);
}

.sky-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.85);
  animation: drift 9s ease-in-out infinite alternate;
}

.sky-dot.d1 { left: 9%; top: 18%; animation-delay: -2s; }
.sky-dot.d2 { left: 84%; top: 30%; width: 5px; height: 5px; animation-delay: -5s; }
.sky-dot.d3 { left: 16%; top: 62%; width: 4px; height: 4px; opacity: 0.7; animation-delay: -7s; }

.sky-ring {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-radius: 50%;
  animation: drift 14s ease-in-out infinite alternate;
}

.sky-ring.r1 { width: 120px; height: 120px; left: -52px; top: 34%; }
.sky-ring.r2 { width: 74px; height: 74px; right: -28px; top: 55%; border-color: rgba(255, 255, 255, 0.4); animation-delay: -6s; }

@keyframes drift {
  from { transform: translate3d(0, -6px, 0); }
  to { transform: translate3d(4px, 8px, 0); }
}

canvas#game {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
  cursor: grab;
}

canvas#game:active {
  cursor: grabbing;
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(120% 82% at 50% 42%, rgba(0, 0, 0, 0) 52%, rgba(7, 45, 72, 0.2) 100%);
}

.flash {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 56%, rgba(255, 255, 255, 0.75) 0%, rgba(255, 61, 90, 0.42) 34%, rgba(255, 61, 90, 0) 66%);
  transition: opacity 0.12s linear;
}

.flash.on {
  opacity: 1;
}

/* ---------- HUD ---------- */

.hud {
  position: absolute;
  z-index: 20;
  top: calc(12px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  visibility: hidden;
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0s linear 0.28s;
}

.stage[data-state="playing"] .hud {
  opacity: 1;
  transform: none;
  visibility: visible;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.icon-btn {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border: 2px solid rgba(11, 35, 65, 0.1);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(11, 63, 96, 0.16);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

.icon-btn:hover { background: #fff; }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.icon-btn .ico-off { display: none; }
.icon-btn[aria-pressed="true"] .ico-on { display: none; }
.icon-btn[aria-pressed="true"] .ico-off { display: block; }

.score-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 102px;
  padding: 5px 18px 7px;
  background: var(--ink);
  border-radius: 20px;
  box-shadow: 0 6px 0 rgba(11, 35, 65, 0.16), 0 10px 22px rgba(11, 63, 96, 0.22);
}

.score-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: #8fe3ff;
}

.score-number {
  font-family: var(--display);
  font-size: 34px;
  line-height: 0.92;
  color: var(--yellow);
  font-variant-numeric: tabular-nums;
}

.score-number.pop {
  animation: score-pop 0.24s ease-out;
}

@keyframes score-pop {
  0% { transform: scale(1); }
  38% { transform: scale(1.22); color: #fff; }
  100% { transform: scale(1); }
}

.float-score {
  position: absolute;
  z-index: 18;
  transform: translate(-50%, -50%);
  font-family: var(--display);
  font-size: 24px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(11, 35, 65, 0.35);
  pointer-events: none;
  animation: float-up 0.9s ease-out forwards;
}

@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  18% { opacity: 1; transform: translate(-50%, -55%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}

.best-pill {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 9px 12px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(11, 63, 96, 0.14);
}

.best-pill b {
  font-family: var(--display);
  font-size: 15px;
  color: var(--ink);
  letter-spacing: 0;
}

/* ---------- in-game hint ---------- */

.hint {
  position: absolute;
  z-index: 15;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: rgba(11, 35, 65, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(8, 40, 68, 0.25);
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}

.hint.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hint-hand {
  display: grid;
  place-items: center;
  color: var(--yellow);
}

.hint-dot { opacity: 0.5; }

/* ---------- overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px 14px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(8, 40, 68, 0) 34%, rgba(8, 40, 68, 0.18) 100%);
  transition: opacity 0.24s ease, visibility 0.24s ease;
}

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

.card {
  width: 100%;
  max-width: 352px;
  background: rgba(255, 255, 255, 0.96);
  border: 3px solid var(--ink);
  border-radius: 28px;
  box-shadow:
    0 9px 0 rgba(11, 35, 65, 0.16),
    0 26px 60px rgba(8, 45, 75, 0.28);
}

.overlay-start {
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.34) 0%,
    rgba(255, 255, 255, 0) 30%,
    rgba(8, 40, 68, 0) 72%,
    rgba(8, 40, 68, 0.2) 100%
  );
}

.start-top {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.start-bottom {
  width: 100%;
  max-width: 286px;
  margin: 0 auto;
}

.kicker {
  margin: 0 0 1px;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.3em;
  color: #0a7d86;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

.logo {
  margin: 0 auto 8px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(34px, 10.2vw, 43px);
  line-height: 0.92;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: var(--ink);
  text-shadow:
    3px 3px 0 var(--yellow),
    0 1px 0 rgba(255, 255, 255, 0.6);
}

.logo span {
  color: var(--red);
  text-shadow: 3px 3px 0 var(--ink);
}

.logo-3d {
  display: inline-block;
  margin-left: 3px;
  padding: 2px 7px 4px;
  font-style: normal;
  font-size: 17px;
  line-height: 1;
  vertical-align: 12px;
  color: var(--yellow);
  background: var(--ink);
  border-radius: 7px;
  letter-spacing: 0.02em;
  text-shadow: none;
  transform: rotate(-4deg);
}

.studio {
  margin: 0 auto 7px;
  max-width: 330px;
  font-size: 10.5px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #23496b;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.rule {
  display: inline-block;
  margin: 0 auto 9px;
  padding: 7px 13px;
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(11, 63, 96, 0.12);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.rule b {
  color: #d51f44;
}

.legend {
  display: flex;
  gap: 6px;
  max-width: 330px;
  margin: 0 auto;
}

.legend-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 10px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 3px 10px rgba(11, 63, 96, 0.1);
}

.swatch {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  flex: 0 0 auto;
}

.swatch-ball {
  background: radial-gradient(circle at 35% 28%, #d8fdff 0 18%, #04d4f0 19% 62%, #007f99 63% 100%);
  border: 1px solid var(--ink);
  border-radius: 50%;
}

.swatch-safe {
  background: linear-gradient(180deg, #43f0c8 0%, #12c4a3 100%);
  box-shadow: inset 0 -2px 0 rgba(0, 80, 65, 0.22);
}

.swatch-gap {
  background: var(--ink);
  border: 2px dashed rgba(255, 255, 255, 0.95);
  border-radius: 50%;
}

.swatch-dead {
  background: linear-gradient(180deg, #ff5a73 0%, #d91f43 100%);
  box-shadow: inset 0 -2px 0 rgba(90, 0, 15, 0.25);
}

.btn {
  width: 100%;
  min-height: 54px;
  padding: 9px 16px 7px;
  color: var(--ink);
  font-family: var(--display);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 0.06em;
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 5px 0 var(--yellow-deep);
  cursor: pointer;
  transition: transform 0.07s ease, box-shadow 0.07s ease, background 0.12s ease;
}

.btn:hover { background: #ffdb63; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--yellow-deep); }
.btn:focus-visible { outline: 4px solid rgba(255, 210, 63, 0.55); outline-offset: 3px; }

.best-line {
  margin: 9px 0 0;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.best-line b {
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 0;
  color: var(--ink);
}

/* game over card */

.overlay-over {
  align-items: center;
  background: rgba(7, 24, 46, 0.46);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.over-card {
  padding: 20px 20px 18px;
  text-align: center;
  color: #fff;
  background:
    radial-gradient(120% 80% at 50% -20%, rgba(60, 110, 160, 0.5) 0%, rgba(11, 35, 65, 0) 60%),
    linear-gradient(180deg, #14325a 0%, #0b2341 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 26px;
  box-shadow:
    0 10px 0 rgba(3, 16, 32, 0.28),
    0 30px 70px rgba(3, 16, 32, 0.5);
}

.kicker-dead {
  color: #ff8295;
}

.over-title {
  margin: 4px 0 4px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 39px;
  line-height: 1;
  letter-spacing: 0.01em;
  color: #fff;
}

.cause {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.4;
  color: #b9cee4;
}

.stats {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.stat {
  flex: 1;
  padding: 9px 8px 7px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 14px;
}

.stat span {
  display: block;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #8fb3d9;
}

.stat b {
  display: block;
  margin-top: 2px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 27px;
  line-height: 1;
  color: var(--yellow);
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  background: #e8f8ff;
  color: #0b2341;
  font-family: system-ui, sans-serif;
  text-align: center;
}

@media (max-height: 760px) {
  .start-card { padding: 12px 15px 10px; }
  .logo { font-size: clamp(32px, 10.2vw, 40px); margin-bottom: 6px; }
  .rule { font-size: 12px; margin-bottom: 8px; }
  .legend { margin-bottom: 9px; }
  .legend-item { padding: 5px 3px; font-size: 9.5px; }
  .btn { min-height: 48px; font-size: 23px; }
  .best-line { margin-top: 6px; }
  .over-card { padding: 16px; }
  .over-title { font-size: 34px; }
  .stats { margin: 12px 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sky-dot,
  .sky-ring,
  .btn,
  .icon-btn {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- About entry on the start screen ---------- */

.about-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 2px auto 0;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  border-radius: 10px;
}

.about-link:hover { color: var(--ink); }
.about-link:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* ---------- About page ---------- */

.about-body { overflow: auto; }

.about-main {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(48px + env(safe-area-inset-bottom));
}

.about-back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid rgba(11, 35, 65, 0.22);
}

.about-back:hover { border-bottom-color: var(--ink); }
.about-back:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

.about-head { margin: 20px 0 22px; }

.about-title {
  margin: 0 0 12px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(40px, 10vw, 62px);
  line-height: 0.95;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-shadow: 3px 3px 0 var(--yellow);
}

.about-lede {
  max-width: 560px;
  margin: 0;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.about-card {
  padding: 24px 22px;
  background: rgba(255, 255, 255, 0.94);
  border: 3px solid var(--ink);
  border-radius: 26px;
  box-shadow:
    0 9px 0 rgba(11, 35, 65, 0.14),
    0 24px 50px rgba(8, 45, 75, 0.2);
}

.about-card h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.about-card p {
  margin: 0 0 20px;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.about-card p:last-child { margin-bottom: 0; }

.about-inline {
  color: #0a5fb4;
  font-weight: 700;
  text-underline-offset: 2px;
}

.about-play {
  max-width: 340px;
  margin: 22px auto 0;
}

.about-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.about-foot {
  margin: 22px 0 0;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
