/* I Know Games / Deep Cut: the dungeon.
   Colors and sizes you may want to tweak are in :root. */
:root {
  --vh: 1vh;                 /* set by app.js to the real visible height / 100 */
  --kb: 0px;                 /* height of the on-screen keyboard, set by app.js */
  --fh: calc(var(--vh) * 86);/* one floor's height (phone) */
  --ink: #efe4cf;
  --ink-dim: #b9a988;
  --amber: #d38a34;
  --amber-hi: #e0a24c;
  --parch: #f1e6cc;
  --parch-ink: #1d1813;
  --t0: #f0a08e;             /* wrong / timed out (text) */
  --t1: #cdd1d5;             /* Mainstream */
  --t2: #78d866;             /* Well Known */
  --t3: #68b4ff;             /* Cult Classic */
  --t4: #c99bff;             /* Hidden Gem */
  --t5: #f4c552;             /* Deep Cut */
  color-scheme: dark;
}
@media (min-width: 900px) { :root { --fh: calc(var(--vh) * 74); } }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #090706; }
body { font: 16px/1.45 "Alegreya Sans", system-ui, sans-serif; color: var(--ink); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button { font: inherit; }

.dg { position: fixed; inset: 0; overflow: hidden; background: #090706; }
.track { position: absolute; left: 0; right: 0; top: 0; transition: transform 0ms cubic-bezier(.55,0,.22,1); will-change: transform; }
@media (prefers-reduced-motion: reduce) {
  .track { transition: none !important; }
  .flame, .glow { animation: none !important; }
  .plaque { animation: none !important; }
}

/* ---- The surface above the entrance ---- */
.surface { position: absolute; left: 0; right: 0; top: calc(var(--vh) * -40); height: calc(var(--vh) * 40);
  background: linear-gradient(#1a2333 0%, #3b3a4a 45%, #8a5d45 88%, #b47a50 100%); }
.surface .grass { position: absolute; left: 0; right: 0; bottom: 0; height: 22px; background: #3f5a2a; border-top: 3px solid #5d7d38; }
.surface .arch { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 170px; height: 96px;
  background: #0d0a08; border: 10px solid #6e6458; border-bottom: none; border-radius: 85px 85px 0 0; }

/* ---- Floors ---- */
.floor { position: relative; height: var(--fh); overflow: hidden; }
.wall { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.shaft { position: absolute; top: -20%; height: 140%; width: 16%; transform: skewX(-14deg); pointer-events: none;
  background: linear-gradient(to bottom, rgba(255,238,196,.9), rgba(255,238,196,0) 85%); }
.drip { position: absolute; top: 0; width: 3px; border-radius: 0 0 3px 3px; }
.fx, .moss { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.crack { vector-effect: non-scaling-stroke; fill: none; stroke: rgba(0,0,0,.55); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.crack.ember { stroke: #ff7a2a; stroke-width: 2.5; filter: drop-shadow(0 0 4px rgba(255,110,30,.9)); }
.root { vector-effect: non-scaling-stroke; fill: none; stroke: #3d2a1c; stroke-width: 5; stroke-linecap: round; }
.root.thin { stroke-width: 2.5; }
.web { position: absolute; top: 0; width: 110px; height: 110px; pointer-events: none; }
.web.l { left: 0; } .web.r { right: 0; transform: scaleX(-1); }
.web path { fill: none; stroke: rgba(225,222,210,.42); stroke-width: 1; }
.chain { position: absolute; top: -6px; width: 22px; }
.chain ellipse { fill: none; stroke: #5c5650; stroke-width: 3; }
.chain ellipse.thin { stroke: #4a4540; }
.banner { position: absolute; top: 0; width: 58px; height: 150px; transform: translateX(-50%);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%); box-shadow: inset 0 -30px 40px rgba(0,0,0,.45); }
.banner .rod { position: absolute; top: 8px; left: -6px; right: -6px; height: 6px; background: #3b3026; }
.banner svg { position: absolute; left: 50%; top: 42px; transform: translateX(-50%); width: 30px; height: 30px; }
.banner svg circle, .banner svg path { fill: none; stroke: rgba(230,210,170,.55); stroke-width: 2; }
.post { position: absolute; top: 0; bottom: 30px; width: 20px; box-shadow: inset -4px 0 0 rgba(0,0,0,.3); }
.beamtop { position: absolute; left: 0; right: 0; top: 0; height: 22px; box-shadow: inset 0 -4px 0 rgba(0,0,0,.35); }
.emberglow { position: absolute; left: 0; right: 0; bottom: 0; height: 40%; pointer-events: none;
  background: linear-gradient(to top, rgba(255,90,20,.18), rgba(255,90,20,0)); }
.ledge { position: absolute; left: 0; right: 0; bottom: 0; height: 30px; border-top: 2px solid rgba(255,255,255,.08); }
.ledge::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 118px, rgba(0,0,0,.35) 118px 121px); }
.deco { position: absolute; bottom: 26px; pointer-events: none; }
.bone rect, .bone circle { fill: #cfc4ad; }
.skull circle, .skull rect { fill: #d8ceb8; } .skull .eye { fill: #1a1512; }
.crystal { filter: drop-shadow(0 0 8px var(--cg)); }
.coins ellipse { fill: #d9a93a; stroke: #8a6516; stroke-width: 1; }
.chest { left: calc(50% - 60px); filter: drop-shadow(0 0 16px rgba(244,197,82,.6)); }
.chest rect { stroke: #2a1a0c; stroke-width: 2; }
.torch { position: absolute; width: 26px; height: 80px; z-index: 2; top: 14%; }
.torch.l { left: 7%; } .torch.r { right: 7%; }
@media (min-width: 900px) { .torch { top: 30%; } .torch.l { left: calc(50% - 400px); } .torch.r { right: calc(50% - 400px); } }
.torch .stick { fill: #4a3322; } .torch .bracket { fill: #2c2a28; }
.flame { transform-origin: 13px 26px; animation: flick 1.3s ease-in-out infinite alternate; }
.glow { position: absolute; width: 420px; height: 420px; margin: -210px 0 0 -210px; left: 13px; top: 14px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255,170,80,.34) 0%, rgba(255,140,60,.12) 35%, rgba(255,120,40,0) 68%);
  animation: glow 1.7s ease-in-out infinite alternate; }
@keyframes flick { 0% { transform: scale(1,1) rotate(-2deg); } 35% { transform: scale(.92,1.08) rotate(2deg); }
  70% { transform: scale(1.05,.94) rotate(-1deg); } 100% { transform: scale(.96,1.05) rotate(1.5deg); } }
@keyframes glow { 0% { opacity: .78; transform: scale(.97); } 50% { opacity: 1; } 100% { opacity: .86; transform: scale(1.03); } }
.dark { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.goldglow { position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(ellipse 60% 45% at 50% 92%, rgba(244,197,82,.28), rgba(244,197,82,0) 70%); }
.label { position: absolute; left: 14px; bottom: 38px; z-index: 4; font-family: "Grenze Gotisch", serif; font-size: 19px;
  letter-spacing: .06em; color: rgba(240,222,190,.62); text-shadow: 0 1px 0 rgba(0,0,0,.8); line-height: 1.1; }
.label .zone { display: block; font: 700 11px "Alegreya Sans", system-ui, sans-serif; letter-spacing: .18em; color: rgba(240,222,190,.5); }
.markers { position: absolute; right: 12px; bottom: 38px; z-index: 4; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; max-width: 60%; }
.marker { font-size: 13px; padding: 3px 8px; border-radius: 3px; background: rgba(18,14,11,.85); border: 1px solid rgba(255,255,255,.08);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ---- The plaque (always fully lit) ---- */
.plaque-wrap { position: absolute; left: 0; right: 0; z-index: 10; display: flex; justify-content: center; pointer-events: none; }
.plaque { pointer-events: auto; position: relative; width: min(560px, calc(100% - 24px));
  transform: translateY(calc(-50% - var(--kb) / 2)); transition: transform .2s ease-out;
  padding: 20px 20px 18px; background: linear-gradient(#3b342d, #2a2520); border: 2px solid #66574a; border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.09), 0 0 0 5px rgba(16,12,10,.75), 0 0 70px 14px rgba(255,196,120,.16), 0 22px 50px rgba(0,0,0,.65);
  max-height: calc(var(--fh) - 70px); overflow-y: auto; }
@media (min-width: 900px) { .plaque { padding: 26px 28px 22px; } }
.plaque.pop { animation: pop .35s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(calc(-50% + 10px)); } to { opacity: 1; } }
.rivet { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: #8d7a62; box-shadow: inset 0 -1px 1px rgba(0,0,0,.6); }
.rivet.tl { left: 8px; top: 8px; } .rivet.tr { right: 8px; top: 8px; } .rivet.bl { left: 8px; bottom: 8px; } .rivet.br { right: 8px; bottom: 8px; }
.kicker { font-family: "Grenze Gotisch", serif; font-size: 17px; letter-spacing: .12em; color: #d9c29a; margin: 0; }
.ptext { font-family: Alegreya, serif; font-weight: 800; font-size: 25px; line-height: 1.2; color: #fbf2e1; margin: 6px 0 14px; }
@media (min-width: 900px) { .ptext { font-size: 30px; } }
.intro { font-size: 17px; color: #e6d8bd; margin: 0 0 16px; }
.trow { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.tnum { font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; }
.tnum.low { color: #f0a08e; }
.timer { height: 6px; border-radius: 3px; background: rgba(255,255,255,.1); overflow: hidden; margin: 4px 0 2px; }
.timer i { display: block; height: 100%; background: var(--amber-hi); }
.timer.low i { background: #e2553f; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inp { width: 100%; font: 500 18px "Alegreya Sans", system-ui, sans-serif; padding: 13px 14px; border-radius: 4px;
  border: 2px solid #8a7656; background: var(--parch); color: var(--parch-ink); }
.inp::placeholder { color: #6a5c47; }
.inp:focus { outline: 3px solid var(--amber-hi); outline-offset: 1px; }
.inp:disabled { opacity: .6; }
.go { margin-top: 10px; width: 100%; min-height: 50px; border: 0; border-radius: 4px; background: var(--amber); color: #1c1209;
  font: 800 18px "Alegreya Sans", system-ui, sans-serif; letter-spacing: .04em; cursor: pointer; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.go:disabled { opacity: .45; cursor: default; }
.go.ghost { background: #251f1a; color: var(--ink); border: 1px solid #6a5a48; box-shadow: none; }
.go:focus-visible, .choice:focus-visible, .icon:focus-visible, .close:focus-visible, .link:focus-visible { outline: 3px solid var(--amber-hi); outline-offset: 2px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.note { min-height: 20px; margin: 8px 0 0; font-size: 15px; color: #d8c8ac; }
.note.warn { color: #f0a08e; }
.choices { margin-top: 10px; background: #f6eedb; border: 2px solid #8a7656; border-radius: 4px; padding: 4px 0; }
.choose { margin: 6px 14px 2px; font-size: 14px; font-weight: 700; color: #5e513f; }
.choice { display: flex; justify-content: space-between; gap: 10px; width: 100%; min-height: 46px; padding: 10px 14px; border: 0;
  background: transparent; color: var(--parch-ink); font: 600 17px "Alegreya Sans", system-ui, sans-serif; text-align: left; cursor: pointer; }
.choice:hover { background: #e6d5ae; }
.choice .yr { color: #5e513f; font-weight: 500; flex-shrink: 0; }
.choice.none { color: #5e513f; font-size: 15px; font-weight: 500; border-top: 1px solid #d9c8a4; }
.tier { font-family: "Grenze Gotisch", serif; font-size: 30px; letter-spacing: .04em; margin: 2px 0 0; }
.gname { font-family: Alegreya, serif; font-weight: 800; font-size: 22px; color: #fbf2e1; margin: 2px 0 4px; }
.detail { font-size: 16px; color: #d8c8ac; margin: 0; }
.after { margin: 12px 0 0; font-size: 15px; font-weight: 700; }
.reached { font-family: "Grenze Gotisch", serif; font-size: 44px; line-height: 1; color: var(--t5); margin: 4px 0 4px; }
.reached-zone { font-size: 12px; font-weight: 700; letter-spacing: .16em; color: var(--ink-dim); margin: 0 0 12px; }
.squares { display: flex; gap: 6px; margin-bottom: 12px; }
.sq { width: 26px; height: 26px; border-radius: 4px; }
.rows { display: grid; gap: 5px; margin-bottom: 6px; }
.res-row { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.07); padding-bottom: 4px; }
.res-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-row .pts { font-weight: 800; flex-shrink: 0; }
.c0 { color: var(--t0); } .c1 { color: var(--t1); } .c2 { color: var(--t2); } .c3 { color: var(--t3); } .c4 { color: var(--t4); } .c5 { color: var(--t5); }
.b0 { background: #4a4038; } .b1 { background: var(--t1); } .b2 { background: var(--t2); } .b3 { background: var(--t3); } .b4 { background: var(--t4); } .b5 { background: var(--t5); }

/* ---- HUD ---- */
.hud { position: absolute; left: 0; right: 0; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px calc(8px) max(12px, env(safe-area-inset-left)); padding-top: max(8px, env(safe-area-inset-top));
  background: linear-gradient(rgba(6,5,4,.94), rgba(6,5,4,.62)); border-bottom: 1px solid rgba(255,255,255,.06); }
.hud-left { flex: 1 1 auto; min-width: 0; }
.brand { font-family: "Grenze Gotisch", serif; font-size: 22px; letter-spacing: .05em; color: var(--ink); line-height: 1; white-space: nowrap; }
.brand span { color: var(--ink-dim); font-size: 16px; }
.pips { display: flex; gap: 4px; margin-top: 5px; }
.pip { width: 14px; height: 14px; border-radius: 3px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2); }
.pip.cur { border: 2px solid var(--amber-hi); }
.pip.done { border-color: transparent; }
.pip.b0 { background: #4a4038; } .pip.b1 { background: var(--t1); } .pip.b2 { background: var(--t2); }
.pip.b3 { background: var(--t3); } .pip.b4 { background: var(--t4); } .pip.b5 { background: var(--t5); }
.hud-buttons { display: flex; gap: 2px; }
.icon { width: 40px; height: 40px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-dim); cursor: pointer; display: grid; place-items: center; }
.icon:hover { background: rgba(255,255,255,.07); color: var(--ink); }
.icon svg, .close svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.depth { text-align: right; line-height: 1; flex-shrink: 0; min-width: 64px; }
.depth .k { font-size: 11px; letter-spacing: .16em; color: var(--ink-dim); font-weight: 700; }
.depth .n { font-family: "Grenze Gotisch", serif; font-size: 32px; color: var(--t5); }
.depth .of { font-size: 15px; color: var(--ink-dim); }
.depth .z { font-size: 10px; letter-spacing: .12em; color: var(--ink-dim); font-weight: 700; margin-top: 2px; white-space: nowrap; }
@media (max-width: 430px) { .depth .z { display: none; } .brand { font-size: 20px; } }
.foot { position: absolute; left: 0; right: 0; bottom: max(6px, env(safe-area-inset-bottom)); z-index: 30; text-align: center;
  font-size: 12px; color: #a99a80; pointer-events: none; padding: 0 12px; }

/* ---- Overlay sheets: results, stats, archive, how to play ---- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(5,4,3,.72); display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 700px) { .overlay { align-items: center; } }
.sheet { position: relative; width: min(620px, 100%); max-height: calc(var(--vh) * 92); overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: linear-gradient(#332d27, #24201b); border: 2px solid #66574a; border-radius: 10px 10px 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.6); padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .sheet { border-radius: 10px; padding: 26px 28px; } }
.close { position: absolute; right: 10px; top: 10px; width: 44px; height: 44px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-dim); cursor: pointer; display: grid; place-items: center; }
.sheet h2 { font-family: "Grenze Gotisch", serif; font-size: 30px; font-weight: 700; margin: 0 48px 12px 0; color: #fbf2e1; letter-spacing: .03em; }
.sheet h3 { font: 800 15px "Alegreya Sans", system-ui, sans-serif; letter-spacing: .1em; color: #d9c29a; margin: 18px 0 8px; text-transform: uppercase; }
.sheet p { margin: 0 0 10px; color: #e6d8bd; }
.sheet .muted { color: var(--ink-dim); font-size: 14px; }
.card { background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.08); border-left: 5px solid var(--edge, #4a4038); border-radius: 6px; padding: 12px 14px; margin-bottom: 10px; }
.card .q { font-size: 14px; color: var(--ink-dim); }
.card .pick { font-family: Alegreya, serif; font-weight: 800; font-size: 19px; color: #fbf2e1; margin: 2px 0; display: flex; justify-content: space-between; gap: 10px; }
.card .line { font-size: 14px; color: #d8c8ac; margin: 2px 0; }
.card details { margin-top: 6px; font-size: 14px; }
.card summary { cursor: pointer; color: var(--amber-hi); min-height: 32px; display: flex; align-items: center; }
.card ol { margin: 4px 0 0; padding-left: 22px; }
.card li { margin: 2px 0; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; text-align: center; margin-bottom: 8px; }
.stat .v { font-family: "Grenze Gotisch", serif; font-size: 34px; color: #fbf2e1; line-height: 1.1; }
.stat .l { font-size: 12px; color: var(--ink-dim); line-height: 1.2; }
.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 96px 1fr 32px; align-items: center; gap: 8px; font-size: 14px; }
.bar .track2 { height: 14px; background: rgba(255,255,255,.07); border-radius: 3px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 3px; }
.bar .num { text-align: right; font-variant-numeric: tabular-nums; }
.days { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dayrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 8px 12px;
  background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.08); border-radius: 6px; color: var(--ink); text-align: left; cursor: pointer; font: 600 16px "Alegreya Sans", system-ui, sans-serif; }
.dayrow:hover { border-color: #8a7656; }
.dayrow .st { font-weight: 500; color: var(--ink-dim); font-size: 14px; }
.codebox { width: 100%; min-height: 70px; font: 13px ui-monospace, monospace; background: #15110e; color: var(--ink); border: 1px solid #6a5a48; border-radius: 4px; padding: 8px; }
.link { background: none; border: 0; color: var(--amber-hi); text-decoration: underline; cursor: pointer; padding: 6px 0; font-size: 15px; }
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 60; background: #f1e6cc; color: #1d1813; font-weight: 700;
  padding: 10px 16px; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
