* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --head-h: 40px;   /* header with the paccastudio menu item */
  --foot-h: 32px;   /* footer with the paccastudio link */
  --ink: #14130f;
  --panel: #1e1c16;
  --line: #36321f;
  --muted: #8d8770;
  --text: #ece7d2;
  --haz: #ffd23f;    /* hazard yellow: the sweeper's suit */
  --mist: #7dffb0;   /* the spray */
  --red: #ff5a52;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, 'Courier New', monospace;
}

html, body { height: 100%; }

body {
  background: var(--ink);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--sans);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ── Header and footer ─────────────────────────────────────────────────────── */
.page-bar {
  flex: none;
  height: var(--head-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(14px, env(safe-area-inset-left));
  background: var(--ink);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font: 12px var(--mono);
  letter-spacing: 2px;
  position: relative;
  z-index: 5;
}
.page-bar.foot {
  height: var(--foot-h);
  border-bottom: 0;
  border-top: 1px solid var(--line);
  justify-content: center;
  font-size: 11px;
  letter-spacing: 1px;
}
.game-name { color: var(--text); display: flex; align-items: center; gap: 8px; }
.game-name .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--haz); }
.page-bar nav { display: flex; align-items: center; gap: 6px; }
.tool {
  height: 28px; min-width: 32px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--line); border-radius: 4px;
  color: var(--muted); font: 11px var(--mono); letter-spacing: 1px;
}
.tool:hover { color: var(--text); border-color: var(--muted); }
#btn-sound .mute { display: none; }
#btn-sound.off .wave { display: none; }
#btn-sound.off .mute { display: inline; }
.pacca { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; padding: 0 4px; }
.pacca:hover { color: var(--text); }

/* body.playing: the level takes the whole window under the header */
body.playing .foot { display: none; }

/* ── Screens ───────────────────────────────────────────────────────────────── */
.stage { flex: 1; position: relative; min-height: 0; }
.screen {
  position: absolute; inset: 0;
  overflow-y: auto;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 28px 16px;
  background:
    repeating-linear-gradient(135deg, transparent 0 22px, rgba(255, 210, 63, .035) 22px 44px),
    var(--ink);
}
.screen.over { z-index: 4; background: rgba(12, 11, 8, .82); align-items: center; }
.sheet { width: 100%; max-width: 620px; margin: auto 0; }
.sheet.small { max-width: 380px; text-align: center; }

h1 { font: 800 clamp(40px, 9vw, 68px)/1 var(--sans); letter-spacing: -1px; color: var(--haz); }
h2 { font: 800 26px/1.15 var(--sans); margin-bottom: 10px; overflow-wrap: anywhere; }
.lead { margin: 12px 0 22px; font-size: 17px; line-height: 1.45; color: var(--text); max-width: 34em; }
p { line-height: 1.5; }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.mode {
  text-align: left; padding: 10px 12px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
}
.mode b { font-size: 15px; }
.mode span { font-size: 12px; color: var(--muted); }
.mode.on { border-color: var(--haz); box-shadow: inset 0 0 0 1px var(--haz); }
.mode:disabled { opacity: .55; cursor: default; }

#go { display: flex; gap: 8px; }
.url {
  flex: 1; min-width: 0; display: flex; align-items: center;
  background: #fff; color: #14130f; border-radius: 8px; padding: 0 12px;
  font: 16px var(--mono);
}
.url span { color: #77715c; }
.url input { flex: 1; min-width: 0; height: 48px; border: 0; outline: 0; background: none; font: inherit; color: inherit; }
.url:focus-within { box-shadow: 0 0 0 3px var(--haz); }

.btn {
  height: 48px; padding: 0 18px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--line);
  font-weight: 700; font-size: 15px; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.main { background: var(--haz); border-color: var(--haz); color: #14130f; }
.btn.main:hover { filter: brightness(1.08); }
.btn.ghost { background: none; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.or { margin: 22px 0 8px; font-size: 13px; color: var(--muted); }
.ready { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.ready button {
  text-align: left; padding: 10px 12px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
}
.ready button:hover { border-color: var(--haz); }
.ready b { font-size: 14px; }
.ready span { font-size: 12px; color: var(--muted); }

.keys { list-style: none; margin-top: 24px; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 6px 14px; font-size: 13px; color: var(--muted); }
.keys kbd { font: 12px var(--mono); color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; margin-right: 6px; }
.fine { margin-top: 16px; font-size: 12px; color: var(--muted); }
.found { margin-top: 12px; padding: 10px 12px; border-left: 3px solid var(--haz); background: var(--panel); border-radius: 0 8px 8px 0; }

/* the scan line of the loading screen */
.scan { height: 90px; border: 1px solid var(--line); border-radius: 8px; position: relative; overflow: hidden; margin-bottom: 14px;
  background: repeating-linear-gradient(0deg, transparent 0 13px, rgba(236, 231, 210, .07) 13px 14px); }
.scan i { position: absolute; top: 0; bottom: 0; width: 34%; left: -34%;
  background: linear-gradient(90deg, transparent, rgba(125, 255, 176, .35)); border-right: 2px solid var(--mist);
  animation: scan 1.3s linear infinite; }
@keyframes scan { to { left: 100%; } }

/* ── The level ─────────────────────────────────────────────────────────────── */
#play { position: absolute; inset: 0; background: #fff; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#site { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; pointer-events: none; }
#fx { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }

#hud { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 6px; align-items: center; pointer-events: none; }
#hud .grow { flex: 1; }
.chip {
  height: 30px; padding: 0 10px; display: inline-flex; align-items: center;
  background: rgba(20, 19, 15, .9); color: var(--text); border: 1px solid var(--line); border-radius: 15px;
  font: 12px var(--mono); white-space: nowrap;
}
.chip.host { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; display: inline-block; line-height: 28px; }
.chip.act { pointer-events: auto; }
.chip.act:hover { border-color: var(--haz); }
#h-report { background: var(--haz); color: #14130f; border-color: var(--haz); font-weight: 700; }

#cards { position: absolute; left: 10px; bottom: 10px; width: min(360px, calc(100% - 20px)); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.bugcard {
  background: rgba(20, 19, 15, .95); border: 1px solid var(--line); border-left: 4px solid var(--haz); border-radius: 8px;
  padding: 10px 12px; display: grid; grid-template-columns: 44px 1fr; gap: 2px 10px; align-items: center;
  animation: card-in .25s ease-out;
}
.bugcard canvas { grid-row: span 2; width: 44px; height: 44px; background: #f4f0df; border-radius: 6px; }
.bugcard b { font-size: 14px; }
.bugcard small { font: 10px var(--mono); letter-spacing: 1px; color: var(--haz); text-transform: uppercase; margin-left: 6px; }
.bugcard p { grid-column: 2; font-size: 13px; line-height: 1.35; color: #cfc9b3; }
.bugcard.out { opacity: 0; transition: opacity .4s; }
@keyframes card-in { from { transform: translateY(12px); opacity: 0; } }

/* X-ray mode: the page as a radiograph, the find being asked for on top */
#play.xray { background: #0b1622; }
#play.xray #site { filter: grayscale(1) invert(1) brightness(.92) sepia(.4) hue-rotate(165deg) contrast(1.05); }
#mission {
  position: absolute; top: 46px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 20px);
  background: rgba(11, 22, 34, .94); color: #cdeeff; border: 1px solid #5cd0ff; border-radius: 16px;
  padding: 6px 14px; font: 13px var(--mono); text-align: center; pointer-events: none;
  animation: card-in .25s ease-out;
}
.bugcard.xr { border-left-color: #5cd0ff; }
.bugcard.xr.hit { border-left-color: var(--haz); }
.bugcard .tagpic {
  grid-row: span 2; width: 44px; height: 44px; border-radius: 6px; background: #0b1622; color: #5cd0ff;
  font: 700 11px var(--mono); display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.bugcard.xr small { color: var(--haz); }
.tally .n.ok { color: #1c8a4a; }
.tally .n.ko { color: #c2281f; }
/* on a phone the find takes two lines at the top: the cards sit low, above the buttons */
body.touch #play.xray #cards { top: auto; bottom: 132px; }

/* touch: the stick appears under the left thumb, the actions sit on the right */
#touch { position: absolute; inset: 0; pointer-events: none; }
#joy { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%;
  background: rgba(20, 19, 15, .28); border: 2px solid rgba(255, 255, 255, .55); display: none; }
#joy.on { display: block; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: rgba(255, 210, 63, .9); border: 2px solid #14130f; }
#touch button {
  position: absolute; pointer-events: auto; touch-action: none;
  border-radius: 50%; border: 2px solid #14130f; font: 700 12px var(--mono); letter-spacing: 1px; color: #14130f;
}
#t-spray { right: max(16px, env(safe-area-inset-right)); bottom: 28px; width: 92px; height: 92px; background: rgba(125, 255, 176, .92); }
#t-jump { right: calc(max(16px, env(safe-area-inset-right)) + 100px); bottom: 14px; width: 72px; height: 72px; background: rgba(255, 210, 63, .92); }
#touch button.down { filter: brightness(.82); }
body.touch #cards { bottom: auto; top: 46px; }

/* ── The report card ───────────────────────────────────────────────────────── */
.sheet.card {
  max-width: 460px; background: #f4f0df; color: #14130f; border-radius: 10px; padding: 22px 22px 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .5); border-top: 10px solid var(--haz);
}
.kicker { font: 11px var(--mono); letter-spacing: 2px; text-transform: uppercase; color: #77715c; }
.grade { display: flex; align-items: baseline; gap: 4px; margin: 4px 0 6px; }
.grade b { font: 800 78px/1 var(--sans); }
.grade span { font: 700 22px var(--sans); color: #77715c; }
.grade.good b { color: #1c8a4a; }
.grade.mid b { color: #b47a00; }
.grade.bad b { color: #c2281f; }
.tally { list-style: none; margin: 12px 0; border-top: 1px solid #d6d0b8; }
.tally li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid #d6d0b8; font-size: 14px; }
.tally .n { font: 700 14px var(--mono); min-width: 22px; }
.tally .who { color: #55503d; font-size: 12px; display: block; }
.stats { font: 12px var(--mono); color: #55503d; }
.card .fine { color: #77715c; }
.card .btn { background: #fff; border-color: #c9c2a6; color: #14130f; height: 44px; }
.card .btn.main { background: #14130f; border-color: #14130f; color: var(--haz); }
.card .btn.ghost { background: none; }

@media (max-width: 520px) {
  #go { flex-direction: column; }
  .screen { padding: 20px 14px; }
  .chip.host { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .scan i, .bugcard { animation: none; }
}
