:root {
  --ink: #18120e;
  --cream: #fff6e6;
  --saffron: #ff9f2e;
  --maroon: #7d1a22;
  --glass: rgba(16, 12, 10, 0.58);
  --soft: #d9d3cb;
  font-family: "Avenir Next", "Segoe UI", Roboto, system-ui, sans-serif;
  color-scheme: dark;
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0d0b0a; overflow: hidden; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; touch-action: none; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
button { font: inherit; cursor: pointer; }

/* intro */
.panel-screen { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 30%, rgba(125, 26, 34, 0.55), rgba(10, 8, 7, 0.92) 70%); z-index: 20; }
.intro-card { width: min(520px, 100%); color: var(--cream); text-align: center; }
.intro-logo { display: block; width: min(240px, 60vw); height: auto; margin: 0 auto 12px; }
.hud-logo { height: 18px; vertical-align: -4px; margin-right: 2px; }
.kicker { letter-spacing: 0.22em; font-size: 12px; color: var(--saffron); font-weight: 700; }
.intro-card h1 { font-size: clamp(40px, 9vw, 72px); margin: 6px 0 4px; font-weight: 800; letter-spacing: -0.02em; }
.lede { margin: 0 0 22px; color: var(--soft); font-size: 17px; }
#loadbar { height: 6px; background: rgba(255, 255, 255, 0.12); border-radius: 3px; overflow: hidden; }
#loadfill { height: 100%; width: 0; background: linear-gradient(90deg, var(--saffron), #ffd27a); transition: width 0.2s; }
#loadtext { font-size: 13px; color: var(--soft); margin: 8px 0 18px; min-height: 1.2em; }
#startbtn { background: var(--saffron); color: var(--ink); border: 0; border-radius: 999px; padding: 14px 40px;
  font-size: 18px; font-weight: 800; box-shadow: 0 8px 30px rgba(255, 159, 46, 0.35); }
#startbtn:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.intro-controls { margin-top: 22px; font-size: 13px; color: var(--soft); line-height: 1.8; }
.intro-controls b { color: var(--cream); }
.quality { display: inline-block; margin-top: 14px; font-size: 13px; color: var(--soft); }
.quality select { margin-left: 6px; background: rgba(255, 255, 255, 0.1); color: var(--cream); border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 6px; padding: 3px 6px; }
.quality option { color: #000; }

/* hud */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; color: var(--cream); }
#status { position: absolute; left: calc(16px + var(--sl)); top: calc(16px + var(--st)); background: var(--glass); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-radius: 12px; padding: 10px 14px; min-width: 220px; }
#status .title { font-size: 11px; letter-spacing: 0.18em; color: var(--saffron); font-weight: 700; margin-bottom: 4px; }
#found { font-size: 16px; font-weight: 700; }
#mode { font-size: 14px; color: var(--soft); margin-top: 2px; }
#minimap { position: absolute; right: calc(16px + var(--sr)); top: calc(16px + var(--st)); width: 200px; height: 200px; border-radius: 50%;
  border: 3px solid rgba(255, 246, 230, 0.85); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4); background: #6d7d55; }
#topbtns { position: absolute; right: calc(16px + var(--sr)); top: calc(228px + var(--st)); display: flex; gap: 6px; pointer-events: auto; }
#topbtns button { background: var(--glass); color: var(--cream); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 8px; padding: 6px 10px; font-size: 12px; }
/* under the mini-map and its buttons: back to the site (shown only when the game is opened on its own, see index.html) */
#btnback { position: absolute; right: calc(16px + var(--sr)); top: calc(264px + var(--st)); pointer-events: auto; text-decoration: none;
  background: rgba(16, 12, 10, 0.78); color: var(--cream); border: 1px solid rgba(255, 246, 230, 0.5); border-radius: 9px; padding: 8px 14px; font-size: 14px; font-weight: 600; line-height: normal; }
#btnback:hover { background: rgba(255, 176, 48, 0.3); }
#prompt { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); background: var(--glass);
  border-radius: 999px; padding: 10px 22px; font-size: 18px; font-weight: 600; white-space: nowrap; }
#prompt kbd { background: var(--cream); color: var(--ink); border-radius: 5px; padding: 1px 8px; font-weight: 800; margin-right: 4px; }
#card { position: absolute; left: calc(16px + var(--sl)); top: calc(116px + var(--st)); width: min(380px, calc(100% - 260px));
  background: rgba(16, 12, 10, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-left: 5px solid var(--saffron); border-radius: 10px; padding: 11px 15px; }
#card.show { animation: cardin 0.35s ease-out; }
@keyframes cardin { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
.card-tag { font-size: 10px; letter-spacing: 0.18em; color: #7fe08a; font-weight: 800; }
.card-title { font-size: 21px; font-weight: 800; margin: 1px 0 4px; }
.card-body { font-size: 13.5px; line-height: 1.42; color: var(--soft); }
#toast { position: absolute; left: 50%; top: 22px; transform: translateX(-50%); background: var(--glass); border-radius: 999px; padding: 8px 18px; font-size: 15px; }
#bigmap { position: absolute; inset: 0; background: rgba(8, 6, 5, 0.78); display: grid; place-items: center; pointer-events: auto; }
#bigmapcanvas { width: min(96vw, 1040px); height: min(calc(100vh - 56px), 920px); border-radius: 14px; }
.bigmap-hint { position: absolute; bottom: 12px; font-size: 13px; color: var(--soft); }
#finish { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(8, 6, 5, 0.55); pointer-events: auto; }
.finish-card { background: rgba(16, 12, 10, 0.9); border-radius: 16px; padding: 26px 34px; text-align: center; max-width: 92%; }
#finishtext { font-size: 22px; margin: 10px 0 18px; }
#againbtn { background: var(--saffron); border: 0; border-radius: 999px; padding: 10px 28px; font-weight: 800; color: var(--ink); }

/* touch */
#touch { position: absolute; inset: 0; pointer-events: none; z-index: 11; }
#stick { position: absolute; left: calc(28px + var(--sl)); bottom: calc(34px + var(--sb)); width: 132px; height: 132px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12); border: 2px solid rgba(255, 255, 255, 0.35); pointer-events: auto; }
#knob { position: absolute; left: 41px; top: 41px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255, 246, 230, 0.75); }
.tbtn { position: absolute; width: 72px; height: 72px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(16, 12, 10, 0.5); color: var(--cream); font-weight: 800; font-size: 20px; pointer-events: auto; }
#tbtn-use { right: calc(34px + var(--sr)); bottom: calc(120px + var(--sb)); background: rgba(255, 159, 46, 0.75); color: var(--ink); }
#tbtn-run { right: calc(120px + var(--sr)); bottom: calc(40px + var(--sb)); font-size: 15px; }
.tbtn.on { background: rgba(255, 246, 230, 0.8); color: var(--ink); }

#mission { position: absolute; left: calc(16px + var(--sl)); bottom: calc(16px + var(--sb)); width: min(360px, calc(100% - 32px));
  background: rgba(16, 12, 10, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-left: 5px solid #ffb030; border-radius: 10px; padding: 10px 14px; }
.m-tag { font-size: 10px; letter-spacing: 0.18em; color: #ffb030; font-weight: 800; }
#mtext { font-size: 14.5px; line-height: 1.4; margin-top: 3px; }
#mtimer { font-size: 26px; font-weight: 800; color: #ffd27a; margin-top: 4px; font-variant-numeric: tabular-nums; }
#race { position: absolute; left: 50%; top: calc(66px + var(--st)); transform: translateX(-50%); text-align: center;
  background: rgba(10, 30, 40, 0.7); border: 1px solid rgba(79, 216, 255, 0.6); border-radius: 12px; padding: 6px 18px; }
.r-tag { font-size: 10px; letter-spacing: 0.22em; color: #4fd8ff; font-weight: 800; }
#rtime { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
#rinfo { font-size: 12px; color: var(--soft); }
#countdown { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font-size: 120px; font-weight: 900;
  color: #4fd8ff; text-shadow: 0 6px 30px rgba(0, 0, 0, 0.6); }
#card.banner { border-left-color: #ffb030; }
#card.banner .card-tag { color: #ffb030; }
/* phones held sideways: a smaller mini-map, with the buttons under it, clear of the touch buttons */
@media (max-height: 500px) {
  #minimap { width: 132px; height: 132px; right: calc(12px + var(--sr)); top: calc(10px + var(--st)); }
  #topbtns { right: calc(12px + var(--sr)); top: calc(150px + var(--st)); }
  #btnback { right: calc(12px + var(--sr)); top: calc(186px + var(--st)); }
}
@media (max-width: 640px) {
  #mission { bottom: calc(176px + var(--sb)); left: calc(10px + var(--sl)); width: calc(100% - 140px); padding: 7px 10px; }
  #mtext { font-size: 12px; }
  #mtimer { font-size: 20px; }
  #rtime { font-size: 22px; }
  #status { left: calc(10px + var(--sl)); top: calc(10px + var(--st)); min-width: 0; padding: 8px 10px; }
  #found { font-size: 14px; }
  #mode { font-size: 12px; }
  #minimap { width: 120px; height: 120px; right: calc(10px + var(--sr)); top: calc(10px + var(--st)); }
  #topbtns { right: calc(10px + var(--sr)); top: calc(138px + var(--st)); }
  #btnback { right: calc(10px + var(--sr)); top: calc(174px + var(--st)); }
  #prompt { bottom: 262px; font-size: 15px; }
  #card { top: calc(72px + var(--st)); left: calc(10px + var(--sl)); width: calc(100% - 150px); padding: 8px 11px; }
  .card-title { font-size: 17px; }
  .card-body { font-size: 12px; }
  #toast { top: auto; bottom: 240px; font-size: 13px; white-space: nowrap; }
}

/* pop-up panels: event viewer and place info (press E) */
#panel { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(8, 6, 5, 0.62); pointer-events: auto; z-index: 15; padding: 12px; }
.pn-card { position: relative; width: min(860px, 96vw); max-height: 92vh; overflow: auto; background: rgba(22, 15, 13, 0.95);
  border: 1px solid rgba(255, 210, 122, 0.25); border-radius: 16px; padding: 20px 22px 14px; color: var(--cream); box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5); animation: cardin 0.25s ease-out; }
.pn-x { position: absolute; right: 10px; top: 8px; background: none; border: 0; color: var(--soft); font-size: 20px; padding: 4px 8px; }
.pn-tag { font-size: 11px; letter-spacing: 0.18em; color: #ffb030; font-weight: 800; }
.pn-card h2 { font-size: 30px; margin: 4px 0 6px; font-weight: 800; }
.ev-wrap { display: flex; gap: 24px; align-items: flex-start; }
.ev-img { height: min(64vh, 540px); aspect-ratio: 255 / 411; border-radius: 10px; object-fit: cover; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45); flex: none; }
.ev-info { flex: 1; min-width: 0; padding-top: 6px; }
.ev-kind { color: var(--soft); font-size: 16px; margin-bottom: 16px; }
.ev-row { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid rgba(255, 255, 255, 0.1); padding: 10px 0; font-size: 15px; }
.ev-row span { color: var(--soft); }
.ev-row b { color: #ffd27a; text-align: right; }
.ev-count { margin-top: 12px; color: var(--soft); font-size: 13px; }
.pn-foot { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.pn-foot button { background: rgba(255, 255, 255, 0.1); color: var(--cream); border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 8px; padding: 8px 14px; font-size: 14px; }
.pn-foot button:hover { background: rgba(255, 176, 48, 0.25); }
.pn-hint { margin-left: auto; font-size: 12px; color: var(--soft); }
#panel.pn-place .pn-card { width: min(640px, 96vw); }
.pn-place p { font-size: 15px; line-height: 1.55; color: #eee6da; margin: 0 0 10px; }
.pl-facts { margin: 4px 0 8px; padding-left: 18px; font-size: 14px; line-height: 1.55; color: var(--soft); }
.pl-src { font-size: 11.5px; color: #a89f94; margin-top: 10px; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .ev-wrap { flex-direction: column; align-items: center; gap: 12px; }
  .ev-img { height: 40vh; }
  .ev-info { width: 100%; }
  .pn-card { padding: 16px 14px 10px; }
  .pn-card h2 { font-size: 22px; }
  .pn-hint { display: none; }
}

/* "Now on stage" card with the official YouTube player (shown near the main stage) */
#song { position: absolute; right: calc(16px + var(--sr)); bottom: calc(16px + var(--sb)); width: 372px; pointer-events: auto;
  background: rgba(22, 15, 13, 0.92); border: 1px solid rgba(255, 210, 122, 0.3); border-radius: 12px; padding: 8px 8px 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); animation: cardin 0.3s ease-out; z-index: 12; }
.sg-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 2px 4px 6px; }
.sg-tag { font-size: 10px; letter-spacing: 0.18em; color: #ffb030; font-weight: 800; }
.sg-title { font-size: 15px; font-weight: 800; color: var(--cream); }
.sg-x { background: none; border: 0; color: var(--soft); font-size: 16px; padding: 2px 6px; }
.sg-frame iframe { display: block; width: 356px; height: 200px; border: 0; border-radius: 8px; background: #000; }
.sg-foot { font-size: 10.5px; color: var(--soft); padding: 5px 4px 0; }
.sg-foot a { color: #ffd27a; }
@media (max-width: 640px) {
  #song { right: calc(8px + var(--sr)); bottom: auto; top: calc(178px + var(--st)); width: 236px; }
  .sg-frame iframe { width: 220px; height: 200px; }
}
