/* (The base colours, the page and the loader are styled inline in index.html, so the loader
   paints before anything else has downloaded.) */

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

/* The objective and, under it, Dan's lines and the hints: one column, top left, out of the middle of the view (the
   owner: the lines at the bottom were distracting with the objective at the top, and the objective sat front and
   centre; the permanent title tag went). */
#talk-col { position: absolute; top: 16px; left: 16px; width: min(380px, calc(100% - 260px)); display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
/* While a clock shows top-centre (the speedrun timer, a dare's clock: each at most 196 px wide), the column stops 12 px short
   of it, on every width (G-41: below about 900 px it ran under the timer). */
body:has(#run-timer:not(.hidden), #dare-hud:not(.hidden)) #talk-col { width: min(380px, calc(50% - 126px)); }

#stats-panel {
  position: absolute; top: 16px; right: 16px; text-align: right; font-size: 14px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
#stats-panel .score b { font-family: 'Permanent Marker', cursive; font-size: 34px; font-weight: 400; }
#stats-panel .score span {
  display: inline-block; margin-left: 8px; font-family: 'Permanent Marker', cursive; font-size: 22px; color: #ffdf8a;
  transform: rotate(-6deg);
}
#stats-panel .score span.pop { animation: pop 0.25s ease-out; }
@keyframes pop { from { transform: scale(1.6) rotate(-6deg); } to { transform: scale(1) rotate(-6deg); } }
#stats-panel .sub { font-size: 12px; opacity: 0.9; }

#objective {
  transform: rotate(-0.8deg); transform-origin: top left;
  background: var(--paper); color: var(--ink); padding: 4px 14px 6px; border: 2px dashed var(--kraft-dark);
  box-shadow: 0 3px 0 var(--kraft-dark); text-align: left; max-width: 100%;
}
#objective small { display: block; font-size: 8px; font-weight: 700; letter-spacing: 0.25em; text-transform: uppercase; opacity: 0.6; }
#objective span { font-family: 'Permanent Marker', cursive; font-size: 15px; line-height: 1.2; }
#objective.flash { animation: flash 0.6s ease-out; }
@keyframes flash { 0% { transform: scale(1.12) rotate(-0.8deg); } 100% { transform: scale(1) rotate(-0.8deg); } }

/* Dan's lines and the hints: down the left side, out of the middle of the view (the owner: they hid the game). */
#toast {
  margin-left: 6px;
  background: #fffaf0; color: var(--ink); padding: 8px 14px; border-radius: 14px; border: 2px solid var(--ink);
  max-width: 100%; font-size: 15px; font-weight: 700; text-align: left; line-height: 1.3;
  box-shadow: 0 4px 0 rgba(42, 27, 14, 0.45);
}
#toast b { font-family: 'Permanent Marker', cursive; font-weight: 400; margin-right: 8px; color: #8e3b1c; }
#toast.hint { background: var(--kraft); border-style: dashed; font-weight: 500; }
#toast.hint b { color: var(--ink); }

#title-card {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: var(--paper);
  text-shadow: 0 6px 0 var(--kraft-dark), 0 10px 30px rgba(0, 0, 0, 0.5); animation: title 4s ease-in-out forwards;
}
#title-card h1 { font-family: 'Permanent Marker', cursive; font-size: clamp(44px, 9vw, 110px); margin: 0; font-weight: 400; }
#title-card p { margin: 0; letter-spacing: 0.5em; font-weight: 700; text-transform: uppercase; }
@keyframes title { 0% { opacity: 0; transform: scale(1.1); } 15%, 75% { opacity: 1; transform: scale(1); } 100% { opacity: 0; } }

/* A district's name, as Dan first walks in (the rebuilt town): hand-lettered on a torn strip, low on the screen. */
#district {
  position: fixed; left: 50%; bottom: 24%; transform: translateX(-50%); z-index: 9; pointer-events: none; text-align: center;
  font-family: 'Permanent Marker', cursive; font-size: clamp(26px, 4.2vw, 52px); color: var(--paper);
  text-shadow: 0 4px 0 var(--kraft-dark), 0 8px 24px rgba(0, 0, 0, 0.45); opacity: 0; transition: opacity 0.9s ease;
}
#district small { display: block; font-family: inherit; font-size: 0.42em; letter-spacing: 0.3em; text-transform: uppercase; opacity: 0.85; }
#district.show { opacity: 1; }

#fade { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 12; }
/* The film's closing song line, over the flight's white fade (stages/Finale, CL-GD-038 §3.7). */
#song-line { position: fixed; left: 50%; top: 44%; transform: translate(-50%, -50%); z-index: 13; pointer-events: none; width: min(86vw, 760px); text-align: center;
  font-family: 'Permanent Marker', cursive; font-size: clamp(22px, 3.4vw, 40px); line-height: 1.3; color: #2a3a66; opacity: 0; transition: opacity 1.2s ease; }
#song-line.show { opacity: 1; }
.end-pitch { margin: 14px 0 -4px; font-size: 15px; font-style: italic; text-align: center; }
.gold-star { color: #e0a020; text-shadow: 0 0 6px rgba(255, 200, 60, 0.8); }

#end-screen, #fall-screen, #continue-screen, #lost-screen { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; background: rgba(255, 255, 255, 0.35); }
.fall-card { transform: rotate(1.5deg); }
.fall-hint { margin: 12px 0 0; font-size: 13px; opacity: 0.7; }
#lost-screen { z-index: 50; } /* (a lost WebGL context, ui/FailCards: over everything) */
.loader-card .fail-more { max-width: 420px; margin: 10px auto 0; font-weight: 500; } /* (no WebGL2, ui/FailCards) */
@media (max-height: 620px) {
  .end-card { padding: 14px 20px; }
  .end-card h1 { font-size: 26px; }
  .end-sub { margin-bottom: 10px; font-size: 14px; }
  .end-stats { gap: 6px 12px; margin-bottom: 12px; }
  .end-stats div { padding: 4px; }
  .end-stats b { font-size: 20px; }
}
.end-card {
  width: min(92vw, 640px); background: var(--kraft); color: var(--ink); padding: 28px 32px; text-align: center;
  border: 3px dashed var(--kraft-dark); box-shadow: 0 12px 0 var(--kraft-dark); transform: rotate(-1deg);
}
.end-card h1 { font-family: 'Permanent Marker', cursive; font-weight: 400; font-size: clamp(26px, 5vw, 40px); margin: 0 0 6px; }
.end-sub { margin: 0 0 18px; font-style: italic; }
.end-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 20px; margin-bottom: 22px; font-weight: 700; }
.end-stats div { background: rgba(255, 255, 255, 0.35); padding: 8px; border-radius: 6px; }
.end-stats b { display: block; font-family: 'Permanent Marker', cursive; font-weight: 400; font-size: 26px; }
.end-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn {
  font: 700 15px Inter, sans-serif; padding: 12px 20px; border: 3px solid var(--ink); border-radius: 10px; cursor: pointer;
  background: var(--paper); color: var(--ink); text-decoration: none; box-shadow: 0 4px 0 var(--ink);
}
.btn.primary { background: #1f2d55; color: #ffdf8a; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.credits { margin: 18px 0 0; font-size: 11px; opacity: 0.7; }
#stats-panel .mode { text-transform: uppercase; letter-spacing: 0.12em; font-size: 11px; opacity: 0.85; }

#charge {
  position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%);
  width: 220px; height: 14px; background: rgba(42, 27, 14, 0.55); border: 2px solid var(--kraft);
  border-radius: 8px; overflow: hidden; opacity: 0; transition: opacity 0.3s;
}
#charge.visible { opacity: 1; }
#charge-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #f0b35a, #ffdf8a); transform-origin: left; }
#charge span {
  position: absolute; inset: 0; font-size: 9px; font-weight: 700; letter-spacing: 0.3em; text-align: center;
  line-height: 10px; color: var(--ink);
}

#prompt {
  position: absolute; bottom: 110px; left: 50%; transform: translateX(-50%);
  background: var(--kraft); color: var(--ink); padding: 8px 18px; font-weight: 700;
  border: 2px dashed var(--kraft-dark); box-shadow: 0 4px 0 var(--kraft-dark);
}

#help {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  font-size: 12px; opacity: 0.85; text-align: center; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
#help b { color: #ffdf8a; }

#minimap-wrap {
  position: absolute; right: 16px; bottom: 44px; width: 190px; height: 190px;
  pointer-events: auto; cursor: pointer; filter: drop-shadow(0 5px 0 var(--kraft-dark));
}
#minimap { width: 100%; height: 100%; display: block; }
.minimap-hint {
  position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%) rotate(-2deg);
  background: var(--ink); color: var(--paper); font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  padding: 2px 8px; text-transform: uppercase;
}

#bigmap {
  position: fixed; inset: 0; z-index: 15; display: grid; place-items: center;
  background: rgba(26, 18, 10, 0.55); backdrop-filter: blur(3px);
}
.bigmap-card {
  width: min(92vw, 1100px); height: min(90vh, 900px); display: flex; flex-direction: column;
  background: var(--kraft); border: 3px dashed var(--kraft-dark); box-shadow: 0 12px 0 var(--kraft-dark);
  padding: 14px 18px; transform: rotate(-0.6deg); color: var(--ink);
}
.bigmap-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.bigmap-head h2 { font-family: 'Permanent Marker', cursive; font-weight: 400; font-size: 30px; margin: 0; }
.bigmap-head span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.7; }
#bigmap-canvas { flex: 1; min-height: 0; width: 100%; margin: 10px 0; border: 2px solid var(--ink); }
.collection { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 10px; font-size: 13px; font-weight: 700; }
.collection div { background: rgba(255, 255, 255, 0.35); border-radius: 6px; padding: 4px 10px; }
.collection b { font-family: 'Permanent Marker', cursive; font-weight: 400; font-size: 17px; margin-right: 6px; }
.collection .done { background: rgba(255, 214, 90, 0.55); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; font-weight: 700; }
.legend i { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 5px; border: 2px solid var(--ink); }
.k-you { background: #ffdf8a; clip-path: polygon(50% 0, 100% 100%, 50% 75%, 0 100%); border: none !important; }
.k-beast { background: #6b4526; border-radius: 50%; }
.k-light { background: #e0a040; }
.k-strong { background: #8e3b1c; }
.k-ramp { background: repeating-linear-gradient(0deg, #c79656 0 3px, #2a1b0e 3px 4px); }
.k-tall { background: linear-gradient(90deg, #be8c55, #5f3e1e); }

#stock { display: flex; gap: 6px; justify-content: flex-end; margin: 6px 0 2px; }
#stock div {
  display: flex; align-items: center; gap: 4px; background: rgba(42, 27, 14, 0.55); padding: 2px 7px 2px 4px;
  border-radius: 10px; font-weight: 700; font-size: 13px;
}
#stock i { width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid var(--ink); display: inline-block; }
#stock div.pop { animation: pop 0.3s ease-out; }
#build-nudge { position: absolute; top: 118px; right: 16px; background: #ffdf8a; color: var(--ink); font-weight: 700; font-size: 12px; padding: 4px 10px; border-radius: 8px; border: 2px solid var(--ink); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }

#workshop { position: fixed; inset: 0; z-index: 16; display: grid; place-items: center; background: rgba(26, 18, 10, 0.6); backdrop-filter: blur(3px); }
.ws-card {
  width: min(94vw, 1060px); max-height: 92vh; overflow: auto; background: var(--kraft); color: var(--ink);
  border: 3px dashed var(--kraft-dark); box-shadow: 0 12px 0 var(--kraft-dark); padding: 16px 20px; transform: rotate(-0.4deg);
}
.ws-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.ws-head h2 { font-family: 'Permanent Marker', cursive; font-weight: 400; font-size: 32px; margin: 0; }
.ws-head span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.7; }
.ws-sub { margin: 2px 0 12px; font-style: italic; }
.ws-stock { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.ws-stock div { background: rgba(255, 255, 255, 0.3); border-radius: 8px; padding: 8px 10px; font-weight: 700; }
.ws-stock b { font-family: 'Permanent Marker', cursive; font-weight: 400; font-size: 22px; margin: 0 4px; }
.ws-stock small { display: block; font-weight: 500; font-size: 11px; opacity: 0.75; }
.ws-stock i, .ws-chip i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid var(--ink); vertical-align: -1px; }
.ws-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ws-item { background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.ws-item.upgrade { background: #eadcc0; }
.ws-item.owned { opacity: 0.6; }
.ws-item.ready { box-shadow: 0 0 0 3px #ffdf8a; }
.ws-kind { font-size: 10px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; opacity: 0.6; }
.ws-item h3 { font-family: 'Permanent Marker', cursive; font-weight: 400; margin: 0; font-size: 20px; }
.ws-item p { margin: 0; font-size: 13px; flex: 1; }
.ws-cost { display: flex; flex-wrap: wrap; gap: 4px; }
.ws-chip { font-size: 12px; font-weight: 700; background: rgba(0, 0, 0, 0.06); border-radius: 6px; padding: 2px 6px; }
.ws-chip.short { color: #a3321c; }
.ws-item button { font: 700 14px Inter, sans-serif; padding: 8px; border: 2px solid var(--ink); border-radius: 8px; background: #1f2d55; color: #ffdf8a; cursor: pointer; }
.ws-item button[aria-disabled="true"] { background: #b9a88a; color: #6b5a40; cursor: not-allowed; }
.ws-item kbd { font: 11px Inter, sans-serif; background: rgba(255, 255, 255, 0.2); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.ws-done { font-weight: 700; color: #2f6b2f; }
.ws-locked { font-size: 12px; font-weight: 700; opacity: 0.7; }
@media (max-width: 800px) { .ws-grid, .ws-stock { grid-template-columns: repeat(2, 1fr); } }

@media (max-width: 640px) {
  #minimap-wrap { width: 130px; height: 130px; bottom: 56px; }
  body:not(:has(#run-timer:not(.hidden), #dare-hud:not(.hidden))) #talk-col { width: calc(100% - 170px); }
  #help { font-size: 10px; }
}

/* The keepsake card: Mom's drawing, pinned askew with her note under it. */
/* (On the right side, under the counters and clear of the minimap: in the middle it hid the game.) */
#keepsake { position: fixed; right: 24px; top: 96px; transform: rotate(-3deg) scale(0.9); transform-origin: top right; z-index: 40; pointer-events: none;
  background: #f5ecd8; padding: 10px 10px 8px; box-shadow: 0 10px 28px rgba(20, 10, 0, 0.4); width: min(280px, 34vw); opacity: 0; transition: opacity 0.5s, transform 0.5s; }
#keepsake.show { opacity: 1; transform: rotate(-3deg) scale(1); }
#keepsake::before { content: ''; position: absolute; top: -12px; left: 50%; width: 22px; height: 34px; margin-left: -11px; background: #c8a064; border-radius: 3px; transform: rotate(8deg); box-shadow: 0 2px 4px rgba(0,0,0,0.3); }
#keepsake img { display: block; width: 100%; border: 1px solid rgba(0, 0, 0, 0.15); }
#keepsake p { margin: 8px 4px 2px; font-family: 'Permanent Marker', 'Comic Sans MS', cursive; font-size: 15px; line-height: 1.25; color: #2b4f86; }

/* The pause menu: options and key bindings (ui/Options). */
#options {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: rgba(26, 18, 10, 0.55); backdrop-filter: blur(3px);
}
.options-card {
  width: min(94vw, 900px); max-height: 92vh; overflow-y: auto; box-sizing: border-box;
  background: var(--kraft); border: 3px dashed var(--kraft-dark); box-shadow: 0 12px 0 var(--kraft-dark);
  padding: 14px 20px; transform: rotate(-0.4deg); color: var(--ink);
}
.options-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.options-head h2 { font-family: 'Permanent Marker', cursive; font-weight: 400; font-size: 30px; margin: 0; }
.options-head span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.7; }
.options-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 28px; }
@media (max-width: 700px) { .options-cols { grid-template-columns: 1fr; } }
.options-card h3 { font-family: 'Permanent Marker', cursive; font-weight: 400; font-size: 19px; margin: 14px 0 6px; }
.options-card h3 small { font-family: Inter, sans-serif; font-size: 11px; opacity: 0.7; }
.opt-row { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; padding: 4px 0; }
.opt-row span { flex: 1; }
.opt-row input[type=range] { width: 140px; accent-color: #c0392b; }
.opt-row input[type=checkbox] { width: 18px; height: 18px; accent-color: #c0392b; }
.opt-row output { width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.opt-row select { font: inherit; padding: 2px 6px; border: 2px solid var(--ink); background: rgba(255, 255, 255, 0.5); }
.opt-key { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; padding: 2px 0; }
.opt-key span { flex: 1; }
.opt-key button { min-width: 96px; font: inherit; padding: 3px 8px; border: 2px solid var(--ink); background: rgba(255, 255, 255, 0.55); cursor: pointer; }
.opt-key button.capturing { background: #ffd65a; }

/* The speedrun timer (Options: Speedrun timer). */
#run-timer {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 6;
  font-family: 'Permanent Marker', cursive; font-size: 24px; color: #fff8e8;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45); font-variant-numeric: tabular-nums; pointer-events: none; text-align: center; max-width: 196px;
}
#run-timer small { display: block; font-family: Inter, sans-serif; font-size: 12px; font-weight: 700; }
#run-timer .ahead { color: #8fe38f; }
#run-timer .behind { color: #ff9f8a; }

/* Dan's Dares: the challenge clock. */
#dare-hud {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%) rotate(-1deg); z-index: 6; pointer-events: none;
  background: var(--kraft); border: 3px dashed var(--kraft-dark); box-shadow: 0 6px 0 var(--kraft-dark);
  padding: 6px 16px; color: var(--ink); text-align: center; font-weight: 700; box-sizing: border-box; max-width: 196px;
}
#dare-hud b { display: block; font-family: 'Permanent Marker', cursive; font-weight: 400; font-size: 26px; font-variant-numeric: tabular-nums; }
#dare-hud.late b { color: #c0392b; }

/* A gamepad's highlight in the menus (ui/PadNav). */
.pad-focus { outline: 3px solid #f2c14a !important; outline-offset: 3px; box-shadow: 0 0 0 6px rgba(242, 193, 74, 0.25); }

/* What Dan carries (game/Hands): bottom right, a slot per thing. */
#hands { position: fixed; right: 16px; bottom: 246px; z-index: 6; pointer-events: none; display: flex; align-items: center; gap: 6px;
  background: rgba(42, 27, 14, 0.55); padding: 5px 8px; border-radius: 12px; color: var(--paper); }
#hands small { font-size: 9px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; opacity: 0.8; margin-right: 2px; }
#hands div { width: 34px; height: 34px; border-radius: 8px; background: var(--paper); border: 2px solid var(--kraft-dark);
  display: grid; place-items: center; font-size: 22px; font-weight: 700; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); }
#hands div.empty { background: rgba(245, 236, 216, 0.25); border-style: dashed; }
#hands.pop { animation: pop 0.3s ease-out; }

/* A dare won: its points ring up (ui/DareTally). */
#dare-tally { position: fixed; top: 74px; left: 50%; transform: translateX(-50%) rotate(-1deg); z-index: 7; pointer-events: none; min-width: 230px;
  background: var(--paper); color: var(--ink); border: 3px dashed var(--kraft-dark); box-shadow: 0 6px 0 var(--kraft-dark); padding: 8px 16px 10px; }
#dare-tally small { display: block; text-align: center; font-size: 9px; font-weight: 700; letter-spacing: 0.25em; text-transform: uppercase; color: #b8860b; }
#dare-tally h3 { margin: 0; text-align: center; font-family: 'Permanent Marker', cursive; font-weight: 400; font-size: 20px; }
#dare-tally p { margin: 0 0 6px; text-align: center; font-weight: 700; opacity: 0.7; }
#dare-tally div { display: flex; justify-content: space-between; gap: 18px; font-weight: 700; opacity: 0.3; font-variant-numeric: tabular-nums; }
#dare-tally div.on, #dare-tally div.total { opacity: 1; }
#dare-tally div.total { margin-top: 4px; padding-top: 4px; border-top: 2px solid var(--kraft-dark); font-family: 'Permanent Marker', cursive; font-weight: 400; font-size: 22px; }
#dare-tally.landed div.total b { color: #c98a00; animation: pop 0.35s ease-out; display: inline-block; }
