:root {
  color-scheme: light;
  --sky: #a9dce8;
  --sky-deep: #5d9ec0;
  --ink: #234259;
  --ink-soft: #607e8f;
  --cream: #fff9e9;
  --card: rgba(255, 252, 242, .96);
  --coral: #f47c65;
  --sun: #ffcf61;
  --mint: #8fd5bd;
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Nunito", sans-serif;
  font-family: var(--font-body);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body {
  min-height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background: #d7eff0;
  font-family: var(--font-body);
}
button, a { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible {
  outline: 3px solid #e5775f;
  outline-offset: 4px;
}
[hidden] { display: none !important; }

.game-shell {
  width: 100%;
  min-height: 100dvh;
  padding: 16px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 12% 16%, rgba(255,255,255,.78), transparent 31%),
    radial-gradient(ellipse at 93% 87%, rgba(255,219,165,.55), transparent 33%),
    linear-gradient(145deg, #d9f0eb 0%, #d9edf0 55%, #f0e8d6 100%);
}
.game-world {
  position: relative;
  isolation: isolate;
  width: min(100%, 1440px);
  height: min(calc(100dvh - 32px), 900px);
  min-height: 540px;
  overflow: hidden;
  border: 1px solid rgba(42, 83, 103, .16);
  border-radius: 27px;
  background: linear-gradient(180deg, #83c4dc 0%, #aadce2 42%, #f1dcb5 100%);
  box-shadow: 0 26px 80px rgba(47, 98, 117, .21), 0 4px 13px rgba(38, 76, 91, .11);
}
#game-world > canvas {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.world-sky {
  position: absolute;
  inset: 0;
  z-index: -4;
  background:
    radial-gradient(ellipse at 51% 57%, rgba(255,251,223,.92) 0%, rgba(255,247,216,.37) 19%, transparent 48%),
    linear-gradient(180deg, #70b9d5 0%, #a5d9e3 44%, #f4e2c0 100%);
}
.world-art {
  position: absolute;
  z-index: -3;
  inset: 0;
  background: url("./cover.png") center 57% / cover no-repeat;
  opacity: .86;
  filter: saturate(.9);
  transform: scale(1.018);
  animation: drift-in 1.1s cubic-bezier(.2,.75,.22,1) both;
}
.world-vignette {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(24,73,98,.18), transparent 24%, transparent 70%, rgba(37,83,103,.1));
}
.topbar {
  position: absolute;
  z-index: 5;
  inset: 0 0 auto;
  height: 76px;
  padding: 0 30px;
  display: flex;
  align-items: center;
  gap: 22px;
  color: #fffdf2;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  font: 700 16px/1 var(--font-display);
  letter-spacing: .1em;
  text-shadow: 0 1px 12px rgba(24,72,97,.22);
}
.brand-mark { position: relative; display: inline-flex; width: 25px; height: 24px; align-items: center; justify-content: center; }
.brand-mark i { position: absolute; bottom: 2px; display: block; width: 15px; height: 13px; border-radius: 100% 100% 70% 70%; background: #fff2cc; transform: rotate(-8deg); }
.brand-mark i:nth-child(2) { width: 12px; height: 16px; left: 1px; bottom: 6px; background: #ffba76; transform: rotate(-29deg); }
.brand-mark i:nth-child(3) { width: 11px; height: 15px; right: 1px; bottom: 6px; background: #ff8971; transform: rotate(28deg); }
.identity-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 33px;
  padding: 0 11px;
  border: 1px solid rgba(255,255,255,.26);
  border-radius: 99px;
  background: rgba(45,94,117,.26);
  color: rgba(255,255,255,.94);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .01em;
  backdrop-filter: blur(12px);
}
.identity-dot { width: 7px; height: 7px; border-radius: 50%; background: #ffd16e; box-shadow: 0 0 0 3px rgba(255,209,110,.18); }
.identity-separator { height: 13px; width: 1px; background: rgba(255,255,255,.27); }
.account-label { color: rgba(255,255,255,.72); font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 11px; margin-left: auto; }
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: rgba(255,255,255,.9);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.connection-status > span { width: 7px; height: 7px; border-radius: 50%; background: #b2e8b9; box-shadow: 0 0 0 3px rgba(178,232,185,.2); }
.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.36);
  border-radius: 50%;
  color: #fffdf3;
  background: rgba(54,103,125,.22);
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: transform .18s ease, background-color .18s ease;
}
.icon-button:hover { transform: translateY(-2px); background-color: rgba(255,255,255,.2); }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sound-off { display: none; }
.sound-button[aria-pressed="true"] .sound-on { display: none; }
.sound-button[aria-pressed="true"] .sound-off { display: block; }

.hud {
  position: absolute;
  z-index: 4;
  top: 91px;
  left: 30px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.stat-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 111px;
  height: 52px;
  padding: 0 13px;
  border: 1px solid rgba(255,255,255,.58);
  border-radius: 15px;
  background: rgba(255,251,233,.84);
  box-shadow: 0 7px 20px rgba(46,93,109,.1);
  backdrop-filter: blur(12px);
}
.stat-icon { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 9px; font-size: 16px; }
.score-icon { color: #e67f58; background: #ffe5cb; }
.gem-icon { color: #4d9d9b; background: #d8f3e7; font-size: 14px; }
.distance-icon { color: #6988b7; background: #e2e8ff; font-size: 19px; }
.stat-copy { display: grid; gap: 1px; }
.stat-copy small, .run-recap small {
  color: #7e9295;
  font: 800 8px/1.15 var(--font-body);
  letter-spacing: .11em;
}
.stat-copy strong { color: #2a4a5e; font: 700 16px/1.1 var(--font-display); }
.stat-copy em { color: #79909a; font: 700 10px var(--font-body); font-style: normal; }
.pause-button { width: 40px; height: 40px; margin-left: 3px; color: #31546a; border-color: rgba(255,255,255,.6); background: rgba(255,251,233,.84); }
.pause-button svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.world-caption {
  position: absolute;
  left: 50%;
  bottom: 28px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(42,79,96,.68);
  font: 700 9px/1 var(--font-display);
  letter-spacing: .2em;
  white-space: nowrap;
  transform: translateX(-50%);
}
.caption-line { width: 25px; height: 1px; background: rgba(54,93,106,.4); }

.screen-card {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: min(426px, calc(100% - 36px));
  padding: 34px 38px 26px;
  border: 1px solid rgba(255,255,255,.95);
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 28px 80px rgba(35,80,98,.23), 0 4px 15px rgba(40,81,91,.1);
  text-align: center;
  transform: translate(-50%,-47%);
  animation: card-arrive .55s cubic-bezier(.2,.75,.22,1) both;
}
.start-card { padding-top: 33px; }
.card-eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #cc8063;
  font: 800 9px/1.1 var(--font-display);
  letter-spacing: .17em;
}
.eyebrow-star { color: #e6aa47; font-size: 13px; }
.screen-card h1, .screen-card h2 {
  margin: 15px 0 11px;
  color: #284b61;
  font: 700 37px/.98 var(--font-display);
  letter-spacing: -.065em;
}
.screen-card h1 span, .screen-card h2 span:not(.title-cloud) { color: #e57e63; }
.intro-copy {
  max-width: 310px;
  margin: 0 auto;
  color: #708893;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}
.button {
  position: relative;
  min-height: 52px;
  border: 0;
  border-radius: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 19px;
  font: 900 15px/1 var(--font-body);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.button:hover { transform: translateY(-2px); filter: saturate(1.08); }
.button:active { transform: translateY(1px) scale(.99); }
.button:disabled { cursor: not-allowed; opacity: .65; filter: saturate(.55); box-shadow: none; transform: none; }
.renderer-warning { margin: 13px 0 0; color: #a4513f; font-size: 11px; font-weight: 800; line-height: 1.45; }
.button-primary {
  width: 100%;
  margin-top: 24px;
  color: #fffdf3;
  background: linear-gradient(135deg, #f28e69, #ed755f);
  box-shadow: 0 8px 0 #d96354, 0 13px 23px rgba(211,101,77,.2);
}
.button-primary:hover { box-shadow: 0 9px 0 #d96354, 0 16px 27px rgba(211,101,77,.23); }
.button-arrow { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,.19); font-size: 16px; }
.card-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 9px;
  margin-top: 17px;
}
.text-button, .leaderboard-link {
  padding: 6px;
  border: 0;
  color: #577483;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}
.text-button:hover, .leaderboard-link:hover { color: #d96f5b; }
.text-button span { color: #d9795f; margin-left: 3px; }
.foot-note { width: 100%; color: #9aa9a8; font-size: 10px; font-weight: 700; }
.leaderboard-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 17px;
  padding: 9px 14px;
  border: 1px solid #e9e5d7;
  border-radius: 99px;
  color: #496b7d;
  background: rgba(255,255,255,.44);
}
.trophy { color: #d9a248; font-size: 15px; }
.leaderboard-link-arrow { color: #d9795f; font-size: 15px; }

.pause-card, .gameover-card { width: min(400px, calc(100% - 36px)); }
.pause-card h2 { margin-top: 12px; }
.title-cloud { display: inline-block; color: #90c7d5; font-size: 22px; vertical-align: top; transform: rotate(-12deg); }
.pause-glyph { display: flex; justify-content: center; gap: 5px; margin: 0 auto 14px; }
.pause-glyph span { width: 9px; height: 19px; border-radius: 8px; background: #f18a6b; transform: rotate(10deg); }
.pause-glyph span:nth-child(2) { background: #f4c65d; transform: rotate(-10deg); }
.keyboard-hint { margin: 18px 0 0; color: #93a4a7; font-size: 10px; font-weight: 800; }
kbd { display: inline-grid; place-items: center; min-width: 21px; height: 19px; padding: 0 5px; border: 1px solid #d6ded8; border-bottom-width: 2px; border-radius: 5px; color: #66818a; background: #fffdf6; font: 800 9px var(--font-display); }
.gameover-card { padding-top: 30px; }
.gameover-card h2 { font-size: 35px; }
.run-recap { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; padding: 14px; border: 1px solid #eee8d9; border-radius: 14px; background: #fffdf5; }
.run-recap > div { display: grid; gap: 5px; }
.run-recap > div + div { border-left: 1px solid #eee8d9; }
.run-recap strong { color: #2a4a5e; font: 700 19px/1 var(--font-display); }
.recap-gem { color: #60b9a6; font-size: 14px; }
.save-status { margin: 13px 0 -10px; color: #879b9f; font-size: 11px; font-weight: 700; }
.gameover-card .button-primary { margin-top: 23px; }
.gameover-leaderboard { margin-top: 13px; }

.leaderboard-panel {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: 50%;
  width: min(468px, calc(100% - 36px));
  padding: 27px 29px 19px;
  border: 1px solid rgba(255,255,255,.96);
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 28px 80px rgba(35,80,98,.27);
  transform: translate(-50%,-50%);
  animation: card-arrive .3s cubic-bezier(.2,.75,.22,1) both;
}
.leaderboard-head { display: flex; align-items: flex-start; justify-content: space-between; }
.leaderboard-head .card-eyebrow { justify-content: flex-start; color: #b87b64; font-size: 8px; }
.leaderboard-head h2 { margin: 8px 0 0; color: #284b61; font: 700 29px/1 var(--font-display); letter-spacing: -.06em; }
.close-button { flex: 0 0 auto; width: 36px; height: 36px; color: #607d89; border-color: #e6e6dc; background: #fffdf6; }
.close-button svg { width: 17px; height: 17px; }
.leaderboard-tabs { display: flex; gap: 6px; margin: 22px 0 18px; padding: 4px; border-radius: 11px; background: #f0efe5; }
.leader-tab { flex: 1; padding: 9px 5px; border-radius: 8px; color: #84979a; text-align: center; font-size: 11px; font-weight: 900; }
.leader-tab.is-active { color: #406475; background: #fffdf5; box-shadow: 0 2px 5px rgba(52,89,95,.1); }
.leaderboard-column-labels { display: flex; justify-content: space-between; padding: 0 8px 9px; border-bottom: 1px solid #e9e7dc; color: #93a3a1; font: 800 8px var(--font-display); letter-spacing: .1em; }
.leaderboard-list { display: grid; gap: 6px; min-height: 151px; max-height: 230px; overflow-y: auto; margin: 0; padding: 9px 0; list-style: none; }
.leaderboard-empty { display: flex; align-items: center; justify-content: center; gap: 13px; color: #62808c; text-align: left; font-size: 12px; font-weight: 800; }
.leaderboard-empty small { display: inline-block; margin-top: 4px; color: #98a8a6; font-size: 10px; font-weight: 700; }
.empty-spark { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 13px; color: #dcae4e; background: #fff2d3; font-size: 19px; }
.leaderboard-entry { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; min-height: 48px; padding: 5px 9px; border-radius: 10px; color: #536f7c; font-size: 12px; font-weight: 800; }
.leaderboard-entry:nth-child(odd) { background: #f7f4e9; }
.leaderboard-rank { color: #cb9a48; font: 700 13px var(--font-display); }
.leaderboard-entry strong { color: #31546a; font: 700 14px var(--font-display); }
.leaderboard-entry.is-current-player { outline: 2px solid rgba(106,175,154,.38); background: #e4f4e8; }
.leaderboard-foot { display: flex; align-items: center; gap: 7px; padding-top: 13px; border-top: 1px solid #eeebdf; color: #99a8a4; font-size: 10px; font-weight: 800; }
.sync-mark { color: #6aaf9a; font-size: 15px; }

.touch-controls {
  position: absolute;
  z-index: 2;
  inset: auto 26px 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
}
.direction-controls { display: flex; gap: 10px; }
.control-button {
  display: grid;
  place-items: center;
  min-width: 60px;
  min-height: 60px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 20px;
  color: #315b6c;
  background: rgba(255,250,229,.76);
  box-shadow: 0 5px 0 rgba(66,113,126,.22), 0 9px 20px rgba(45,91,109,.12);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  pointer-events: auto;
  backdrop-filter: blur(9px);
  transition: transform .12s ease, background-color .12s ease;
}
.control-button:hover { background: rgba(255,255,247,.95); }
.control-button:active { transform: translateY(3px); }
.direction-button span { font: 700 27px/1 var(--font-display); }
.jump-button {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 72px;
  min-width: 72px;
  min-height: 72px;
  border-radius: 50%;
  color: #fffdf3;
  border-color: rgba(255,255,255,.64);
  background: linear-gradient(145deg,#f59570,#e97561);
  box-shadow: 0 5px 0 #ce6959, 0 10px 22px rgba(183,93,76,.23);
}
.jump-button:hover { background: linear-gradient(145deg,#f8a27d,#e87961); }
.jump-symbol { font: 700 25px/1 var(--font-display); }
.jump-button > span:last-child { font: 900 8px/1 var(--font-display); letter-spacing: .15em; }
.keyboard-controls {
  position: absolute;
  z-index: 2;
  right: 30px;
  bottom: 33px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(42,79,96,.73);
  font: 700 9px var(--font-body);
}
.keyboard-controls span { margin: 0 6px 0 1px; }
.toast {
  position: absolute;
  z-index: 10;
  top: 78px;
  left: 50%;
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 99px;
  color: #426476;
  background: rgba(255,251,233,.94);
  box-shadow: 0 8px 25px rgba(47,92,109,.15);
  font-size: 12px;
  font-weight: 800;
  transform: translateX(-50%);
}
.loading-screen {
  position: absolute;
  z-index: 12;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 17px;
  color: #fffdf2;
  background: rgba(67,133,157,.7);
  backdrop-filter: blur(6px);
  font-weight: 800;
}
.loading-screen p { margin: 0; }
.loading-orbit { position: relative; display: flex; gap: 6px; }
.loading-orbit i { width: 10px; height: 10px; border-radius: 50%; background: #ffcb61; animation: bob 850ms ease-in-out infinite alternate; }
.loading-orbit i:nth-child(2) { background: #fff4d3; animation-delay: 140ms; }
.loading-orbit i:nth-child(3) { background: #f48a6a; animation-delay: 280ms; }

@keyframes drift-in { from { opacity: .5; transform: scale(1.06) translateY(9px); } to { opacity: .86; transform: scale(1.018) translateY(0); } }
@keyframes card-arrive { from { opacity: 0; transform: translate(-50%,-43%); } to { opacity: 1; transform: translate(-50%,-47%); } }
@keyframes bob { to { transform: translateY(-7px); } }

@media (min-width: 1100px) and (min-height: 700px) {
  .screen-card { margin-top: -13px; }
}
@media (max-width: 767px) {
  body { overflow: hidden; }
  .game-shell { min-height: 100dvh; padding: 0; }
  .game-world { width: 100%; height: 100dvh; min-height: 520px; border: 0; border-radius: 0; }
  .world-art { inset: 0; background-position: 100% center; background-size: auto 100%; opacity: .76; }
  .world-vignette { background: linear-gradient(180deg, rgba(24,73,98,.23), transparent 22%, transparent 66%, rgba(37,83,103,.12)); }
  .topbar { height: 64px; padding: 0 16px; gap: 9px; }
  .brand { gap: 7px; font-size: 13px; }
  .brand-mark { transform: scale(.87); }
  .identity-badge { gap: 6px; min-height: 30px; max-width: 150px; padding: 0 8px; font-size: 9px; }
  #player-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top-actions { gap: 8px; }
  .connection-status { width: 8px; overflow: hidden; gap: 10px; color: transparent; white-space: nowrap; }
  .connection-status > span { flex: 0 0 7px; }
  .icon-button { width: 37px; height: 37px; }
  .hud { top: 75px; left: 14px; gap: 6px; }
  .stat-pill { min-width: 0; height: 43px; gap: 6px; padding: 0 8px; border-radius: 13px; }
  .stat-icon { width: 23px; height: 23px; font-size: 13px; }
  .stat-copy small { font-size: 7px; }
  .stat-copy strong { font-size: 13px; }
  .stat-copy em { font-size: 9px; }
  .pause-button { width: 36px; height: 36px; margin-left: 0; }
  .screen-card { top: 49%; width: min(390px, calc(100% - 32px)); padding: 29px 25px 22px; border-radius: 21px; }
  .screen-card h1 { margin-top: 13px; font-size: clamp(32px, 9vw, 37px); }
  .screen-card h2 { font-size: 34px; }
  .intro-copy { max-width: 290px; font-size: 12px; }
  .button-primary { margin-top: 21px; }
  .card-foot { margin-top: 15px; }
  .leaderboard-link { margin-top: 13px; }
  .world-caption { bottom: 115px; font-size: 7px; letter-spacing: .14em; gap: 7px; }
  .caption-line { width: 14px; }
  .touch-controls { inset: auto 16px max(18px, env(safe-area-inset-bottom)); align-items: flex-end; }
  .direction-controls { gap: 9px; }
  .control-button { width: 62px; min-width: 62px; min-height: 62px; border-radius: 20px; }
  .jump-button { width: 76px; min-width: 76px; min-height: 76px; border-radius: 50%; }
  .keyboard-controls { display: none; }
  .pause-card, .gameover-card { top: 48%; }
  .leaderboard-panel { width: calc(100% - 28px); padding: 23px 19px 17px; }
  .toast { top: 72px; font-size: 11px; }
}
@media (max-width: 380px) {
  .topbar { padding-inline: 11px; }
  .identity-badge { max-width: 119px; }
  .hud { left: 10px; gap: 4px; }
  .stat-pill { padding-inline: 6px; }
  .stat-icon { width: 20px; height: 20px; }
  .stat-copy small { letter-spacing: .06em; }
  .control-button { width: 57px; min-width: 57px; min-height: 57px; }
  .jump-button { width: 70px; min-width: 70px; min-height: 70px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
