/* Powderline — chill snowboard trick game */

:root {
  --ink: #12303e;
  --teal: #0fb9a8;
  --teal-dark: #0a8f82;
  --coral: #ff7a59;
  --sun: #ffd166;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-border: rgba(255, 255, 255, 0.9);
  --shadow: 0 10px 30px rgba(18, 48, 62, 0.25);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #bfe3ff;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

/* ---------- HUD ---------- */
#hud {
  position: fixed; inset: 0;
  pointer-events: none;
  display: none;
  z-index: 5;
}
#hud.on { display: block; }

.hud-card {
  position: absolute;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 10px 14px;
  backdrop-filter: blur(6px);
}

#hudScore { top: 14px; left: 14px; min-width: 150px; }
#hudScore .label, .hud-label { font-size: 11px; letter-spacing: 0.12em; opacity: 0.65; text-transform: uppercase; }
#scoreVal { font-size: 28px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
#scoreCombo { font-size: 13px; font-weight: 700; color: var(--teal-dark); min-height: 16px; }

#hudSpeed { bottom: 14px; right: 14px; width: 170px; }
#speedVal { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
#speedVal small { font-size: 12px; font-weight: 600; opacity: 0.6; }
#speedbar { height: 8px; background: rgba(18,48,62,0.15); border-radius: 99px; overflow: hidden; margin-top: 5px; }
#speedbar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--teal), var(--sun), var(--coral)); border-radius: 99px; transition: width 0.08s linear; }

#hudTimer { top: 14px; right: 14px; text-align: center; min-width: 110px; }
#timerVal { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
#hudTimer.low #timerVal { color: #d92c2c; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.07); } }

#hudDist { top: 14px; left: 50%; transform: translateX(-50%); text-align: center; padding: 8px 18px; }
#distVal { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }

#popups {
  position: absolute; left: 50%; top: 26%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: max-content; max-width: 90vw;
}
.popup {
  font-weight: 900; font-size: 30px; letter-spacing: 0.02em;
  color: #fff; text-shadow: 0 2px 0 rgba(18,48,62,0.45), 0 6px 18px rgba(18,48,62,0.35);
  animation: popup 1.5s ease-out forwards; white-space: nowrap;
}
.popup small { font-size: 20px; color: var(--sun); }
.popup.bail { color: #ffb3a4; font-size: 40px; }
@keyframes popup {
  0% { transform: translateY(14px) scale(0.7); opacity: 0; }
  12% { transform: translateY(0) scale(1.06); opacity: 1; }
  22% { transform: scale(1); }
  75% { opacity: 1; }
  100% { transform: translateY(-34px); opacity: 0; }
}

#flash {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  font-size: 64px; font-weight: 900; color: var(--coral);
  text-shadow: 0 3px 0 rgba(120, 20, 0, 0.35), 0 10px 30px rgba(18,48,62,0.4);
  opacity: 0; pointer-events: none;
}
#flash.show { animation: flashIn 0.9s ease-out; }
@keyframes flashIn { 0% { opacity: 0; transform: translate(-50%,-50%) scale(0.6) rotate(-6deg);} 15% {opacity:1; transform: translate(-50%,-50%) scale(1.15) rotate(2deg);} 80%{opacity:1;} 100% { opacity: 0; } }

#chargeBar {
  position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%);
  width: 130px; height: 10px; border-radius: 99px;
  background: rgba(255,255,255,0.5); border: 2px solid rgba(255,255,255,0.9);
  overflow: hidden; opacity: 0; transition: opacity 0.15s;
}
#chargeBar.on { opacity: 1; }
#chargeBar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg,#7ee081,var(--sun),var(--coral)); }

#hint {
  position: absolute; bottom: 14px; left: 14px;
  font-size: 12.5px; line-height: 1.55; padding: 10px 14px;
  transition: opacity 1s ease;
}
#hint.fade { opacity: 0; }
#hint b { color: var(--teal-dark); }

#speedlines {
  position: absolute; inset: 0; opacity: 0; transition: opacity 0.25s;
  background:
    repeating-conic-gradient(
      from 0deg at 50% 46%,
      rgba(255,255,255,0) 0deg 3deg,
      rgba(255,255,255,0.5) 3deg 3.6deg
    );
  mask-image: radial-gradient(circle at 50% 46%, transparent 34%, #000 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 46%, transparent 34%, #000 78%);
  mix-blend-mode: soft-light;
}
#speedlines.on { opacity: 0.55; animation: spinLines 14s linear infinite; }
@keyframes spinLines { to { transform: rotate(360deg); } }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: none; align-items: center; justify-content: center;
  flex-direction: column;
  background: radial-gradient(1200px 700px at 50% 20%, rgba(255,255,255,0.25), rgba(30,70,95,0.35));
}
.overlay.on { display: flex; }

.panel {
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 26px 30px;
  max-width: min(92vw, 560px);
  max-height: 86vh; overflow-y: auto;
  text-align: center;
}

.logo {
  font-size: clamp(38px, 8vw, 58px); font-weight: 900; letter-spacing: 0.04em;
  color: #fff; line-height: 1;
  text-shadow:
    0 2px 0 #2ea9c9, 0 4px 0 #1f88ab,
    0 8px 0 rgba(18,48,62,0.35), 0 14px 30px rgba(18,48,62,0.45);
  margin-bottom: 2px;
}
.tagline { font-size: 14px; font-weight: 600; opacity: 0.7; margin-bottom: 18px; }

.mode-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.mode-card {
  pointer-events: auto; cursor: pointer;
  border: 3px solid transparent; border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #eef7fb);
  box-shadow: 0 6px 18px rgba(18,48,62,0.18);
  padding: 14px 18px; width: 200px;
  transition: transform 0.12s ease, border-color 0.12s ease;
  font-family: inherit;
}
.mode-card:hover { transform: translateY(-3px) scale(1.02); border-color: var(--teal); }
.mode-card .emoji { font-size: 34px; }
.mode-card h3 { font-size: 17px; margin: 4px 0 3px; }
.mode-card p { font-size: 12px; opacity: 0.65; line-height: 1.4; }

.btn {
  pointer-events: auto; cursor: pointer; font-family: inherit;
  border: 0; border-radius: 14px; padding: 12px 22px;
  font-size: 16px; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, var(--teal), var(--teal-dark));
  box-shadow: 0 5px 0 var(--teal-dark), 0 10px 20px rgba(18,48,62,0.25);
  transition: transform 0.08s ease, filter 0.12s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--teal-dark); }
.btn.coral { background: linear-gradient(180deg, #ff8f70, #f2603d); box-shadow: 0 5px 0 #d14e2e, 0 10px 20px rgba(18,48,62,0.25); }
.btn.coral:active { box-shadow: 0 2px 0 #d14e2e; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px rgba(18,48,62,0.25); font-weight: 700; }
.btn.small { padding: 8px 14px; font-size: 13px; border-radius: 11px; box-shadow: 0 3px 0 var(--teal-dark); }
.btn:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }

.menu-foot { display: flex; gap: 10px; justify-content: center; margin-top: 6px; flex-wrap: wrap; }
#bestLine { font-size: 13px; font-weight: 700; opacity: 0.75; margin-top: 12px; }

/* how-to */
.how-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; text-align: left; font-size: 13.5px; margin: 12px 0 4px; align-items: center; }
.key {
  display: inline-block; min-width: 26px; padding: 3px 8px; text-align: center;
  background: #fff; border: 2px solid rgba(18,48,62,0.25); border-bottom-width: 4px;
  border-radius: 8px; font-weight: 800; font-size: 12px;
}

/* results */
.res-big { font-size: 54px; font-weight: 900; color: var(--teal-dark); line-height: 1; margin: 6px 0; }
.rank-stamp {
  display: inline-block; margin: 8px 0 4px; padding: 6px 22px;
  font-size: 40px; font-weight: 900; color: #fff;
  background: linear-gradient(180deg, var(--coral), #e8532f); border-radius: 14px;
  transform: rotate(-4deg); box-shadow: 0 6px 0 rgba(160,60,30,0.5);
}
.res-stats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 12px 0 16px; }
.stat { background: #fff; border-radius: 12px; padding: 8px 14px; min-width: 104px; box-shadow: inset 0 0 0 2px rgba(18,48,62,0.08); }
.stat .v { font-weight: 900; font-size: 19px; }
.stat .k { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.6; }
.newbest { color: #d92c2c; font-weight: 900; font-size: 14px; min-height: 18px; }

/* interstitial */
#interstitial .panel { max-width: min(94vw, 720px); }
.ad-note { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.55; margin-bottom: 10px; }

/* ---------- Ad slots ---------- */
.ad-slot {
  position: fixed; z-index: 8;
  display: none; align-items: center; justify-content: center;
  overflow: hidden;
}
.ad-slot.on { display: flex; }
.ad-slot .ph {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(45deg, rgba(18,48,62,0.06) 0 12px, rgba(18,48,62,0.02) 12px 24px);
  color: rgba(18,48,62,0.45); font-size: 11px; font-weight: 800; letter-spacing: 0.22em;
  border: 1px dashed rgba(18,48,62,0.2); border-radius: 10px;
}
#adTop { top: 0; left: 0; right: 0; height: 68px; background: rgba(255,255,255,0.55); backdrop-filter: blur(4px); border-bottom: 1px solid rgba(255,255,255,0.7); }
#adMenu { bottom: 12px; left: 50%; transform: translateX(-50%); width: min(92vw, 728px); height: 90px; }
.ins-ad { width: 100%; height: 100%; display: block; }

/* ---------- Touch controls ---------- */
#touchui { position: fixed; inset: 0; z-index: 6; pointer-events: none; display: none; }
#touchui.on { display: block; }
.tbtn {
  position: absolute; pointer-events: auto;
  width: 76px; height: 76px; border-radius: 50%;
  background: rgba(255,255,255,0.5); border: 2px solid rgba(255,255,255,0.85);
  box-shadow: var(--shadow); backdrop-filter: blur(4px);
  font-size: 26px; font-weight: 900; color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
.tbtn:active { background: rgba(15,185,168,0.55); }
#tLeft { left: 18px; bottom: 96px; }
#tRight { left: 108px; bottom: 96px; }
#tJump { right: 18px; bottom: 96px; width: 92px; height: 92px; font-size: 15px; }
#tGrab { right: 122px; bottom: 116px; font-size: 14px; }

/* ---------- Error overlay ---------- */
#err {
  position: fixed; inset: 0; z-index: 99; display: none;
  align-items: center; justify-content: center; background: #12303e; color: #fff;
  text-align: center; padding: 30px; font-size: 16px; line-height: 1.6;
}

@media (max-width: 720px) {
  #hint { display: none; }
  #adMenu { height: 64px; }
  .mode-card { width: 46vw; max-width: 200px; }
}

/* compact HUD for narrow screens — panels must never overlap */
@media (max-width: 620px), (max-height: 480px) {
  #hudScore { min-width: 0; padding: 7px 10px; top: 8px; left: 8px; }
  #scoreVal { font-size: 21px; }
  #hudTimer { min-width: 0; padding: 7px 10px; top: 8px; right: 8px; }
  #timerVal { font-size: 22px; }
  #hudDist { top: auto; bottom: 74px; padding: 5px 12px; }
  #distVal { font-size: 15px; }
  #hudSpeed { width: 128px; padding: 7px 10px; bottom: 8px; right: 8px; }
  #speedVal { font-size: 17px; }
  #popups { top: 18%; }
  .popup { font-size: 21px; }
  .popup small { font-size: 14px; }
  #flash { font-size: 40px; }
  #chargeBar { bottom: 60px; width: 96px; }
}

