:root {
  --ink: #1a2c3c;
  --navy: #17324a;
  --cream: #f4efe6;
  --red: #d94b3d;
  --line: rgba(26, 44, 60, 0.12);
  --ski: #3b7dd8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #102030;
  color: var(--ink);
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Avenir Next", "Segoe UI", "Gill Sans", sans-serif;
}

#app {
  position: relative;
  width: min(100%, 430px);
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  background: #8ebfd4;
  overflow: hidden;
}

#stage {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  overflow: hidden;
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

button {
  font: inherit;
  color: inherit;
  touch-action: none;
}

button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  padding:
    max(8px, env(safe-area-inset-top))
    12px
    8px
    12px;
}

#hud::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 72px;
  background: linear-gradient(to bottom, rgba(18, 36, 52, 0.32), transparent);
  pointer-events: none;
}

#hud button { pointer-events: auto; }

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  position: relative;
}

.time {
  font-weight: 750;
  font-size: 26px;
  letter-spacing: -0.04em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(16, 32, 48, 0.45);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.sub {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.88);
  text-shadow: 0 1px 2px rgba(16, 32, 48, 0.4);
  font-variant-numeric: tabular-nums;
}


.hint {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translate(-50%, -50%);
  margin: 0;
  max-width: min(320px, 86%);
  text-align: center;
  color: #fff;
  font-weight: 750;
  font-size: 16px;
  letter-spacing: -0.03em;
  text-shadow: 0 2px 10px rgba(16, 32, 48, 0.45);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.hint.show { opacity: 1; }

.hint.coach {
  top: 22%;
  max-width: min(360px, 92%);
  font-size: 14px;
  line-height: 1.3;
}

#deck {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  background:
    linear-gradient(to bottom, rgba(16, 32, 48, 0.08), transparent 18px),
    #d5e3ea;
}

.leans {
  position: absolute;
  left: 0;
  right: 0;
  top: 18%;
  display: flex;
  flex-flow: row nowrap;
  align-items: flex-start;
  justify-content: center;
  gap: 24px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

.lean {
  position: relative;
  width: min(156px, calc((100% - 24px) / 2));
  aspect-ratio: 1;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 0;
  border-radius: 50%;
  padding: 8px 10px 10px;
  background: var(--cream);
  color: var(--navy);
  box-shadow:
    inset 0 -8px 0 rgba(23, 50, 74, 0.08),
    0 10px 22px rgba(16, 32, 48, 0.1);
  text-align: center;
}

.lean-go {
  background: var(--navy);
  color: #f7f3ec;
  box-shadow:
    inset 0 -8px 0 rgba(0, 0, 0, 0.18),
    0 10px 22px rgba(16, 32, 48, 0.14);
}

.lean svg {
  width: 48%;
  height: 48%;
  display: block;
  flex: 0 0 auto;
}

.lean-name {
  font-size: 13px;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.05;
  white-space: nowrap;
}

.lean-do {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.1;
  opacity: 0.72;
}

.lean.held {
  transform: scale(0.96);
  box-shadow: inset 0 0 0 rgba(0, 0, 0, 0);
}

.lean-go.held { background: #10283c; }

.util {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 68px;
  height: 68px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: #f7f3ec;
  color: #314554;
  box-shadow: 0 8px 16px rgba(16, 32, 48, 0.1);
  display: grid;
  place-items: center;
}

.util svg { width: 28px; height: 28px; display: block; }

#restart { left: max(14px, env(safe-area-inset-left)); }
#mute { right: max(14px, env(safe-area-inset-right)); }
#mute .slash { display: none; }
#mute.is-muted .wave { display: none; }
#mute.is-muted .slash { display: block; }

@media (max-height: 740px) {
  .leans { top: 6%; }
  .lean {
    width: min(124px, calc((100% - 24px) / 2));
  }
  .lean svg { width: 42%; height: 42%; }
  .lean-name { font-size: 12px; }
  .lean-do { font-size: 10px; }
  .util { width: 58px; height: 58px; }
  .util svg { width: 24px; height: 24px; }
}

#boot {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  background: #163044;
  color: #f7f3ec;
  text-align: center;
}

.boot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: min(280px, 100%);
}

.boot-slope {
  position: relative;
  width: 132px;
  height: 56px;
  margin-bottom: 4px;
}

.boot-slope::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  height: 3px;
  border-radius: 999px;
  background: rgba(247, 243, 236, 0.45);
  transform: rotate(18deg);
  transform-origin: 12% 50%;
}

.boot-rider {
  position: absolute;
  left: 0;
  bottom: 16px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f7f3ec;
  box-shadow: 0 8px 0 -5px #8ebfd4;
  animation: schuss-load 1.15s ease-in-out infinite;
}

#boot-text {
  margin: 0;
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.03em;
}

#boot.is-error .boot-rider { animation: none; left: 42%; }

#boot-retry {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  min-height: 44px;
  font: inherit;
  font-weight: 750;
  background: #f7f3ec;
  color: #17324a;
}

@keyframes schuss-load {
  0% { transform: translate(0, 6px); }
  100% { transform: translate(104px, 28px); }
}

@media (prefers-reduced-motion: reduce) {
  .boot-rider {
    animation: none;
    left: 42%;
    bottom: 22px;
  }
}

#menu, #result {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 10px 12px 12px;
  overflow: auto;
}

#result { z-index: 4; background: rgba(18, 36, 52, 0.22); }

.panel {
  width: 100%;
  background: rgba(244, 239, 230, 0.96);
  color: var(--ink);
  border-radius: 20px;
  padding: 14px 14px 12px;
  box-shadow: 0 18px 50px rgba(20, 40, 60, 0.16);
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #5d7284;
}

h1, h2 {
  margin: 0 0 6px;
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 0.95;
}

h1 { font-size: 40px; }
h2 { font-size: 28px; }

.lead {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.35;
}

.result-time {
  margin: 0 0 8px;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.fine {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.35;
  color: #52687a;
}

.desk { display: none; }
@media (hover: hover) and (pointer: fine) {
  .desk { display: block; }
}

.primary {
  display: block;
  width: 100%;
  margin-top: 8px;
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 750;
  letter-spacing: -0.02em;
  border: 0;
  background: var(--navy);
  color: #f7f3ec;
}

.primary:active { transform: scale(0.99); }

#hold-upright {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 30;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #e8f4fa;
  color: var(--navy);
  text-align: center;
}

#hold-upright p {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

@media (orientation: landscape) and (pointer: coarse),
       (orientation: landscape) and (max-height: 500px) {
  #hold-upright { display: flex; }
}

[hidden] { display: none !important; }
