:root {
  --night: #1b2142;
  --ink: #1b1d33;
  --cream: #fff4e6;
  --paper: #fff8ef;
  --amber: #ffbe5c;
  --ember: #ff5a36;
  --muted: rgba(255, 244, 230, .62);
  --serif: "Fraunces", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #a6d3f1; color: var(--ink); font-family: var(--serif); -webkit-font-smoothing: antialiased; }
body { touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; }
a { color: inherit; }

#city { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: default; outline: none; }
/* the HUD sits on the city in the same cream as the intro card */
.hud, .hint, .corner, .guide { opacity: 0; transition: opacity .8s .4s; }
.riding .hud, .riding .hint, .riding .corner, .riding .guide { opacity: 1; }
.riding .hint.gone, .guide:not(.on) { opacity: 0; }

/* ---------- HUD ---------- */
.hud { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: max(16px, env(safe-area-inset-top)) 20px 0; pointer-events: none; }
.title { font: 400 19px/1 var(--serif); letter-spacing: -.01em; padding: 10px 16px; border-radius: 999px; background: rgba(255, 248, 239, .88); box-shadow: 0 8px 24px -12px rgba(27, 29, 51, .35); }
.title em { font-style: italic; color: #c0541f; }
.found { display: flex; align-items: center; gap: 10px; font: 500 12px/1 var(--mono); letter-spacing: .08em; padding: 10px 13px; border-radius: 999px; background: rgba(255, 248, 239, .88); box-shadow: 0 8px 24px -12px rgba(27, 29, 51, .35); }
.dots { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 7px; gap: 3px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(27, 29, 51, .14); transition: background .4s, transform .4s; }
.dots i.on { background: #f0a43a; transform: scale(1.15); }

.hint { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); font: 400 12px/1.4 var(--mono); letter-spacing: .06em; color: var(--ink); white-space: nowrap; pointer-events: none; padding: 8px 14px; border-radius: 999px; background: rgba(255, 248, 239, .85); }
.tag { position: fixed; left: 0; top: 0; z-index: 2; padding: 7px 12px; border-radius: 999px; background: rgba(255, 248, 239, .94); color: var(--ink); font: 500 13px/1 var(--mono); letter-spacing: .02em; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .3s; box-shadow: 0 8px 24px -10px rgba(27, 29, 51, .4); }
.tag.on { opacity: 1; }
.fade { position: fixed; inset: 0; z-index: 1; background: #fff8ef; opacity: 0; pointer-events: none; }
.guide { position: fixed; left: 50%; top: max(70px, calc(env(safe-area-inset-top) + 56px)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 7px 12px 7px 9px; border-radius: 999px; background: rgba(255, 248, 239, .85); font: 500 12px/1 var(--mono); color: var(--ink); pointer-events: none; }
.guide i { width: 16px; height: 16px; display: block; background: #f0a43a; clip-path: polygon(50% 0, 100% 100%, 50% 74%, 0 100%); transition: transform .15s linear; }
.corner { position: fixed; right: 18px; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 8px; }
.link { background: rgba(255, 248, 239, .85); border: 0; padding: 8px 12px; border-radius: 999px; cursor: pointer; font: 400 12px/1 var(--mono); letter-spacing: .06em; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { background: var(--paper); }

.stick { position: fixed; width: 104px; height: 104px; margin: -52px 0 0 -52px; border-radius: 50%; border: 2px solid rgba(255, 248, 239, .8); background: rgba(27, 29, 51, .08); pointer-events: none; opacity: 0; transition: opacity .2s; }
.stick.on { opacity: 1; }
.stick i { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; background: rgba(255, 248, 239, .9); }

/* ---------- screens (intro / finale / list) ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(27, 29, 51, .28); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 5; animation: fade .5s ease both; }
.screen[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.panel { position: relative; width: min(520px, 100%); max-height: calc(100svh - 40px); overflow: auto; padding: 34px 32px 28px; border-radius: 26px; background: var(--paper); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .55); animation: rise .6s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }
.kicker { margin: 0 0 10px; font: 500 12px/1.3 var(--mono); letter-spacing: .08em; color: #c0541f; }
.panel h1 { margin: 0 0 14px; font: 400 clamp(30px, 6vw, 40px)/1.05 var(--serif); letter-spacing: -.02em; }
.panel p { margin: 0 0 18px; font-size: 18px; line-height: 1.5; }
/* the opening ride sits behind the intro card */
#intro { place-items: start; padding: max(22px, env(safe-area-inset-top)) 22px 22px; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.ride { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: var(--night); }
#intro .panel { width: min(410px, 100%); padding: 26px 26px 22px; box-shadow: 0 24px 70px -28px rgba(10, 12, 30, .6); }
#intro .panel h1 { font-size: clamp(28px, 4.6vw, 36px); margin-bottom: 12px; }
#intro .panel p { font-size: 16.5px; margin-bottom: 16px; }
#intro.leaving .panel { animation: panelOut .3s ease forwards; }
#intro.leaving .ride { animation: rideOut .45s .38s ease forwards; }
@keyframes panelOut { to { opacity: 0; transform: translateY(-14px); } }
@keyframes rideOut { to { opacity: 0; } }

.keys { font: 400 12px/1.5 var(--mono) !important; color: rgba(27, 29, 51, .55); margin: 16px 0 0 !important; }
.keys a { color: inherit; }
#keys-touch { display: none; }
.touch #keys-touch { display: block; }
.touch #keys-desktop { display: none; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 13px 20px; border-radius: 999px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink); font: 500 16px/1 var(--serif); text-decoration: none; cursor: pointer; transition: transform .2s, background .2s; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

/* ---------- spot card ---------- */
.card { position: fixed; right: 22px; top: 50%; transform: translateY(-50%); z-index: 4; width: min(400px, calc(100vw - 32px)); max-height: calc(100svh - 120px); overflow: auto; padding: 26px 24px 22px; border-radius: 24px; background: var(--paper); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .6); animation: cardIn .45s cubic-bezier(.2, .8, .2, 1) both; }
.card[hidden] { display: none; }
@keyframes cardIn { from { opacity: 0; transform: translateY(-50%) translateX(20px); } }
.close { position: absolute; top: 12px; right: 14px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(27, 29, 51, .07); color: var(--ink); font-size: 22px; line-height: 1; cursor: pointer; }
.card-n { margin: 0 0 6px; font: 500 11.5px/1 var(--mono); letter-spacing: .1em; color: #c0541f; text-transform: uppercase; }
.card h2 { margin: 0 40px 12px 0; font: 400 26px/1.1 var(--serif); letter-spacing: -.015em; }
.card-body p { margin: 0 0 12px; font-size: 17px; line-height: 1.5; }
.card-body .aside { font-style: italic; color: rgba(27, 29, 51, .7); }
.card-body .win { color: #b14a17; font-style: italic; }
.card-body .row { margin-top: 6px; }
.card-body .small { font: 400 12px/1.5 var(--mono); color: rgba(27, 29, 51, .55); }

/* chess */
.board { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); width: 100%; max-width: 300px; aspect-ratio: 1; margin: 4px 0 12px; border-radius: 8px; overflow: hidden; }
.board button { border: 0; padding: 0; display: grid; place-items: center; font-size: clamp(18px, 5vw, 26px); line-height: 1; cursor: pointer; background: #ead9bd; color: #1b1d33; }
.board button.dk { background: #b58963; }
.board button.last { box-shadow: inset 0 0 0 3px rgba(240, 138, 60, .45); }
.board button.sel { box-shadow: inset 0 0 0 3px var(--ember); }
.board button.hit { animation: hit .5s ease; }
@keyframes hit { 50% { background: #ffcf8a; } }
.board .w { color: #fff; text-shadow: 0 0 1px #000, 0 1px 1px #000; }

/* list view */
.list-panel ol { margin: 0; padding-left: 20px; }
.list-panel li { margin: 0 0 14px; font-size: 16px; line-height: 1.5; }
.list-panel li b { font-weight: 500; }

/* confetti */
.confetti { position: fixed; top: -20px; width: 9px; height: 14px; z-index: 6; pointer-events: none; border-radius: 2px; animation: drop linear forwards; }
@keyframes drop { to { transform: translate(var(--dx), 110vh) rotate(var(--r)); } }

.noscript { position: fixed; inset: 0; display: grid; place-content: center; padding: 24px; max-width: 560px; margin: auto; }

@media (max-width: 640px) {
  .title { font-size: 16px; }
  .found { padding: 8px 10px; font-size: 11px; }
  .dots { display: none; }
  .card { left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; transform: none; max-height: 70svh; animation-name: sheetIn; }
  @keyframes sheetIn { from { opacity: 0; transform: translateY(30px); } }
  .hint { bottom: 60px; font-size: 11px; }
  .corner { left: auto; right: 12px; }
  .title { padding: 9px 13px; }
  .panel { padding: 28px 22px 22px; }
  .panel p { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* the welcome: her, in 2D, over the 3D city */
.welcome { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; gap: 4px; padding: 20px 20px 4svh; background: linear-gradient(to top, rgba(27, 29, 51, .35), rgba(27, 29, 51, 0) 60%); }
.welcome[hidden] { display: none; }
.wfig { position: relative; height: min(600px, 74svh); aspect-ratio: 300 / 790; flex: none; animation: wpop .7s cubic-bezier(.2, 1.4, .4, 1) both; transform-origin: 50% 100%; }
.wfull { display: block; height: 100%; width: auto; filter: drop-shadow(0 14px 18px rgba(0, 0, 0, .3)); }
.bubble { position: relative; align-self: center; width: min(360px, 100%); margin-bottom: 140px; padding: 22px 24px 20px; border-radius: 22px; background: var(--paper); color: var(--ink); box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .5); animation: rise .6s cubic-bezier(.2, .8, .2, 1) .35s both; }
.bubble::before { content: ''; position: absolute; left: -12px; bottom: 34px; border: 12px solid transparent; border-left: 0; border-right-color: var(--paper); }
.bubble p { margin: 0 0 14px; line-height: 1.5; }
.welcome.leaving .wfig { animation: wbye .45s ease-in both; }
.welcome.leaving .bubble { animation: wfade .3s ease-in both; }
@keyframes wpop { from { transform: translateY(60%) scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes wbye { to { transform: translateY(40%) scale(.6); opacity: 0; } }
@keyframes wfade { to { opacity: 0; transform: translateY(10px); } }
@media (max-width: 640px) {
  .welcome { padding-bottom: 12svh; flex-direction: column-reverse; align-items: center; justify-content: flex-end; }
  .wfig { height: 50svh; margin-top: 12px; }
  .bubble { margin: 0; align-self: center; }
  .bubble::before { display: none; }
}

/* minigames */
.minigame { display: block; width: 100%; height: auto; aspect-ratio: 640 / 300; max-height: 34svh; border-radius: 14px; background: #f6ead7; touch-action: none; margin: 4px 0 10px; outline: none; }
.keys-row { position: relative; display: flex; margin: 6px 0 12px; height: 140px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.pkey { flex: 1; min-width: 0; border: 1px solid rgba(27, 29, 51, .25); border-left-width: 0; border-radius: 0 0 8px 8px; background: #fffdf8; box-shadow: inset 0 -6px 0 rgba(27, 29, 51, .06); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; padding: 0 0 8px; font: 500 11px var(--mono); color: rgba(27, 29, 51, .5); transition: background .08s; }
.pkey:first-child { border-left-width: 1px; }
.pkey i { font-style: normal; font-size: 9px; opacity: .6; }
.pkey.blk { position: absolute; top: 0; height: 60%; z-index: 1; border: 0; border-radius: 0 0 5px 5px; background: #24263a; box-shadow: inset 0 -4px 0 rgba(255, 255, 255, .08); color: rgba(255, 253, 248, .45); font-size: 9px; padding-bottom: 6px; }
.pkey.on { background: #ffcf8a; }
.pkey.blk.on { background: #c98a3a; }
.felt { padding: 10px 14px 4px; border-radius: 14px; background: #2f6b4f; margin: 6px 0 12px; }
.felt .small { color: rgba(255, 244, 230, .7) !important; margin: 0 0 4px !important; }
.hand { display: flex; gap: 6px; margin-bottom: 10px; }
.pc { display: grid; place-items: center; width: 40px; height: 56px; border-radius: 6px; background: #fffdf8; color: #1b1d33; font: 500 16px var(--mono); box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.pc.red { color: #c8372b; }
.pc.back { background: repeating-linear-gradient(45deg, #b14a17 0 4px, #d06a33 4px 8px); }
