:root {
  --bg: #476882;
  --ice: #b8e897;
  --snow: #fff9e7;
  --gold: #ffd166;
  --ink: #233e2e;
  --panel: rgba(12, 24, 37, 0.78);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--snow);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
}

button {
  border: 0;
  font: inherit;
}

.game-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% -20%, rgba(255, 225, 181, 0.32), transparent 60%),
    linear-gradient(180deg, #91b5cf 0%, #62879f 54%, #476882 100%);
}

#game {
  object-fit: contain;
  object-position: center;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(100%, calc(100vh * 1040 / 844));
  height: auto;
  aspect-ratio: 1040 / 844;
  max-height: 100%;
  box-sizing: border-box;
  padding: clamp(6px, 1.2vw, 14px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-content: start;
  align-items: start;
  gap: 6px;
  pointer-events: none;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
}

.hud > div {
  min-width: 0;
  max-width: 100%;
  justify-self: start;
  overflow-wrap: anywhere;
  padding: 8px 11px;
  border: 1px solid rgba(237, 248, 255, 0.14);
  border-radius: 12px;
  background: rgba(17, 25, 34, 0.86);
  backdrop-filter: blur(4px);
}

.hud > div:last-child {
  justify-self: end;
  text-align: right;
}

.hud-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.74;
}

.hud strong {
  display: block;
  font-size: clamp(16px, 4vw, 24px);
  line-height: 1.1;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 22px;
  padding: max(24px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
  background: rgba(12, 19, 28, 0.52);
  backdrop-filter: blur(4px);
  text-align: center;
}

.overlay.hidden {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(100%, 360px);
  max-width: 360px;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 62px;
  height: 62px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--snow), var(--ice));
  color: var(--ink);
  font-weight: 900;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.32);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(36px, 12vw, 64px);
  line-height: 0.92;
}

h2 {
  font-size: 38px;
  line-height: 1;
}

.brand p,
#finalScore {
  margin-top: 8px;
  color: rgba(237, 248, 255, 0.82);
  line-height: 1.35;
}

.primary-button {
  width: min(100%, 288px);
  min-height: 56px;
  border-radius: 16px;
  background: var(--gold);
  color: #1b1400;
  font-weight: 850;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}

.primary-button:active,
.control-button:active,
.jump-button:active {
  transform: translateY(1px) scale(0.98);
}

.nickname-field { display: grid; gap: 7px; width: min(100%, 280px); text-align: left; color: rgba(237, 248, 255, 0.84); font-size: 13px; font-weight: 700; }
.nickname-field input { width: 100%; min-height: 46px; border: 1px solid rgba(158, 232, 255, 0.42); border-radius: 8px; background: rgba(17, 25, 34, 0.9); color: var(--snow); padding: 0 13px; outline: none; font: inherit; }
.nickname-field input:focus { border-color: var(--gold); }
.text-button { min-height: 36px; padding: 7px 12px; color: var(--ice); background: transparent; font-weight: 750; text-decoration: underline; text-underline-offset: 4px; }
.status-text { max-width: 300px; color: rgba(237, 248, 255, 0.72); font-size: 13px; line-height: 1.4; }
.leaderboard-overlay { z-index: 7; }
.leaderboard-card { width: min(100%, 390px); border: 1px solid rgba(158, 232, 255, 0.22); border-radius: 14px; padding: 20px; background: rgba(17, 25, 34, 0.96); box-shadow: 0 24px 64px rgba(0,0,0,.4); }
.leaderboard-header { display: flex; justify-content: space-between; align-items: center; }.leaderboard-header h2 { font-size: 30px; }
.icon-button { width: 36px; height: 36px; border-radius: 50%; color: var(--snow); background: rgba(237,248,255,.12); font-size: 27px; line-height: 1; }
.leaderboard-list { min-height: 120px; margin: 15px 0 10px; padding: 0; list-style: none; text-align: left; }
.leaderboard-list li { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 8px; padding: 10px 4px; border-bottom: 1px solid rgba(237,248,255,.1); }.leaderboard-list li.is-player { color: var(--gold); }.rank-place { opacity: .67; font-weight: 800; }.rank-score { font-variant-numeric: tabular-nums; font-weight: 850; }

.touch-controls {
  position: absolute;
  left: 0;
  right: 0;
  width: min(100%, calc(100vh * 1040 / 844));
  margin: 0 auto;
  bottom: calc(max(0px, (100vh - 100vw * 844 / 1040) / 2) + env(safe-area-inset-bottom) + 12px);
  z-index: 3;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 max(18px, env(safe-area-inset-left)) 0 max(18px, env(safe-area-inset-right));
  pointer-events: none;
}

.control-button {
  width: clamp(76px, 22vw, 104px);
  height: clamp(76px, 22vw, 104px);
  border-radius: 50%;
  background: rgba(237, 248, 255, 0.16);
  color: rgba(237, 248, 255, 0.86);
  border: 1px solid rgba(237, 248, 255, 0.24);
  font-size: 56px;
  line-height: 1;
  pointer-events: auto;
  touch-action: none;
  backdrop-filter: blur(8px);
}

.jump-button { width: clamp(88px, 25vw, 114px); height: clamp(88px, 25vw, 114px); align-self: flex-end; border-radius: 50%; background: var(--gold); color: #1b1400; box-shadow: 0 10px 30px rgba(0, 0, 0, .28); font-size: 13px; font-weight: 900; pointer-events: auto; touch-action: none; }

.mobile-tip { max-width: 288px; margin: -8px 0 0; color: rgba(237, 248, 255, .7); font-size: 12px; line-height: 1.45; }

@media (max-height: 680px) {
  .overlay { gap: 14px; padding-top: max(18px, env(safe-area-inset-top)); }
  .brand-mark { width: 52px; height: 52px; }
  .nickname-field input { min-height: 42px; }
  .touch-controls { bottom: calc(max(0px, (100vh - 100vw * 844 / 1040) / 2) + env(safe-area-inset-bottom) + 8px); }
  .control-button { width: 70px; height: 70px; }
  .jump-button { width: 80px; height: 80px; }
}

@media (min-width: 760px) {
  .control-button {
    width: 96px;
    height: 96px;
  }
}

.movement-zone { position: absolute; inset: 0 50% 0 0; z-index: 2; touch-action: none; user-select: none; -webkit-user-select: none; }
.jump-button {
  user-select: none;
  -webkit-user-select: none;
  background: transparent;
  border: 1px solid rgba(237, 248, 255, .35);
  color: rgba(245, 250, 255, .88);
  box-shadow: none;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .8);
  transition: border-color .18s ease, box-shadow .18s ease, color .18s ease;
}
.jump-button.boost-ready {
  background: transparent;
  border-color: rgba(139, 235, 159, .7);
  color: #c3f2cd;
  box-shadow: 0 0 14px rgba(105, 227, 138, .25), inset 0 0 10px rgba(105, 227, 138, .12);
}
.hud > div:nth-child(2) { text-align: center; }
.brand h1 { text-transform: uppercase; font-size: clamp(32px, 9vw, 54px); font-weight: 950; font-style: italic; letter-spacing: -2px; }
.brand-mark { background: #d6bc65; color: #17212b; transform: rotate(-6deg); }
.location-label { display: block; margin-top: 5px; font: 700 9px/1.3 monospace; letter-spacing: .06em; color: #a9c3da; max-width: 130px; }
.developer-credit { color: #b8c6cc; font-size: 12px; line-height: 1.5; text-align: center; }
#menu { overflow-y: auto; touch-action: pan-y; justify-content: safe center; }
#menu > * { flex-shrink: 0; }
.developer-credit a { color: #b8e897; text-decoration: underline; text-underline-offset: 3px; }
.developer-credit a:focus-visible { outline: 2px solid #b8e897; outline-offset: 4px; }

/* Phone camera fills all available space below the compact HUD. */
@media (max-width: 759px), (pointer: coarse) and (max-width: 1024px) and (max-height: 600px) {
  .game-shell {
    --phone-hud-space: calc(92px + env(safe-area-inset-top));
    --phone-board-top: var(--phone-hud-space);
  }

  #game {
    top: var(--phone-board-top);
    bottom: auto;
    height: calc(100% - var(--phone-hud-space));
  }

  .hud {
    top: var(--phone-board-top);
    bottom: auto;
    margin: 0 auto;
    width: 100%;
    height: max-content;
    max-height: none;
    aspect-ratio: auto;
    padding: 0 max(8px, env(safe-area-inset-right)) 10px max(8px, env(safe-area-inset-left));
    transform: translateY(-100%);
  }

  .hud strong {
    font-size: 22px;
  }

  .touch-controls {
    width: 100%;
    bottom: calc(env(safe-area-inset-bottom) + 12px);
  }

  .movement-zone {
    top: var(--phone-board-top);
  }
}
