@font-face {
  font-family: 'Cinzel';
  src: url('fonts/cinzel-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Cinzel';
  src: url('fonts/cinzel-800.woff2') format('woff2');
  font-weight: 800;
  font-display: swap;
}

:root {
  --ink: #0b1420;
  --ink-2: #101f31;
  --snow: #eef4fb;
  --snow-dim: #b9c9db;
  --gold: #e8b04b;
  --gold-deep: #c98b28;
  --ice: #8fd6e8;
  --flag-blue: #2f6fb0;
  --flag-red: #b8452f;
  --panel: rgba(12, 22, 34, 0.72);
  --stroke: rgba(238, 244, 251, 0.16);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1420;
  color: var(--snow);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- boot ---------- */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 14px;
  justify-items: center;
  background: radial-gradient(120% 90% at 50% 20%, #16283d 0%, #0a121d 70%);
  z-index: 60;
  transition: opacity .6s ease, visibility .6s;
}
.boot.hide { opacity: 0; visibility: hidden; }
.boot-mark { width: 92px; opacity: .95; animation: float 3.4s ease-in-out infinite; }
.boot-mark svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 6px 18px rgba(143, 214, 232, .25)); }
.boot-text {
  margin: 0;
  font-size: 11px;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--snow-dim);
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: calc(var(--safe-t) + 14px) calc(var(--safe-r) + 16px) 26px calc(var(--safe-l) + 16px);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  z-index: 30;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(6, 14, 24, .58), rgba(6, 14, 24, .24) 58%, rgba(6, 14, 24, 0));
  text-shadow: 0 2px 14px rgba(5, 12, 20, .75);
}
.hud[hidden] { display: none; }
.hud-left { flex: 1; min-width: 0; }
.dist {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 800;
  font-size: clamp(30px, 9vw, 44px);
  line-height: .92;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}
.dist em { font-size: .38em; font-style: normal; margin-left: 4px; color: var(--gold); letter-spacing: .06em; }
.best-line {
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--snow-dim);
  font-variant-numeric: tabular-nums;
}
.hud-bells {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  background: rgba(10, 20, 32, .45);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: #ffe6ae;
}
.bell-ico { width: 17px; height: 17px; color: var(--gold); }
.hud-right { display: flex; gap: 8px; pointer-events: auto; }
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(10, 20, 32, .45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--snow);
  padding: 0;
  cursor: pointer;
  transition: transform .12s ease, background .2s;
}
.icon-btn:active { transform: scale(.93); background: rgba(20, 36, 54, .7); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .ico-off { display: none; }
.icon-btn.muted .ico-on { display: none; }
.icon-btn.muted .ico-off { display: block; }

.shield-chip {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(var(--safe-t) + 66px);
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-weight: 700;
  color: #d8f6ff;
  background: rgba(24, 79, 99, .55);
  border: 1px solid rgba(143, 214, 232, .45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.shield-chip[hidden] { display: none; }
.shield-chip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ice);
  box-shadow: 0 0 10px var(--ice);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  padding: calc(var(--safe-t) + 18px) calc(var(--safe-r) + 20px) calc(var(--safe-b) + 18px) calc(var(--safe-l) + 20px);
  overflow: hidden;
}
.screen[hidden] { display: none; }
.screen-menu {
  align-items: flex-end;
  background:
    radial-gradient(110% 70% at 50% 8%, rgba(8, 16, 26, 0) 30%, rgba(8, 16, 26, .55) 78%, rgba(6, 12, 20, .88) 100%),
    linear-gradient(180deg, rgba(6, 12, 20, .35) 0%, rgba(6, 12, 20, 0) 26%, rgba(6, 12, 20, .55) 72%, rgba(6, 12, 20, .92) 100%);
}
.menu-wrap {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding-bottom: calc(var(--safe-b) + 14px);
  animation: rise .7s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.eyebrow {
  margin: 0 0 12px;
  font-size: 10px;
  letter-spacing: .38em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}
.title {
  margin: 0;
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 800;
  font-size: clamp(44px, 13.6vw, 72px);
  line-height: .86;
  letter-spacing: .01em;
  text-transform: uppercase;
}
.title span { display: block; }
.title span:first-child { color: #f4f8fd; text-shadow: 0 10px 40px rgba(0, 0, 0, .45); }
.title .title-run {
  color: var(--gold);
  letter-spacing: .14em;
  font-size: .72em;
  margin-top: 6px;
  text-shadow: 0 0 40px rgba(232, 176, 75, .35);
}
.tagline {
  margin: 16px 0 26px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--snow-dim);
  max-width: 34ch;
}

.btn {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  border: 0;
  border-radius: 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 17px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .12s ease, filter .2s ease, background .2s ease;
}
.btn:active { transform: scale(.975); }
.btn-primary {
  color: #21160a;
  background: linear-gradient(180deg, #f3c469 0%, var(--gold) 55%, var(--gold-deep) 100%);
  box-shadow: 0 14px 34px -12px rgba(232, 176, 75, .75), inset 0 1px 0 rgba(255, 255, 255, .55);
}
.btn-primary svg { width: 18px; height: 18px; }
.btn-ghost {
  color: var(--snow);
  background: rgba(238, 244, 251, .07);
  border: 1px solid var(--stroke);
  font-weight: 600;
  padding: 14px 18px;
  margin-top: 10px;
}
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.menu-meta {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.meta-cell {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding: 11px 14px;
  border-radius: 13px;
  background: rgba(238, 244, 251, .06);
  border: 1px solid var(--stroke);
}
.meta-k { font-size: 9.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--snow-dim); }
.meta-v { font-family: 'Cinzel', Georgia, serif; font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; }

.controls-hint {
  margin-top: 20px;
  display: grid;
  gap: 8px;
}
.hint {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--snow-dim);
}
.swipe {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: rgba(238, 244, 251, .08);
  border: 1px solid var(--stroke);
  font-size: 13px;
  color: var(--snow);
  flex: none;
}

.ios-hint { font-size: 12px; color: var(--snow-dim); text-align: center; margin: 10px 0 0; }
.ios-hint strong { color: var(--snow); }
.footnote { margin: 14px 0 0; font-size: 10.5px; letter-spacing: .08em; color: rgba(185, 201, 219, .65); text-align: center; }

/* dim panels */
.screen-dim {
  align-items: center;
  justify-content: center;
  background: rgba(5, 11, 18, .58);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
}
.panel {
  width: 100%;
  max-width: 390px;
  padding: 26px 22px 22px;
  border-radius: 24px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .9);
  animation: rise .4s cubic-bezier(.2,.8,.2,1) both;
  text-align: center;
}
.panel .eyebrow { margin-bottom: 10px; }
.panel-title {
  margin: 0 0 18px;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: .02em;
}
.panel-stats, .over-stats {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin: 0 0 22px;
}
.panel-stats div, .over-stats div { display: grid; gap: 3px; }
.panel-stats span, .over-stats span {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.panel-stats em, .over-stats em {
  font-style: normal;
  font-size: 9px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--snow-dim);
}
.panel .btn-ghost { margin-top: 10px; }

.score-big {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin: 2px 0 4px;
}
.score-big span {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 800;
  font-size: 60px;
  line-height: 1;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 44px rgba(232, 176, 75, .35);
}
.score-big em { font-style: normal; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--snow-dim); }
.new-best {
  margin: 6px 0 16px;
  font-size: 10px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--ice);
}
.over-stats { margin: 16px 0 22px; padding-top: 18px; border-top: 1px solid rgba(238, 244, 251, .1); }

/* flash + toast */
.flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  background: radial-gradient(circle at 50% 60%, rgba(143, 214, 232, .55), rgba(143, 214, 232, 0) 60%);
  transition: opacity .28s ease-out;
}
.flash.on { opacity: 1; transition: opacity .06s ease-in; }
.flash.hit { background: radial-gradient(circle at 50% 55%, rgba(210, 70, 50, .55), rgba(210, 70, 50, 0) 65%); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 26px);
  transform: translateX(-50%) translateY(10px);
  margin: 0;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(10, 20, 32, .9);
  border: 1px solid var(--stroke);
  font-size: 12px;
  color: var(--snow);
  z-index: 50;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  max-width: 82vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-height: 760px) {
  .tagline { margin-bottom: 30px; }
  .controls-hint { margin-top: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .boot-mark, .shield-chip .dot { animation: none; }
  .menu-wrap, .panel { animation: none; }
}
