/*! Snow Rider 3D — © 2026 SnowRider.game */
:root {
  --ink: #0d1d3a;
  --text: #f4f8ff;
  --muted: #b3c6e4;
  --ice: #8fdcff;
  --gold: #ffd257;
  --warm1: #ff7b54;
  --warm2: #ff4469;
  --panel1: rgba(24, 50, 98, 0.86);
  --panel2: rgba(10, 24, 54, 0.88);
  --line: rgba(255, 255, 255, 0.16);
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0f2244;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}

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

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgba(0, 0, 0, 0) 58%, rgba(8, 22, 54, 0.32) 100%);
}

.hidden { display: none !important; }

.ic { width: 1.1em; height: 1.1em; flex: none; fill: currentColor; }
.ic.gift { color: var(--gold); --ribbon: #ff4d5e; }

/* ---------- screens & panels ---------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--sat)) calc(12px + var(--sar)) calc(16px + var(--sab)) calc(12px + var(--sal));
  overflow-y: auto;
}

#screen-pause, #screen-over { background: rgba(8, 20, 46, 0.32); }

.panel {
  position: relative;
  width: min(410px, 100%);
  padding: 26px 26px 24px;
  border-radius: 28px;
  text-align: center;
  background: linear-gradient(165deg, var(--panel1), var(--panel2));
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(3, 10, 30, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  animation: pop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.25);
}
.panel-small { width: min(340px, 100%); }

@keyframes pop {
  from { transform: translateY(14px) scale(0.96); opacity: 0; }
  to { transform: none; opacity: 1; }
}

h2 {
  margin: 0 0 14px;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

/* ---------- logo ---------- */

.logo {
  margin: 2px 0 6px;
  line-height: 0.9;
  font-family: "Arial Black", "Segoe UI Black", "Helvetica Neue", system-ui, sans-serif;
  font-weight: 900;
  font-style: italic;
}
.logo-main {
  display: block;
  font-size: clamp(42px, 12vw, 62px);
  letter-spacing: 0.005em;
  color: #fff;
  background: linear-gradient(180deg, #ffffff 0%, #f1f8ff 50%, #b4dcff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #3b6db4) drop-shadow(0 7px 12px rgba(4, 14, 40, 0.55));
}
.logo-3d {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 16px 5px;
  font-size: clamp(26px, 7.5vw, 36px);
  color: #fff;
  background: linear-gradient(180deg, #ff8a5c, #ff3f62);
  border-radius: 12px;
  transform: rotate(-4deg);
  box-shadow: 0 4px 0 #ad2140, 0 10px 20px rgba(0, 0, 0, 0.28);
}
.tagline {
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* ---------- stats ---------- */

.stats, .over-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 4px 0 8px;
}
.stat {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 15px;
  white-space: nowrap;
}
.stat span { color: var(--muted); font-weight: 600; }
.stat b { font-weight: 900; font-variant-numeric: tabular-nums; }
.stat .ic { font-size: 18px; color: var(--ice); }
.stat .ic.gift { color: var(--gold); }

/* ---------- buttons ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  margin-top: 12px;
  padding: 0 18px;
  border: 0;
  border-radius: 18px;
  font: 850 20px/1 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease, box-shadow 0.1s ease;
  touch-action: manipulation;
}
.btn .ic { font-size: 22px; }
.btn-primary {
  background: linear-gradient(180deg, var(--warm1), var(--warm2));
  box-shadow: 0 5px 0 #b3264a, 0 12px 26px rgba(255, 68, 105, 0.32);
  text-shadow: 0 1px 2px rgba(120, 10, 40, 0.35);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: translateY(3px); box-shadow: 0 2px 0 #b3264a, 0 6px 14px rgba(255, 68, 105, 0.3); }
.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.15); }
.btn-secondary:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); }
.btn:disabled { cursor: default; filter: saturate(0.4) brightness(0.85); }
.btn:focus-visible, .round-btn:focus-visible, .card:focus-visible { outline: 3px solid var(--ice); outline-offset: 3px; }

.round-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  background: rgba(9, 22, 48, 0.58);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  font-size: 22px;
  touch-action: manipulation;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.18);
}
.round-btn:active { transform: scale(0.94); }
.round-btn.corner { position: absolute; top: calc(14px + var(--sat)); right: calc(14px + var(--sar)); }

.hint {
  margin: 16px 0 0;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--muted);
}
kbd {
  display: inline-block;
  min-width: 24px;
  padding: 1px 6px;
  margin: 0 1px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom-width: 2px;
  color: #fff;
  font: 700 12px/1.6 system-ui, sans-serif;
}
body.touch .hint-keys { display: none; }
body:not(.touch) .hint-touch { display: none; }

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

.hud {
  position: absolute;
  z-index: 5;
  top: calc(12px + var(--sat));
  left: calc(12px + var(--sal));
  right: calc(12px + var(--sar));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  contain: layout style;
}
.hud .pill { contain: layout paint; }
.hud-left { display: flex; flex-direction: column; align-items: flex-start; }
.hud-right { display: flex; gap: 10px; align-items: center; }
.hud .round-btn { pointer-events: auto; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(9, 22, 50, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.14);
  white-space: nowrap;
}
.pill .unit { font-size: 0.6em; font-weight: 800; opacity: 0.78; margin-left: -2px; }
.pill-dist { font-size: 30px; padding: 4px 18px 5px; }
.pill-small { font-size: 14px; margin-top: 6px; padding: 4px 11px; color: #dfeaff; }
.pill-small .ic { color: var(--gold); }
.pill-gifts { font-size: 24px; padding: 6px 15px; }
.pill-gifts .ic { font-size: 22px; }
.pill-gifts.bump { animation: bump 0.32s ease; }
@keyframes bump { 40% { transform: scale(1.18); } }

.toast {
  position: absolute;
  z-index: 6;
  top: 21%;
  left: 50%;
  transform: translate(-50%, 0);
  padding: 8px 20px;
  border-radius: 999px;
  background: rgba(9, 22, 50, 0.5);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
}
.toast.show { animation: toast 2.2s ease forwards; }
.toast.gold { color: var(--gold); }
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.9); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1.04); }
  20% { transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}

/* ---------- touch controls ---------- */

.touch-ui { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.jump-btn {
  position: absolute;
  right: calc(18px + var(--sar));
  bottom: calc(22px + var(--sab));
  width: 98px;
  height: 98px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.32), rgba(20, 50, 100, 0.45));
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  font: 900 14px/1 system-ui, sans-serif;
  letter-spacing: 0.08em;
  pointer-events: auto;
  touch-action: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}
body:not(.touch) .jump-btn { display: none; }
.jump-btn .ic { font-size: 34px; margin-bottom: -2px; }
.jump-btn.down { transform: scale(0.92); background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.5), rgba(40, 90, 160, 0.55)); }

.touch-hint {
  position: absolute;
  inset: auto 0 calc(140px + var(--sab)) 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 14px;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.6s ease;
  font-size: 14px;
  font-weight: 800;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}
.touch-hint.show { opacity: 1; }
.th-side { max-width: 34%; padding: 10px 12px; border-radius: 14px; background: rgba(9, 22, 50, 0.5); text-align: center; }
.th-arrow { display: block; font-size: 24px; }
.th-mid { flex: 1; text-align: center; padding: 10px 6px; border-radius: 14px; background: rgba(9, 22, 50, 0.38); }

/* ---------- game over ---------- */

.over-title { margin-bottom: 4px; color: #ffe4dc; }
.over-dist { font-size: 64px; font-weight: 900; line-height: 1.05; font-variant-numeric: tabular-nums; text-shadow: 0 4px 0 rgba(0, 0, 0, 0.18); }
.over-dist .unit { font-size: 0.42em; margin-left: 6px; color: var(--muted); }
.newbest {
  display: inline-block;
  margin: 6px 0 12px;
  padding: 6px 16px;
  border-radius: 999px;
  color: #3b2400;
  background: linear-gradient(180deg, #ffe58a, #ffbf3a);
  font-weight: 900;
  font-size: 17px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  box-shadow: 0 0 0 4px rgba(255, 210, 87, 0.22), 0 6px 22px rgba(255, 190, 60, 0.45);
  animation: glow 1.4s ease-in-out infinite alternate;
}
@keyframes glow { to { box-shadow: 0 0 0 7px rgba(255, 210, 87, 0.12), 0 6px 30px rgba(255, 190, 60, 0.7); } }
.panel-over .over-row { margin-top: 10px; }
.panel-over .over-row .stat { flex-direction: column; gap: 3px; padding: 10px 6px; }
.panel-over .over-row .stat b { font-size: 20px; }
.panel-over .over-row .stat.best-hl { border-color: rgba(255, 210, 87, 0.7); background: rgba(255, 210, 87, 0.12); }

/* ---------- shop ---------- */

.screen-shop {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
  flex-direction: row;
  overflow: hidden;
}
.shop-preview { flex: 1; min-width: 0; }
.panel-shop {
  width: 460px;
  max-width: 52vw;
  height: 100%;
  border-radius: 0;
  padding: calc(18px + var(--sat)) calc(18px + var(--sar)) calc(18px + var(--sab)) 18px;
  text-align: left;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  border-width: 0 0 0 1px;
  animation: slidein 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.shop-head { display: flex; align-items: center; gap: 12px; }
.shop-head h2 { flex: 1; margin: 0; font-size: 26px; }
.shop-head .pill { font-size: 20px; }
.shop-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.shop-name-wrap { flex: 1; min-width: 0; }
.shop-name { font-size: 22px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-status { margin-top: 3px; font-size: 14px; font-weight: 700; color: var(--muted); }
.shop-status.price { color: var(--gold); }
.btn-shop-action { width: auto; min-width: 150px; margin: 0; min-height: 54px; font-size: 18px; }
.btn-shop-action .ic { font-size: 20px; }
.btn-shop-action.owned-sel { background: rgba(120, 220, 160, 0.18); border: 1.5px solid rgba(140, 240, 180, 0.5); box-shadow: none; text-shadow: none; filter: none; }
.shop-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.card {
  position: relative;
  padding: 6px 6px 8px;
  border-radius: 16px;
  background: #1d3460;
  border: 2px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  text-align: center;
  cursor: pointer;
  font: inherit;
  min-width: 0;
  touch-action: manipulation;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.card:hover { border-color: rgba(143, 220, 255, 0.45); }
.card.focus { border-color: var(--ice); box-shadow: 0 0 0 3px rgba(143, 220, 255, 0.22); transform: translateY(-2px); }
.card .thumb { width: 100%; aspect-ratio: 4 / 3; border-radius: 10px; display: block; background: #1d3460; object-fit: cover; }
.card .cname {
  margin-top: 5px; font-size: 12px; font-weight: 800; line-height: 1.12; min-height: 2.24em;
  display: flex; align-items: center; justify-content: center; overflow-wrap: anywhere;
}
.card .cprice { margin-top: 2px; font-size: 12px; font-weight: 900; color: var(--gold); display: flex; align-items: center; justify-content: center; gap: 3px; }
.card .cprice.own { color: #9ee6b8; }
.card .cprice .ic { font-size: 13px; }
.card.locked .thumb { filter: saturate(0.7) brightness(0.82); }
.card .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #39c27a;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.card .badge.lock { background: rgba(9, 22, 50, 0.8); color: #c9d6ee; }
.shop-note { margin: 16px 2px 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ---------- loading & errors ---------- */

.loading { flex-direction: column; background: radial-gradient(ellipse at 50% 30%, #2a5aa0, #0f2244 70%); }
.loading p { margin-top: 18px; font-weight: 800; letter-spacing: 0.1em; color: var(--muted); }
.spinner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.18);
  border-top-color: #fff;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-text { color: var(--muted); line-height: 1.55; font-size: 15px; margin: 0 0 6px; }

/* ---------- responsive ---------- */

@media (max-aspect-ratio: 1/1), (max-width: 700px) {
  .screen-shop { flex-direction: column; }
  .shop-preview { flex: 0 0 34%; }
  .panel-shop {
    width: 100%;
    max-width: none;
    height: auto;
    flex: 1;
    border-radius: 26px 26px 0 0;
    border-width: 1px 0 0 0;
    padding: 16px calc(14px + var(--sar)) calc(16px + var(--sab)) calc(14px + var(--sal));
    animation-name: slideup;
  }
  @keyframes slideup { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
  .shop-info { margin: 12px 0 12px; padding: 12px; }
  .shop-name { font-size: 19px; }
  .btn-shop-action { min-width: 128px; font-size: 16px; padding: 0 14px; }
}

@media (max-width: 400px) {
  .panel { padding: 22px 18px 20px; border-radius: 24px; }
  .pill-dist { font-size: 26px; padding: 4px 14px 5px; }
  .pill-gifts { font-size: 21px; padding: 5px 12px; }
  .round-btn { width: 48px; height: 48px; }
  .stat { font-size: 14px; padding: 9px 8px; }
  .shop-grid { gap: 7px; }
  .card { padding: 4px 4px 6px; border-radius: 13px; }
  .card .cname { font-size: 10.5px; }
  .shop-head h2 { font-size: 21px; white-space: nowrap; }
  .over-dist { font-size: 54px; }
}

@media (max-height: 560px) and (min-aspect-ratio: 1/1) {
  .panel { padding: 16px 22px 16px; }
  .logo-main { font-size: 40px; }
  .logo-3d { font-size: 24px; margin-top: 4px; }
  .tagline { margin: 6px 0 8px; font-size: 13px; }
  .btn { min-height: 48px; margin-top: 9px; font-size: 18px; }
  .hint { margin-top: 10px; }
  .over-dist { font-size: 48px; }
  h2 { font-size: 24px; margin-bottom: 8px; }
  .jump-btn { width: 84px; height: 84px; }
  .touch-hint { bottom: calc(110px + var(--sab)); }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .panel-shop { animation: none; }
  .newbest { animation: none; }
}
