/* DaniParkour UI ------------------------------------------------------- */
:root {
  --ink: #1b1235;
  --paper: #fffdf7;
  --pink: #ff5fa2;
  --grape: #7b4bff;
  --sky: #33c9ff;
  --lime: #7df06a;
  --gold: #ffd23f;
  --gem: #59e8ff;
  --shadow: 0 6px 0 rgba(27, 18, 53, .35);
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #0d0a1c; color: var(--ink);
  user-select: none; -webkit-user-select: none;
  /* stop the page itself panning, bouncing or zooming under the game */
  overscroll-behavior: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

#app { position: fixed; inset: 0; }
canvas { display: block; }
.hidden { display: none !important; }

/* cursor is hidden while the game has the mouse; ESC gives it back */
body.cursor-hidden, body.cursor-hidden canvas { cursor: none; }

#resume-hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(27, 18, 53, .88); color: #fff; border: 3px solid var(--gold);
  border-radius: 18px; padding: 16px 30px; font-weight: 800; font-size: 18px;
  text-align: center; pointer-events: none; line-height: 1.5;
}
#resume-hint .sub { font-size: 13px; font-weight: 700; opacity: .7; margin-top: 4px; }

/* ---------------------------------------------------------------- panels */
.panel {
  background: rgba(255, 253, 247, .92);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 8px 14px;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.panel .label { font-size: 11px; letter-spacing: .18em; font-weight: 700; opacity: .55; }
.panel .big { font-size: 34px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.panel .sub { font-size: 12px; font-weight: 700; opacity: .6; font-variant-numeric: tabular-nums; }
.panel.small { font-size: 14px; font-weight: 700; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#hud-left { position: absolute; top: 16px; left: 16px; display: flex; flex-direction: column; gap: 10px; }
#hud-right { position: absolute; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; width: 210px; }

.wallet { display: flex; gap: 14px; justify-content: flex-end; }
.coin { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.coin.big { font-size: 30px; }
.ico { font-size: 20px; }
.ico.gem { color: var(--gem); text-shadow: 0 0 6px rgba(89, 232, 255, .8); }
.ico.tix { filter: saturate(1.4); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #f5a623; margin-right: 6px; }
.dot.on { background: var(--lime); }
.dot.off { background: #ff5b5b; }

#board { width: 100%; }
#board ol { margin: 4px 0 0; padding-left: 20px; font-size: 13px; font-weight: 700; }
#board li { margin: 1px 0; font-variant-numeric: tabular-nums; }
#board li.me { color: var(--pink); }
#board li.empty { list-style: none; margin-left: -14px; opacity: .5; font-weight: 600; }

#gear-strip {
  position: absolute; left: 16px; bottom: 54px;
  display: flex; gap: 8px; flex-wrap: wrap; max-width: 44vw;
}
.chip {
  background: rgba(27, 18, 53, .78); color: #fff; border: 2px solid rgba(255, 255, 255, .25);
  border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 700; letter-spacing: .04em;
}
.chip.tool { background: rgba(123, 75, 255, .85); }

#hint {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 92px;
  background: rgba(27, 18, 53, .82); color: #fff; padding: 10px 22px; border-radius: 999px;
  font-weight: 700; font-size: 16px; opacity: 0; transition: opacity .25s; text-align: center;
}
#hint.show { opacity: 1; }

#crosshair-hint {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  color: rgba(255, 255, 255, .55); font-size: 12px; font-weight: 700; letter-spacing: .05em;
}

#toasts { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--gold); border: 3px solid var(--ink); border-radius: 14px;
  padding: 8px 18px; font-weight: 800; box-shadow: var(--shadow);
  animation: pop .3s cubic-bezier(.2, 1.6, .4, 1), fade .5s 1.6s forwards;
}
.toast.bad { background: #ff7a7a; }
.toast.good { background: var(--lime); }
.toast.gem { background: var(--gem); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@keyframes fade { to { opacity: 0; transform: translateY(-14px); } }

/* --------------------------------------------------------------- overlays */
.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(123, 75, 255, .45), rgba(13, 10, 28, .92));
  backdrop-filter: blur(3px); z-index: 10; padding: 20px;
}
.card {
  background: var(--paper); border: 4px solid var(--ink); border-radius: 26px;
  padding: 26px 30px; box-shadow: 0 12px 0 rgba(27, 18, 53, .5); max-width: 620px; width: 100%;
  max-height: 92vh; overflow: auto;
}
.title-card { text-align: center; max-width: 520px; }
h1 {
  margin: 0; font-size: 56px; letter-spacing: -.02em; color: var(--grape);
  text-shadow: 3px 3px 0 var(--gold);
}
h1 span { color: var(--pink); }
h2 { margin: 0 0 6px; font-size: 30px; color: var(--grape); }
.tag { margin: 6px 0 18px; font-weight: 700; opacity: .7; }
.fineprint { font-size: 12px; font-weight: 600; opacity: .55; margin: 16px 0 0; }

.field { display: block; text-align: left; margin: 0 auto 16px; max-width: 300px; }
.field span { font-size: 12px; font-weight: 800; letter-spacing: .12em; opacity: .6; }
.field input {
  width: 100%; margin-top: 4px; padding: 10px 14px; font-size: 18px; font-weight: 700;
  border: 3px solid var(--ink); border-radius: 12px; background: #fff; font-family: inherit;
}

.btn {
  font-family: inherit; font-weight: 800; cursor: pointer;
  border: 3px solid var(--ink); border-radius: 14px; padding: 10px 20px;
  background: var(--gold); box-shadow: 0 5px 0 rgba(27, 18, 53, .45); transition: transform .08s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(27, 18, 53, .45); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.big-btn { font-size: 24px; padding: 12px 46px; background: var(--lime); }
.btn.ghost { background: #fff; font-size: 12px; padding: 8px 14px; }

#boot-error {
  margin-top: 16px; background: #fff0f0; border: 3px solid #ff5b5b; border-radius: 14px;
  padding: 14px 16px; text-align: left; font-size: 13px; font-weight: 700; color: #7a1b1b;
}
#boot-error .why {
  margin: 8px 0; font-family: ui-monospace, Consolas, monospace; font-size: 11px;
  font-weight: 600; word-break: break-all; opacity: .8;
}
#boot-error .fix { font-weight: 600; color: var(--ink); }
#boot-error code { background: var(--ink); color: #fff; padding: 1px 6px; border-radius: 5px; }

.controls { margin-top: 20px; display: grid; gap: 6px; font-size: 13px; font-weight: 700; opacity: .8; }
kbd {
  background: var(--ink); color: #fff; border-radius: 6px; padding: 2px 7px;
  font-size: 12px; font-family: inherit; margin-right: 2px;
}
.muted { opacity: .5; font-weight: 600; }

/* ------------------------------------------------------------------ shop */
.shop-card { max-width: 860px; }
.shop-head { display: flex; align-items: center; gap: 16px; }
.shop-head h2 { flex: 1; }
.big-wallet { border: 3px solid var(--ink); border-radius: 12px; padding: 4px 14px; background: #fff; }

.tabs { display: flex; gap: 8px; margin: 16px 0 14px; flex-wrap: wrap; }
.tab {
  font-family: inherit; font-weight: 800; font-size: 13px; letter-spacing: .06em; cursor: pointer;
  border: 3px solid var(--ink); border-radius: 999px; padding: 7px 16px; background: #fff;
}
.tab.active { background: var(--grape); color: #fff; }

.shop-main { display: grid; grid-template-columns: 244px 1fr; gap: 16px; align-items: start; }
@media (max-width: 780px) { .shop-main { grid-template-columns: 1fr; } }

.preview-pane {
  border: 3px solid var(--ink); border-radius: 18px; padding: 10px;
  background: linear-gradient(160deg, #2a2145, #4a3a7a 60%, #6b4fa8);
  display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0;
}
#preview-canvas {
  width: 100%; height: 300px; border-radius: 12px; display: block;
  cursor: grab; touch-action: none;
}
#preview-canvas:active { cursor: grabbing; }
.preview-buttons { display: flex; gap: 6px; justify-content: center; }
.preview-buttons .tab { padding: 5px 14px; font-size: 11px; }
.preview-hint {
  text-align: center; font-size: 11px; font-weight: 700; color: rgba(255, 255, 255, .55);
}

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.item {
  border: 3px solid var(--ink); border-radius: 16px; padding: 12px; background: #fff;
  display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden;
}
.item.equipped { background: #eaffe4; box-shadow: inset 0 0 0 3px var(--lime); }
.item.locked { background: #f2f0f6; }
.item .swatch { height: 46px; border-radius: 10px; border: 2px solid var(--ink); }
.item .nm { font-weight: 800; font-size: 15px; }
.item .ds { font-size: 12px; font-weight: 600; opacity: .65; min-height: 30px; }
.item .price { font-weight: 800; font-size: 14px; display: flex; align-items: center; gap: 5px; }
.item .btn { padding: 6px 12px; font-size: 13px; }
.badge {
  position: absolute; top: 8px; right: 8px; background: var(--lime); border: 2px solid var(--ink);
  border-radius: 999px; font-size: 10px; font-weight: 800; padding: 2px 8px;
}

.statbar {
  margin-top: 16px; border-top: 3px dashed rgba(27, 18, 53, .2); padding-top: 12px;
  display: flex; gap: 18px; flex-wrap: wrap; font-weight: 800; font-size: 14px;
}
.statbar .up { color: #12a150; }

/* ------------------------------------------------------------ race HUD */
#race-panel {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  min-width: 178px; pointer-events: none;
}
#race-panel .big { color: var(--pink); }
#rival-list { margin: 6px 0 0; padding-left: 20px; font-size: 12px; font-weight: 700; }
#rival-list li { margin: 2px 0; font-variant-numeric: tabular-nums; opacity: .75; }
#rival-list li.me { color: var(--pink); opacity: 1; font-size: 13px; }
#rival-list li.done { color: #12a150; }
#rival-list li.out { opacity: .4; text-decoration: line-through; }

#countdown {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  font-size: 120px; font-weight: 800; color: #fff; letter-spacing: -.03em;
  text-shadow: 0 6px 0 rgba(27, 18, 53, .55), 0 0 40px rgba(255, 210, 63, .8);
  pointer-events: none;
}
#countdown.go { color: var(--lime); font-size: 150px; }

/* --------------------------------------------------------- level select */
.levels-card { max-width: 900px; }
.levels-foot { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }

.level-item {
  border: 3px solid var(--ink); border-radius: 18px; padding: 14px; background: #fff;
  display: flex; flex-direction: column; gap: 8px; text-align: left; position: relative;
}
.level-item .nm { font-weight: 800; font-size: 19px; color: var(--grape); }
.level-item .ds { font-size: 12px; font-weight: 600; opacity: .7; min-height: 34px; }
.level-item .meta { display: flex; gap: 12px; font-size: 12px; font-weight: 800; }
.level-item .pips { letter-spacing: 2px; color: var(--pink); }
.level-item .best { font-size: 12px; font-weight: 700; opacity: .65; font-variant-numeric: tabular-nums; }
.level-item .fee { display: flex; align-items: center; gap: 5px; font-weight: 800; }
.level-item.locked { background: #f2f0f6; }
.level-item .swatch { height: 54px; border-radius: 12px; border: 2px solid var(--ink); }

/* --------------------------------------------------------- high scores */
.scores-card { max-width: 560px; text-align: center; }
.score-table {
  list-style: none; margin: 14px 0; padding: 0; text-align: left;
  font-family: ui-monospace, Consolas, monospace; font-size: 16px; font-weight: 700;
}
.score-table li {
  display: flex; gap: 10px; padding: 6px 12px; border-radius: 8px;
  font-variant-numeric: tabular-nums;
}
.score-table li:nth-child(odd) { background: rgba(123, 75, 255, .07); }
.score-table li.fresh { background: var(--gold); }
.score-table .rank { width: 30px; opacity: .55; }
.score-table .who { flex: 1; letter-spacing: .12em; }
.score-table .when { opacity: .8; }
.score-table li.ghost .who { opacity: .5; }

/* ---------------------------------------------------------- name entry */
.entry-card { max-width: 480px; text-align: center; }
.entry-time { font-size: 40px; font-weight: 800; color: var(--pink); line-height: 1; margin-bottom: 14px; }
.entry-slots { display: flex; gap: 8px; justify-content: center; margin: 8px 0 14px; }
.slot {
  width: 46px; height: 62px; border: 3px solid var(--ink); border-radius: 10px;
  background: #fff; display: flex; align-items: center; justify-content: center;
  font-family: ui-monospace, Consolas, monospace; font-size: 32px; font-weight: 800;
}
.slot.active { background: var(--gold); box-shadow: 0 0 0 4px rgba(255, 210, 63, .45); }
.slot-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.slot-arrow {
  font-family: inherit; font-size: 14px; font-weight: 800; line-height: 1;
  border: 2px solid var(--ink); border-radius: 8px; background: #fff;
  width: 42px; height: 30px; cursor: pointer; color: var(--ink);
}
.slot-arrow:active { background: var(--gold); }
.entry-help { font-size: 12px; font-weight: 700; opacity: .6; margin: 0 0 14px; }

/* ------------------------------------------------------------- results */
.results-card { max-width: 500px; text-align: center; }
.results-place { font-size: 64px; font-weight: 800; color: var(--grape); line-height: 1; }
.results-list {
  list-style: none; margin: 14px 0; padding: 0; text-align: left;
  font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.results-list li { display: flex; gap: 10px; padding: 4px 10px; border-radius: 7px; }
.results-list li.me { background: var(--gold); }
.results-list li.podium .pl { color: #12a150; }
.results-list .pl { width: 34px; opacity: .6; }
.results-list .nm { flex: 1; }
.results-buttons { display: flex; gap: 10px; justify-content: center; }

/* ------------------------------------------------------- touch controls */
#touch-ui {
  position: fixed; inset: 0; z-index: 6; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}

#stick-base {
  position: absolute; width: 140px; height: 140px; margin: -70px 0 0 -70px;
  border-radius: 50%; border: 3px solid rgba(255, 255, 255, .35);
  background: rgba(27, 18, 53, .3); pointer-events: none;
  transition: opacity .15s; opacity: 1;
}
#stick-base.idle { opacity: 0; }
#stick-knob {
  position: absolute; left: 50%; top: 50%; width: 62px; height: 62px;
  margin: -31px 0 0 -31px; border-radius: 50%;
  background: rgba(255, 255, 255, .5); border: 3px solid rgba(27, 18, 53, .5);
}

.touch-btn {
  position: absolute; border: 4px solid var(--ink); border-radius: 50%;
  font-family: inherit; font-weight: 800; color: var(--ink);
  background: rgba(125, 240, 106, .82); box-shadow: 0 5px 0 rgba(27, 18, 53, .4);
  touch-action: none; -webkit-tap-highlight-color: transparent;
}
.touch-btn.down { transform: translateY(4px); box-shadow: 0 1px 0 rgba(27, 18, 53, .4); }
#touch-jump {
  right: max(24px, env(safe-area-inset-right)); bottom: 26px;
  width: 108px; height: 108px; font-size: 19px;
}
#touch-dash {
  right: max(146px, calc(env(safe-area-inset-right) + 122px)); bottom: 40px;
  width: 76px; height: 76px; font-size: 14px; background: rgba(51, 201, 255, .82);
}

/* ------------------------------------------------------- rotate prompt */
#rotate-prompt {
  position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 6px;
  background: linear-gradient(160deg, #2a2145, #0d0a1c); color: #fff; padding: 30px;
}
#rotate-prompt h2 { color: var(--gold); margin: 6px 0; }
#rotate-prompt p { font-weight: 700; opacity: .75; margin: 0; }
.rotate-icon { font-size: 64px; animation: tip 1.6s ease-in-out infinite; }
@keyframes tip { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-90deg); } }

/* =========================================================== SMALL SCREENS */
@media (max-width: 900px), (pointer: coarse) {
  .card { padding: 18px 16px; border-width: 3px; border-radius: 20px; }
  h1 { font-size: 38px; }
  h2 { font-size: 22px; }
  .tag { font-size: 13px; margin-bottom: 12px; }
  .btn { padding: 9px 16px; }
  .btn.big-btn { font-size: 19px; padding: 11px 30px; }

  /* HUD shrinks and tucks in so it never covers the track */
  #hud-left { top: 8px; left: 8px; gap: 6px; }
  #hud-right { top: 8px; right: 8px; gap: 6px; width: auto; }
  .panel { padding: 5px 10px; border-width: 2px; border-radius: 12px; }
  .panel .big { font-size: 22px; }
  .panel .label { font-size: 9px; }
  .panel .sub { font-size: 10px; }
  .coin { font-size: 14px; }
  #board, #soundpanel { display: none; }
  #race-panel { top: auto; bottom: 8px; left: 8px; transform: none; min-width: 0; }
  #race-panel #rival-list { display: none; }
  #crosshair-hint { display: none; }
  #gear-strip { display: none; }
  #hint { bottom: auto; top: 62px; font-size: 13px; padding: 7px 14px; max-width: 70vw; }
  #countdown { font-size: 72px; }
  #countdown.go { font-size: 92px; }

  /* overlays become full-height sheets */
  .overlay { padding: 10px; align-items: flex-start; }
  .card { max-height: 96vh; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  .item { padding: 9px; border-width: 2px; border-radius: 12px; }
  .item .swatch { height: 36px; }
  .item .nm { font-size: 13px; }
  .item .ds { font-size: 11px; min-height: 0; }
  .shop-main { grid-template-columns: 1fr; }
  .preview-pane { position: static; }
  #preview-canvas { height: 210px; }
  .tabs { gap: 5px; margin: 10px 0; }
  .tab { padding: 6px 11px; font-size: 11px; border-width: 2px; }
  .controls { display: none; }
  .fineprint { display: none; }
  .levels-card .level-item .ds { min-height: 0; }
  .score-table { font-size: 13px; }
  .slot { width: 36px; height: 48px; font-size: 24px; }
  .entry-help { display: none; }
  .results-place { font-size: 46px; }
}

/* very short landscape (phones held sideways) - claw back vertical space */
@media (max-height: 480px) {
  .card { padding: 12px 14px; }
  h1 { font-size: 30px; }
  h2 { font-size: 19px; }
  #preview-canvas { height: 160px; }
  .field { margin-bottom: 8px; }
  .field input { padding: 7px 10px; font-size: 15px; }
  .entry-time, .reward-time { font-size: 30px; }
  .payout { margin: 8px 0; }
}

/* ---------------------------------------------------------------- reward */
.reward-card { text-align: center; max-width: 460px; }
.reward-time { font-size: 54px; font-weight: 800; color: var(--pink); line-height: 1; font-variant-numeric: tabular-nums; }
.payout { display: flex; gap: 30px; justify-content: center; margin: 18px 0; }

/* ------------------------------------------------------------- nametags */
.nametag {
  position: absolute; transform: translate(-50%, -100%); pointer-events: none;
  background: rgba(27, 18, 53, .78); color: #fff; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 800; white-space: nowrap; border: 2px solid rgba(255, 255, 255, .3);
}
