/* Treasure Hunt World app styles. Colours and fonts come from the theme (TH.applyTheme). */
:root {
  --bg: #FFC9DF; --card: #fff; --tint: #FFF4F9; --line: #22101F; --text: #22101F; --dim: #5A3F55;
  --accent: #FF4F9A; --accent2: #FFD93B; --onAccent: #22101F; --ok: #1E9E5A; --bad: #E5484D; --badBg: #FFE1E1;
  --display: 'Lilita One', sans-serif; --body: 'Space Grotesk', system-ui, sans-serif; --mono: 'DM Mono', monospace;
  --bw: 3px; --radius: 20px; --shadow: 5px 5px 0 #22101F; --shadowSm: 4px 4px 0 #22101F; --upper: none;
}
* { box-sizing: border-box; }
html { overflow-x: clip; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--body); font-size: 17px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: inherit; }
.wrap { max-width: 560px; margin: 0 auto; padding: 18px 18px 110px; display: flex; flex-direction: column; gap: 16px; }
.wrap.wide { max-width: 960px; }
.hidden { display: none !important; }
.dim { color: var(--dim); }
.mono { font-family: var(--mono); }
.small { font-size: 14px; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; text-decoration: none; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 13px; font-weight: 500;
  background: var(--text); color: var(--bg); padding: 6px 12px; border-radius: 999px; text-decoration: none; white-space: nowrap; border: 0;
}
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; line-height: 1.05; text-transform: var(--upper); }
h1 { font-size: clamp(34px, 10vw, 50px); }
h2 { font-size: 24px; }
h3 { font-size: 19px; }
.title-hl { background: var(--accent2); color: var(--onAccent); padding: 0 6px; border-radius: 10px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
[data-mode="dark"] .title-hl { color: var(--bg); }

.card {
  background: var(--card); border: var(--bw) solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; display: flex; flex-direction: column; gap: 14px;
}
.card p { margin: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.clue { font-family: var(--mono); font-size: 15px; line-height: 1.75; white-space: pre-wrap; margin: 0; }
.task { background: var(--accent2); color: #22101F; border: var(--bw) solid var(--line); border-radius: 14px; padding: 12px 14px; white-space: pre-wrap; font-weight: 500; }
.task strong { font-family: var(--display); font-weight: 400; font-size: 18px; display: block; }

.dots { display: flex; gap: 9px; align-items: center; min-height: 20px; flex-wrap: wrap; }
.dot { width: 14px; height: 14px; border: 2.5px solid var(--line); border-radius: 50%; background: var(--card); }
.dot.done { background: var(--ok); border-color: var(--ok); }
.dot.current { width: 18px; height: 18px; background: var(--accent); border-color: var(--line); box-shadow: 0 0 12px 1px var(--accent); }
.dot.final { border-radius: 4px; transform: rotate(45deg); }

label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 15px; }
label.field .hint { font-weight: 400; color: var(--dim); font-size: 13px; }
input[type=text], input[type=email], input[type=url], input[type=number], input[type=datetime-local], input[type=password], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--tint);
  border: var(--bw) solid var(--line); border-radius: 12px; padding: 11px 13px; min-height: 48px;
}
textarea { min-height: 110px; resize: vertical; font-family: var(--mono); font-size: 14px; line-height: 1.6; }
select { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%), linear-gradient(135deg, var(--text) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.check { display: flex; gap: 12px; align-items: flex-start; background: var(--tint); border: var(--bw) solid var(--line); border-radius: 14px; padding: 13px; font-weight: 500; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--ok); flex: 0 0 auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  font-family: var(--display); font-weight: 400; font-size: 19px; text-transform: var(--upper); color: var(--onAccent);
  background: var(--accent); border: var(--bw) solid var(--line); border-radius: 999px; box-shadow: var(--shadowSm);
  padding: 10px 18px; min-height: 52px; cursor: pointer; text-decoration: none;
}
[data-mode="dark"] .btn { border-color: transparent; }
.btn.alt { background: var(--accent2); color: #22101F; }
.btn.secondary { background: transparent; color: var(--text); box-shadow: none; font-family: var(--body); font-weight: 700; font-size: 16px; min-height: 48px; border-color: var(--line); text-transform: none; }
.btn.slim { width: auto; min-height: 40px; font-size: 15px; padding: 6px 14px; }
.btn:active { transform: translate(1px, 1px); }
.btn[disabled] { opacity: 0.45; cursor: default; transform: none; }
.btn-row { display: flex; flex-direction: column; gap: 10px; }
:focus-visible { outline: 3px solid var(--accent2); outline-offset: 3px; }

.notice { border: var(--bw) solid var(--line); border-radius: 14px; padding: 10px 14px; background: var(--card); font-weight: 600; font-size: 15px; margin: 0; }
.notice.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.notice.bad { background: var(--badBg); color: var(--text); border-color: var(--bad); }
.notice:empty { display: none; }
.waiting { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite; flex: 0 0 auto; opacity: .9; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Finish */
.polaroid { background: #fff; color: #22101F; border: var(--bw) solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; transform: rotate(-1.5deg); display: flex; flex-direction: column; gap: 10px; }
.polaroid .photo { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; display: block; background: repeating-linear-gradient(45deg, #fff4f9 0 12px, #ffe3ef 12px 24px); }
.polaroid .cap { display: flex; justify-content: space-between; gap: 8px; font-family: var(--display); font-size: 20px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--card); border: var(--bw) solid var(--line); border-radius: var(--radius); box-shadow: var(--shadowSm); padding: 12px 14px; }
.stat .label { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; display: block; }
.stat .big { font-family: var(--display); font-size: 40px; line-height: 1.1; color: var(--accent); }
.stat .time { font-family: var(--mono); font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; }

/* Leaderboard */
.clock { font-family: var(--mono); font-size: clamp(40px, 13vw, 56px); font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums; }
.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.lb { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; background: var(--card); border: var(--bw) solid var(--line); border-radius: var(--radius); box-shadow: var(--shadowSm); padding: 11px 13px; }
.lb.mine { outline: 3px solid var(--accent2); outline-offset: 2px; }
.rank { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: var(--onAccent); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-size: 19px; }
.lb .name { font-family: var(--display); font-size: 18px; line-height: 1.1; }
.lb .sub { font-size: 13px; color: var(--dim); }
.bar { height: 9px; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; margin-top: 5px; background: var(--tint); }
.bar > span { display: block; height: 100%; background: var(--ok); }
.lb .right { font-family: var(--mono); font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Gallery */
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 720px) { .grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--card); border: var(--bw) solid var(--line); border-radius: 16px; padding: 7px; display: flex; flex-direction: column; gap: 6px; }
.tile .media { position: relative; display: block; width: 100%; aspect-ratio: 1/1; padding: 0; border: 0; border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--tint); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.play-badge { position: absolute; inset: 0; margin: auto; width: 48px; height: 48px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; color: var(--onAccent); font-size: 18px; }
.tile .meta { padding: 0 3px 3px; font-size: 13px; }
.tile .meta strong { display: block; font-family: var(--display); font-weight: 400; font-size: 16px; }
dialog { border: var(--bw) solid var(--line); border-radius: var(--radius); padding: 12px; width: min(94vw, 720px); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .7); }
dialog .frame { width: 100%; max-height: 72vh; border-radius: 10px; display: block; border: 0; }
dialog iframe.frame { aspect-ratio: 9/16; background: #000; }
dialog img.frame { object-fit: contain; }

/* Bottom tab bar (player) */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); background: var(--card); border-top: var(--bw) solid var(--line); }
.tabs a { flex: 1 1 0; max-width: 170px; text-align: center; text-decoration: none; font-family: var(--mono); font-size: 13px; font-weight: 500;
  padding: 10px 6px; border-radius: 999px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.tabs a[aria-current="page"] { background: var(--text); color: var(--bg); }

/* Builder */
.steps { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.steps button { flex: 0 0 auto; font: inherit; font-family: var(--mono); font-size: 12px; border: 2px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 6px 11px; cursor: pointer; }
.steps button[aria-current="step"] { background: var(--text); color: var(--bg); }
.steps button.done::before { content: '✓ '; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-size: 14px; font-weight: 700; border: var(--bw) solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 8px 14px; min-height: 42px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.stopcard .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stopcard .num { font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.iconbtn { font: inherit; border: 2px solid var(--line); background: var(--card); color: var(--text); border-radius: 10px; min-width: 40px; min-height: 40px; cursor: pointer; }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.swatch { text-align: left; font: inherit; cursor: pointer; border-radius: 16px; padding: 14px; min-height: 120px; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; border: 3px solid transparent; }
.swatch[aria-pressed="true"] { outline: 4px solid var(--accent2); outline-offset: 2px; }
.swatch .dots3 { display: flex; gap: 5px; }
.swatch .dots3 span { width: 16px; height: 16px; border-radius: 50%; }
.qrbox { background: #fff; padding: 8px; border-radius: 12px; width: 180px; border: 2px solid var(--line); }
.qrbox svg { width: 100%; height: auto; display: block; }
code.link { font-family: var(--mono); font-size: 13px; word-break: break-all; background: var(--tint); padding: 8px 10px; border-radius: 10px; display: block; border: 1.5px dashed var(--line); }
ol.howto { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }

/* Host */
.sub-card { background: var(--tint); border: 2px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.sub-card img { width: 100%; max-height: 340px; object-fit: contain; border-radius: 10px; background: #000; }
.badge { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; border: 1.5px solid var(--line); padding: 2px 8px; border-radius: 999px; }
.badge.Pending { background: var(--accent2); color: #22101F; }
.badge.Approved { background: var(--ok); color: #fff; border-color: var(--ok); }
.badge.Rejected { background: var(--badBg); }

/* Print sheet (host) */
.qrsheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.qrcard { background: #fff; color: #111; border: 2px dashed #555; border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; break-inside: avoid; }
.qrcard svg { width: 170px; height: 170px; }
.qrcard strong { font-family: var(--display); font-size: 18px; font-weight: 400; }
.qrcard span { font-size: 12px; color: #444; }
@media print {
  body { background: #fff !important; }
  .noprint, .tabs { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .qrsheet { grid-template-columns: repeat(2, 1fr); }
}

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.reveal { animation: reveal .45s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .spinner, .reveal { animation: none; } .btn:active { transform: none; } }
/* Builder: clue ideas */
.ideas summary { cursor: pointer; list-style: none; }
.ideas summary::-webkit-details-marker { display: none; }
.ideas summary::before { content: "+ "; color: var(--accent); font-weight: 700; }
.ideas[open] summary::before { content: "– "; }
.idea { width: 100%; transition: border-color .15s ease, transform .15s ease; }
.idea:hover { border-color: var(--accent); }
.idea:active { transform: scale(.99); }
.idea .spread { gap: 10px; flex-wrap: wrap; }
