:root {
  color-scheme: dark;
  --ink: #e9eee9;
  --muted: #a8b4b0;
  --accent: #e46f3c;
  --panel: rgba(18, 30, 35, 0.82);
}

/* Rock / ink / rust. The game remains the primary surface, not a landing page. */
:root .menu, :root .menu[data-scene="outdoor"] { background:#1e2b32; color:#e1e1d7; }
:root .menu h1 { font-size:64px; letter-spacing:2px; margin:36px 0 42px; font-weight:500; }
:root .menu h1 span { font-size:14px; letter-spacing:2px; color:#aebcbd; }
.menu .menu-top, .menu #sceneDescription, .menu .name-label, .menu #saveNotice, .menu .how-to, .menu #boardPanel > p, .menu #pausePanel p { color:#aebcbd; font-size:14px; }
.menu .menu-top button, .menu .back-button { color:#d6b190; font-size:14px; }
.menu .scene-switch { border-radius:3px; background:#172128; border:1px solid #526267; }
.menu .scene-switch button { border-radius:2px; font-size:14px; color:#aebcbd; }
.menu .scene-switch [aria-pressed="true"] { background:#a95c44; color:#fff6e7; }
.menu .level-card { border:1px solid #526267; border-radius:3px; background:#27373f; color:#e5e6dc; padding:19px 12px; }
.menu .level-card small { font-size:14px; color:#aebcbd; }
.menu .level-number { color:#a4b0ad; }
.menu .level-mark { color:#d6b190; }
.menu #playerName { color:#e5e6dc; border-color:#66777c; }
.menu .how-to p { font-size:14px; }
.menu #boardFilter { background:#27373f; color:#e5e6dc; border-radius:3px; }
.menu .primary-button { background:#a95c44; border-radius:3px; }
.menu #rankingList small { color:#aebcbd; font-size:13px; }
.hud #levelTitle { font-size:14px; }
.hud #runClock { font-size:12px; }

[hidden] { display: none !important; }
button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #d88b4f; outline-offset: 3px; }
.hud { color: #293f3d; text-shadow: none; }
.hud > div:first-child { display: grid; grid-template-columns: 32px 1fr; gap: 4px 7px; align-items: center; }
#pauseButton { pointer-events: auto; border: 1px solid #6f877455; border-radius: 10px; color: #344e47; background: #f8f0dbdd; width: 32px; height: 32px; }
#levelTitle { font-size: 13px; font-weight: 750; }
#runClock { grid-column: 2; font-size: 11px; font-variant-numeric: tabular-nums; }
.hud #best { color: #425e50; }
.hud #legLoad { color: #67482c; }
.menu { position: absolute; inset: 0; z-index: 5; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: max(26px, env(safe-area-inset-top)) 25px max(22px, env(safe-area-inset-bottom)); color: #2e4741; background: #f1eddc; }
.menu[data-scene="outdoor"] { background: #dfeadf; }
.menu-top { display:flex; align-items:center; justify-content:space-between; font-size:11px; color:#6a7b69; }
.menu-top button, .back-button { border:0; color:#3e6556; background:transparent; padding:12px 0; font-size:12px; }
.menu h1 { margin:18px 0 0; font-size:66px; line-height:1.1; letter-spacing:-5px; }
.menu h1 span { display:block; font-size:15px; letter-spacing:4px; margin-top:10px; font-weight:500; }
.hero-climber { position:relative; height:142px; margin-top:-74px; margin-bottom:22px; margin-left:auto; width:122px; transform:rotate(9deg); }
.mascot-head { position:absolute; z-index:2; width:78px; height:69px; background:#ffd6a9; border-radius:45%; top:4px; left:17px; box-shadow:inset -6px -4px #efb68c; }
.mascot-head::before { content:''; position:absolute; left:-4px; top:-11px; width:86px; height:31px; border-radius:40px 40px 9px 9px; background:#e98a58; box-shadow:inset -5px -4px #d57b49; }
.mascot-head i { position:absolute; width:6px; height:8px; top:30px; left:23px; border-radius:50%; background:#37443e; }
.mascot-head i+i { left:49px; }
.mascot-head b { position:absolute; top:37px; left:33px; font-size:22px; }
.mascot-body { position:absolute; top:62px; left:16px; width:79px; height:75px; border-radius:30px; background:#eab451; text-align:center; padding-top:15px; color:#f9e8be; font-size:24px; box-shadow:inset -7px -3px #dda044; }
.mascot-hand { position:absolute; top:42px; right:-7px; width:25px; height:58px; border-radius:20px; background:#ffd6a9; transform:rotate(32deg); }
.scene-switch { display:grid; grid-template-columns:1fr 1fr; padding:4px; gap:5px; background:#d9decd; border-radius:14px; }
.scene-switch button { padding:13px 5px; border:0; border-radius:10px; background:transparent; color:#637465; font-size:13px; font-weight:700; }
.scene-switch [aria-pressed="true"] { background:#345c4d; color:#f4eedb; }
#sceneDescription { font-size:12px; margin:13px 0 18px; color:#6b7a66; }
#levelList { display:grid; gap:10px; }
.level-card { display:grid; grid-template-columns:31px 1fr 35px; gap:9px; align-items:center; text-align:left; width:100%; padding:16px 11px; border:1px solid #a9b49d88; background:#fbf8ea; color:#334f42; border-radius:16px; }
.level-card:disabled { opacity:.48; cursor:default; }
.level-number { font-size:12px; color:#89957a; }
.level-card strong { display:block; font-size:16px; }
.level-card small { display:block; margin-top:6px; font-size:10px; line-height:1.5; color:#74816b; }
.level-mark { font-size:11px; color:#aa773b; text-align:right; }
.name-label { margin-top:22px; display:flex; align-items:center; justify-content:space-between; gap:10px; font-size:11px; color:#72806b; }
#playerName { width:106px; border:0; border-bottom:1px solid #adb79c; background:transparent; padding:8px; color:#35533f; text-align:right; font-size:13px; }
#saveNotice { font-size:10px; color:#7b886e; margin:16px 0 0; }
.menu h2 { font-size:32px; margin:24px 0 12px; }
#boardPanel > p { font-size:12px; color:#6b7a66; line-height:1.8; }
#boardPanel > label { display:block; margin:26px 0 8px; font-size:12px; }
#boardFilter { width:100%; padding:14px; background:#fbf8ea; border:1px solid #b9c4aa; border-radius:12px; color:#335343; }
#rankingList { list-style:none; padding:0; margin:22px 0; }
#rankingList li { display:grid; grid-template-columns:28px 1fr auto; align-items:center; gap:9px; padding:16px 0; border-bottom:1px solid #c4cbb7; font-size:13px; }
#rankingList li > span:last-child { text-align:right; }
#rankingList small { display:block; font-size:10px; margin-top:6px; color:#7b816b; }
.empty-ranking { padding:38px 10px; line-height:1.9; font-size:14px; color:#7b816b; }
.how-to { font-size:12px; margin-top:20px; color:#48634f; }
.how-to summary { cursor:pointer; padding:10px 0; }
.how-to p { font-size:12px; line-height:1.8; }
#pausePanel { min-height:80%; display:flex; flex-direction:column; justify-content:center; align-items:center; text-align:center; }
#pausePanel p { font-size:13px; color:#6e7e69; }
.pause-art { font-size:62px; color:#a4b994; }
.primary-button { background:#365f4d; color:#fff1d5; border:0; border-radius:14px; padding:16px 36px; margin-top:25px; }
.in-menu .controls, .in-menu .hud, .in-menu .tutorial { visibility:hidden; }
.game-shell.in-menu { touch-action:pan-y; }
.menu #playerName { font-size:16px; }
#resultDetails { text-align:center; font-size:13px; line-height:1.7; }
.game-over .quiet-button { background:transparent; color:#dae6d5; box-shadow:none; margin:0; }
.controls .joystick-wrap > span { background:#f2efdeeb; border-radius:8px; padding:4px 8px; color:#365744; }
.controls .joystick-wrap.is-critical > span,.controls .joystick-wrap.is-exhausted > span { color:#ae3234; }
.controls .joystick-wrap.is-tired > span { color:#995425; }
@media(max-height:730px) { .menu h1 { font-size:49px; } .hero-climber { height:108px; transform:scale(.8) rotate(9deg); transform-origin:right bottom; margin-bottom:8px; } .level-card { padding:11px; } .name-label { margin-top:12px; } }

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #101a1f;
  font-family: "Avenir Next", "PingFang SC", "Helvetica Neue", sans-serif;
  color: var(--ink);
}

body {
  display: grid;
  place-items: center;
}

.game-shell {
  position: relative;
  width: min(100vw, 480px);
  height: 100dvh;
  max-height: 960px;
  overflow: hidden;
  background: #24343a;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hud {
  position: absolute;
  inset: max(18px, env(safe-area-inset-top)) 18px auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
  text-shadow: 0 1px 12px rgba(5, 12, 15, 0.48);
}

.brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.meters {
  display: grid;
  justify-items: end;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

#height {
  font-size: 22px;
  font-weight: 750;
}

#best {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

#legLoad {
  margin-top: 2px;
  color: #ef9b70;
  font-size: 11px;
  font-weight: 750;
}

.tutorial {
  position: absolute;
  top: 18%;
  left: 50%;
  width: max-content;
  max-width: calc(100% - 48px);
  padding: 11px 15px;
  transform: translateX(-50%);
  border: 1px solid rgba(233, 238, 233, 0.16);
  border-radius: 14px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06);
  pointer-events: none;
  transition: opacity 240ms ease, transform 240ms ease;
}

.tutorial p {
  margin: 0;
  text-align: center;
  font-size: 13px;
  line-height: 1.55;
}

.tutorial p + p {
  color: var(--muted);
}

.hold-legend {
  display: flex;
  max-width: 292px;
  margin: 8px auto 0;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px 9px;
  color: #dce4df;
  font-size: 10px;
}

.hold-legend span::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.hold-legend .hand-hold { color: #e5944f; }
.hold-legend .foothold { color: #718fb5; }
.hold-legend .dual { color: #71ad82; }

.joystick-wrap.is-tired > span {
  color: #ef9b70;
}

.joystick-wrap.is-critical > span,
.joystick-wrap.is-exhausted > span {
  color: #ef5f5f;
  text-shadow: 0 0 10px rgba(239, 95, 95, 0.42);
}

.tutorial.is-hidden {
  opacity: 0;
  transform: translate(-50%, -8px);
}

.game-over {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  background: rgba(10, 21, 27, 0.72);
  backdrop-filter: blur(9px);
}

.game-over[hidden] {
  display: none;
}

.game-over-label {
  margin: 0;
  color: #c8d2cf;
  font-size: 15px;
}

.game-over strong {
  font-size: clamp(46px, 14vw, 68px);
  line-height: 1;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}

.game-over button {
  min-width: 142px;
  margin-top: 10px;
  padding: 13px 22px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #172025;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.24), 0 9px 24px rgba(13, 22, 26, 0.28);
}

.game-over button:active {
  transform: translateY(1px) scale(0.98);
}

.game-over button:focus-visible {
  outline: 3px solid #f3b08e;
  outline-offset: 3px;
}

.controls {
  position: absolute;
  right: 20px;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 20px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
  z-index: 1;
}

.joystick-wrap {
  display: grid;
  justify-items: center;
  gap: 5px;
  color: rgba(233, 238, 233, 0.54);
  font-size: 11px;
  font-weight: 700;
}

.joystick {
  position: relative;
  width: 104px;
  height: 104px;
  border: 1px solid rgba(225, 234, 230, 0.28);
  border-radius: 50%;
  background: rgba(10, 22, 27, 0.48);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 10px 30px rgba(4, 12, 16, 0.2);
  backdrop-filter: blur(5px);
  pointer-events: auto;
  touch-action: none;
}

.joystick::before,
.joystick::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  background: rgba(225, 234, 230, 0.12);
  transform: translate(-50%, -50%);
}

.joystick::before {
  width: 54px;
  height: 1px;
}

.joystick::after {
  width: 1px;
  height: 54px;
}

.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(239, 166, 129, 0.82);
  border-radius: 50%;
  background: rgba(228, 111, 60, 0.82);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.22), 0 4px 14px rgba(5, 13, 16, 0.32);
  transform: translate(-50%, -50%);
  will-change: transform;
}

.joystick.is-active {
  border-color: rgba(240, 160, 120, 0.64);
}

.joystick.is-gripping .joystick-knob {
  background: #f0a078;
  border-color: #f7d0bc;
}

.joystick.is-pulling .joystick-knob {
  box-shadow: 0 0 0 7px rgba(240, 160, 120, 0.16), 0 0 24px rgba(240, 160, 120, 0.72);
}

.joystick.is-blocked .joystick-knob {
  background: #727a79;
  border-color: #a7afac;
  box-shadow: none;
}

.game-shell.is-dead .hud,
.game-shell.is-dead .tutorial,
.game-shell.is-dead .controls {
  filter: grayscale(1);
  opacity: 0.42;
  transition: filter 180ms ease, opacity 420ms ease;
}

@media (max-height: 700px) {
  .joystick {
    width: 90px;
    height: 90px;
  }

  .controls {
    bottom: max(8px, env(safe-area-inset-bottom));
  }
}

@media (min-width: 520px) {
  .game-shell {
    height: min(92dvh, 900px);
    border-radius: 18px;
    box-shadow: 0 30px 80px rgba(2, 10, 14, 0.45);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tutorial,
  button {
    transition: none;
  }
}
#modelStatus{font-size:12px;color:#d5c9ac;margin:10px 0 4px}.model-credit{font-size:10px;color:#9aa9b0;text-decoration:none}
