:root {
  --desk: #13211d;
  --desk-2: #1a2e28;
  --paper: #f6efe0;
  --paper-2: #ece2cb;
  --manila: #e2c68b;
  --manila-2: #d3b16c;
  --ink: #1d2321;
  --ink-soft: #545c58;
  --red: #c4402f;
  --red-dark: #8f2a1d;
  --green: #2e8b4f;
  --green-soft: #d9efcf;
  --toxic: #a6d83a;
  --gold: #e3a90f;
  --f-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --f-body: 'Lexend', system-ui, sans-serif;
  --f-type: 'Special Elite', 'Courier New', monospace;
  --infect: 0;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: var(--f-body);
  color: var(--paper);
  background:
    radial-gradient(1100px 700px at 15% -10%, #27483d 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 110%, #1d3947 0%, transparent 55%),
    var(--desk);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }
h1, h2, h3, h4 { font-family: var(--f-display); margin: 0; line-height: 1.05; letter-spacing: -0.02em; }
p { line-height: 1.6; }
.muted { color: var(--ink-soft); }
.small { font-size: .9rem; }

#rain { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; opacity: 0; transition: opacity .8s; }
body.rainy #rain { opacity: 1; }
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 40;
  box-shadow: inset 0 0 calc(30px + 170px * var(--infect)) calc(var(--infect) * 50px) rgba(130, 205, 40, calc(var(--infect) * .55));
  transition: box-shadow .5s;
}

main { position: relative; z-index: 1; }
.screen { display: none; min-height: 100vh; padding: 28px 16px 110px; }
.screen.active { display: block; animation: screenIn .45s ease both; }
body.in-mission .screen { padding-top: 92px; }
@keyframes screenIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.wrap { max-width: 1080px; margin: 0 auto; }
.wrap.narrow { max-width: 760px; }

/* ---------- Butang ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 600; font-size: 1rem; line-height: 1;
  padding: 14px 20px; border-radius: 12px; cursor: pointer;
  color: var(--ink); background: var(--paper);
  border: 2px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, background .2s, opacity .2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 0 4px 0 var(--ink); }
.btn-primary { background: var(--red); color: #fff7ee; }
.btn-primary:hover { background: #d24a38; }
.btn-ghost { background: transparent; color: var(--paper); border-color: rgba(246, 239, 224, .7); box-shadow: 0 4px 0 rgba(0, 0, 0, .4); }
.paper .btn-ghost { color: var(--ink); border-color: var(--ink); box-shadow: 0 4px 0 var(--ink); }
.btn-lg { font-size: 1.12rem; padding: 17px 26px; }
.btn .ic, .ic { width: 18px; height: 18px; fill: currentColor; flex: none; }
.btn:focus-visible, .icon-btn:focus-visible, .w:focus-visible, .tile:focus-visible, .rat:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  color: var(--paper); background: rgba(10, 18, 16, .65); border: 2px solid rgba(246, 239, 224, .35);
  backdrop-filter: blur(6px); transition: background .2s, transform .1s;
}
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.icon-btn:hover { background: rgba(10, 18, 16, .9); }
.icon-btn:active { transform: scale(.94); }
.icon-btn[aria-pressed="false"] { opacity: .55; }
.sound-ctl { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; gap: 10px; }

/* ---------- Kertas & label ---------- */
.paper {
  position: relative; color: var(--ink);
  background: linear-gradient(180deg, var(--paper), var(--paper-2));
  border-radius: 16px; padding: 28px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .25), 0 18px 40px rgba(0, 0, 0, .35);
}
.paper::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgba(120, 90, 40, .07) 1px, transparent 1px);
  background-size: 5px 5px;
}
.kicker { font-family: var(--f-type); font-size: 1rem; margin: 0 0 10px; color: var(--ink-soft); }
.kicker.light { color: rgba(246, 239, 224, .75); }
.tag {
  display: inline-block; font-size: .85rem; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  background: var(--ink); color: var(--paper);
}
.tag-green { background: var(--green); }
.pill { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 999px; background: var(--red); color: #fff; font-size: .85rem; padding: 0 7px; }

.stamp {
  display: inline-block; font-family: var(--f-display); font-weight: 800; text-transform: uppercase; letter-spacing: -0.01em;
  color: var(--red); border: 4px solid currentColor; border-radius: 10px; padding: 6px 14px; line-height: 1;
  transform: rotate(-6deg); opacity: .88; mix-blend-mode: multiply;
  -webkit-mask-image: radial-gradient(circle at 30% 30%, #000 60%, rgba(0, 0, 0, .7) 61%, #000 75%);
  mask-image: radial-gradient(circle at 30% 30%, #000 60%, rgba(0, 0, 0, .7) 61%, #000 75%);
}
.stamp-title { font-size: clamp(1.3rem, 4.2vw, 2rem); margin: 18px 0 8px 4px; }
.stamp-big { position: absolute; top: 22px; right: 22px; font-size: clamp(1.2rem, 4vw, 1.9rem); transform: rotate(8deg); }
.stamp-big.slam { animation: slam .5s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: .25s; }
.stamp-big.green { color: var(--green); }
@keyframes slam { from { opacity: 0; transform: rotate(8deg) scale(2.6); } to { opacity: .88; transform: rotate(8deg) scale(1); } }

/* ---------- Skrin tajuk ---------- */
.title-wrap { max-width: 740px; margin: 4vh auto 0; }
.folder { transform: rotate(-1deg); filter: drop-shadow(0 26px 40px rgba(0, 0, 0, .5)); }
.folder-tab {
  display: inline-block; margin-left: 26px; padding: 11px 22px 9px; border-radius: 12px 12px 0 0;
  background: var(--manila); color: var(--ink); font-family: var(--f-type); font-size: .95rem;
}
.folder-body { background: linear-gradient(170deg, var(--manila), var(--manila-2)); border-radius: 4px 18px 18px 18px; padding: 22px 18px 18px; }
.sheet {
  position: relative; color: var(--ink); background: var(--paper); border-radius: 6px;
  padding: 40px clamp(20px, 5vw, 46px) 30px; transform: rotate(1.2deg);
  box-shadow: 0 6px 18px rgba(60, 40, 10, .25);
}
.clip {
  position: absolute; top: -18px; left: 40px; width: 26px; height: 64px; border: 4px solid #8d969a; border-radius: 14px;
  border-bottom-color: transparent; transform: rotate(-8deg);
}
.sheet h1 { font-size: clamp(2.5rem, 8vw, 4.6rem); font-weight: 800; line-height: .92; letter-spacing: -0.035em; }
.sheet h1 span { color: var(--red); }
.lede { font-size: 1.06rem; color: #2f3633; max-width: 56ch; }
.title-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-top: 20px; }
.name-field { display: flex; flex-direction: column; gap: 6px; flex: 1 1 240px; font-size: .92rem; font-weight: 500; color: var(--ink-soft); }
.name-field input {
  width: 100%; padding: 14px 14px; border-radius: 12px; border: 2px solid var(--ink); background: #fffaf0; color: var(--ink);
  font-family: var(--f-type); font-size: 1.1rem;
}
.name-field.inline { max-width: 360px; margin: 10px 0 14px; }
.name-field[hidden] { display: none; }
.name-field em { font-style: normal; font-weight: 400; opacity: .8; }
.class-field input { text-transform: uppercase; }
.class-chip { margin: 12px 0 0; display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; background: rgba(166, 216, 58, .14); border: 1px solid rgba(166, 216, 58, .45); color: var(--paper); padding: 7px 12px; border-radius: 999px; font-size: .92rem; }
.class-chip[hidden] { display: none; }
.class-chip b { color: var(--toxic); }
.class-chip button { background: none; border: 0; color: rgba(246, 239, 224, .75); text-decoration: underline; cursor: pointer; font-size: .85rem; padding: 0; }
.title-meta { display: flex; flex-wrap: wrap; gap: 8px 22px; list-style: none; padding: 0; margin: 22px 0 0; color: var(--ink-soft); font-size: .92rem; }
.lb-note { margin: 14px 0 0; font-size: .88rem; color: var(--ink-soft); }
.lb-note[hidden] { display: none; }
.guru-link { display: inline-block; margin-top: 14px; color: var(--ink-soft); font-size: .9rem; text-decoration: underline; text-underline-offset: 3px; }
.guru-link:hover { color: var(--red); }
.guru-link[hidden] { display: none; }
.title-meta b { color: var(--red); font-family: var(--f-display); font-size: 1.15rem; }

/* ---------- Papan siasatan ---------- */
.board-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 10px 0 34px; }
.board-head h2 { font-size: clamp(1.9rem, 5vw, 3rem); font-weight: 800; }
.board-head h2 span { color: var(--toxic); }
.total-chip { background: rgba(0, 0, 0, .3); border: 2px solid rgba(246, 239, 224, .25); padding: 12px 18px; border-radius: 14px; font-size: .95rem; }
.total-chip b { font-family: var(--f-display); font-size: 1.6rem; margin-left: 8px; color: var(--gold); }
.cases { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px; }
.case { position: relative; transform: rotate(var(--tilt, 0deg)); transition: transform .25s; }
.case:not(.locked):hover { transform: rotate(0deg) translateY(-4px); }
.case::before {
  content: ""; position: absolute; top: 34px; left: 50%; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; z-index: 3;
  background: radial-gradient(circle at 35% 35%, #ff8a75, var(--red) 55%, var(--red-dark)); box-shadow: 0 3px 4px rgba(0, 0, 0, .4);
}
.case-tab { display: inline-block; margin-left: 18px; padding: 9px 16px 7px; border-radius: 10px 10px 0 0; background: var(--manila); color: var(--ink); font-family: var(--f-type); }
.case-body {
  background: linear-gradient(170deg, var(--paper), var(--paper-2)); color: var(--ink); border-radius: 4px 16px 16px 16px;
  padding: 34px 22px 22px; min-height: 260px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, .4); border-top: 10px solid var(--manila);
}
.case-body h3 { font-size: 1.6rem; font-weight: 800; }
.case-body p { margin: 0; color: #3b423f; font-size: .96rem; }
.case-status { margin-top: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .9rem; color: var(--ink-soft); }
.case-status svg.ic { width: 16px; height: 16px; }
.case .btn { width: 100%; margin-top: 6px; }
.case.locked .case-body { filter: grayscale(1); opacity: .62; }
.case .stamp-sm { position: absolute; right: 16px; top: 64px; font-size: 1.15rem; transform: rotate(10deg); color: var(--green); }
.board-foot { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 40px; }

.stars { display: inline-flex; gap: 2px; }
.stars svg { width: 20px; height: 20px; fill: #cfc6b2; }
.stars svg.on { fill: var(--gold); }
.stars-lg { display: flex; gap: 8px; margin: 14px 0 6px; }
.stars-lg svg { width: 44px; height: 44px; fill: #d6ccb6; transform: scale(0); animation: starPop .45s cubic-bezier(.2, 1.7, .4, 1) forwards; }
.stars-lg svg.on { fill: var(--gold); filter: drop-shadow(0 3px 0 rgba(140, 90, 0, .35)); }
@keyframes starPop { to { transform: scale(1); } }

/* ---------- Taklimat ---------- */
.brief h2 { font-size: clamp(2rem, 6vw, 3rem); font-weight: 800; margin-bottom: 10px; }
.brief-obj { font-size: 1.1rem; font-weight: 500; margin: 0 0 20px; }
.brief h4 { font-size: 1.15rem; margin-bottom: 8px; }
.steps { margin: 0 0 22px; padding-left: 22px; }
.steps li { margin: 6px 0; line-height: 1.55; }
.fact {
  display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-radius: 14px;
  background: #e7f2dc; border: 2px dashed #7fb36a; margin: 18px 0 4px;
}
.fact svg { width: 34px; height: 34px; color: var(--green); fill: var(--green); flex: none; }
.fact b { display: block; font-family: var(--f-display); font-size: 1.08rem; margin-bottom: 2px; }
.fact p { margin: 0; font-size: .96rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; margin-top: 22px; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50; display: flex; align-items: center; gap: 14px;
  padding: 12px max(16px, env(safe-area-inset-left)); background: rgba(9, 16, 14, .82); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(246, 239, 224, .14);
}
#hud[hidden] { display: none; }
.hud-mission { font-family: var(--f-display); font-weight: 800; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-meter { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.hud-meter .germ { width: 24px; height: 24px; fill: var(--toxic); color: var(--toxic); }
.meter { width: clamp(80px, 18vw, 190px); height: 14px; border-radius: 999px; background: rgba(255, 255, 255, .12); overflow: hidden; border: 1px solid rgba(255, 255, 255, .2); }
.meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, #5fae3a, var(--toxic), #e2f05a); transition: width .35s ease; }
#meter-val { font-size: .95rem; min-width: 42px; }
#hud.danger .hud-meter { animation: pulse 0.9s ease-in-out infinite; }
#hud.danger .meter-fill { background: linear-gradient(90deg, #9ad13a, #e8f04a, #ff7b5c); }
@keyframes pulse { 50% { transform: scale(1.06); } }
.hud-score { font-size: .9rem; white-space: nowrap; }
.hud-score b { font-family: var(--f-display); font-size: 1.45rem; color: var(--gold); display: inline-block; }
.hud-score b.bump { animation: bump .3s ease; }
@keyframes bump { 50% { transform: scale(1.3); } }
.hud-timer { font-family: var(--f-display); font-weight: 800; font-size: 1.4rem; min-width: 40px; text-align: center; }
.hud-timer.low { color: #ff8a6c; }

/* ---------- Misi 1 ---------- */
.m1-layout { display: grid; grid-template-columns: 1fr 280px; gap: 24px; align-items: start; }
.evidence { padding: 30px clamp(20px, 4vw, 40px); }
.evidence-head { margin-bottom: 16px; border-bottom: 2px dashed #cbbd9d; padding-bottom: 14px; }
.evidence-head h3 { font-size: clamp(1.5rem, 4vw, 2.1rem); font-weight: 800; margin: 12px 0 4px; }
.evidence-head p { margin: 0; }
.passage { font-size: clamp(1.02rem, 2.3vw, 1.16rem); line-height: 2.05; }
.passage p { margin: 0 0 14px; border-radius: 8px; transition: background .3s; }
.passage .w.hinted { background: rgba(227, 169, 15, .5); box-shadow: 0 3px 0 #c58f00; border-radius: 4px; }
.passage p.hinted { background: rgba(227, 169, 15, .22); box-shadow: 0 0 0 6px rgba(227, 169, 15, .22); animation: hintGlow 1s ease-in-out 3; }
@keyframes hintGlow { 50% { background: rgba(227, 169, 15, .4); box-shadow: 0 0 0 6px rgba(227, 169, 15, .4); } }
.w {
  border-radius: 5px; padding: 1px 2px; margin: 0 -2px; transition: background .15s, color .3s;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Ccircle cx='12' cy='12' r='8.5' fill='rgba(255,255,255,.45)' stroke='%231d2321' stroke-width='3'/%3E%3Cpath d='M18.5 18.5l8 8' stroke='%231d2321' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") 12 12, pointer;
}
.w:hover { background: rgba(196, 64, 47, .12); }
.w.checked { color: #8b918d; text-decoration: underline dotted #b2b6b3; cursor: default; }
.w.checked:hover { background: none; }
.w.infected { color: #3f7d1e; text-shadow: 0 0 8px rgba(166, 216, 58, .9); animation: wobble 2.4s ease-in-out infinite; display: inline-block; }
@keyframes wobble { 25% { transform: translateY(-1px) rotate(-1deg); } 75% { transform: translateY(1px) rotate(1deg); } }
.w.shake { animation: shake .35s; display: inline-block; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.w.solved { cursor: default; background: none; }
.w.solved s { color: var(--red); text-decoration-thickness: 2px; opacity: .8; }
.w.solved ins { text-decoration: none; background: var(--green-soft); color: #1d6b37; font-weight: 600; padding: 1px 6px; border-radius: 5px; animation: inkIn .5s ease both; }
.w.solved-alias { cursor: default; }
.w.solved-alias:hover { background: none; }
@keyframes inkIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.m1-side { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 14px; }
.side-card { padding: 22px; }
.side-card h4 { font-size: 1.1rem; }
.found-count { font-family: var(--f-display); font-weight: 800; font-size: 3rem; line-height: 1; margin: 8px 0; }
.found-count span { font-size: 1.6rem; color: var(--ink-soft); }
.found-dots { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.found-dots i { width: 16px; height: 16px; border-radius: 50%; background: #d8ceb8; border: 2px solid #b9ad92; }
.found-dots i.on { background: var(--green); border-color: #1d6b37; animation: starPop .35s ease; }
.log { margin: 0; padding-left: 20px; font-size: .9rem; max-height: 260px; overflow: auto; }
.log li { margin: 6px 0; line-height: 1.4; }
.log s { color: var(--red); }
.log ins { color: #1d6b37; text-decoration: none; font-weight: 600; }
.hint-btn { width: 100%; }

/* Makmal */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(5, 10, 9, .72); backdrop-filter: blur(3px); }
.modal[hidden] { display: none; }
.modal-card { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; animation: popIn .3s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes popIn { from { opacity: 0; transform: scale(.9) translateY(20px); } to { opacity: 1; transform: none; } }
.lab-head h3 { font-size: 1.5rem; margin-top: 12px; }
.evidence-word { font-family: var(--f-type); color: var(--red); background: #fde3dc; padding: 0 8px; border-radius: 6px; }
.lab-ctx { background: #fffaf0; border-left: 4px solid var(--red); padding: 12px 14px; border-radius: 0 10px 10px 0; font-size: 1rem; }
.lab-ctx mark { background: #fde3dc; color: var(--red); font-weight: 600; padding: 0 4px; border-radius: 4px; }
.lab-q { font-weight: 600; margin: 16px 0 10px; }
.lab-q small { display: block; font-weight: 400; color: var(--ink-soft); font-size: .85rem; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt {
  text-align: left; padding: 14px 16px; border-radius: 12px; border: 2px solid var(--ink); background: #fffaf0; color: var(--ink);
  cursor: pointer; font-weight: 500; box-shadow: 0 3px 0 var(--ink); transition: transform .08s, background .2s;
}
.opt:hover:not(:disabled) { background: #fff; transform: translateY(-1px); }
.opt:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.opt.correct { background: var(--green-soft); border-color: var(--green); color: #1d6b37; box-shadow: 0 3px 0 var(--green); }
.opt.wrong { background: #fde3dc; border-color: #d98b7e; color: #a1483a; text-decoration: line-through; box-shadow: none; cursor: not-allowed; animation: shake .35s; }
.why { margin-top: 16px; padding: 16px; border-radius: 12px; background: var(--green-soft); border: 2px solid #8cc57a; animation: inkIn .4s ease; }
.why b { font-family: var(--f-display); font-size: 1.05rem; }
.why p { margin: 6px 0 0; }
.fixline { font-size: 1.15rem; font-weight: 600; }
.fixline s { color: var(--red); }
.fixline ins { color: #1d6b37; text-decoration: none; }

/* ---------- Misi 2 ---------- */
.m2-wrap { max-width: 900px; text-align: center; }
.m2-instr { font-size: 1.08rem; margin: 0 0 12px; }
.bad-word { color: #ff9b85; }
.timebar { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, .12); overflow: hidden; margin-bottom: 16px; }
#m2-time { height: 100%; width: 100%; background: linear-gradient(90deg, var(--gold), #f6d45c); transform-origin: left; }
.street {
  position: relative; border-radius: 22px; padding: 26px 18px 18px; overflow: hidden;
  background: linear-gradient(180deg, #3b4744, #2a3432 70%); border: 3px solid rgba(0, 0, 0, .35);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, .5), 0 20px 40px rgba(0, 0, 0, .35);
}
.street::before { content: ""; position: absolute; inset: 0; opacity: .25; background-image: linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px); background-size: 60px 30px; }
.flood {
  position: absolute; left: -10%; right: -10%; bottom: -8px; height: 46px; pointer-events: none; opacity: .85;
  background: radial-gradient(60px 18px at 50% 0, transparent 60%, rgba(95, 140, 120, .7) 62%) 0 0 / 120px 46px repeat-x;
  animation: flow 6s linear infinite;
}
@keyframes flow { to { background-position: 240px 0; } }
.drains { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 14px; }
.hole { position: relative; height: 230px; }
.hole-mask { position: absolute; left: 0; right: 0; top: 0; bottom: 30px; overflow: hidden; z-index: 1; }
.grate {
  position: absolute; z-index: 0; left: 10%; right: 10%; bottom: 12px; height: 46px; border-radius: 50%;
  background: repeating-linear-gradient(90deg, #36403e 0 7px, #070b0a 7px 14px);
  border: 4px solid #5b6764; box-shadow: inset 0 8px 14px rgba(0, 0, 0, .85), 0 4px 0 rgba(0, 0, 0, .3);
}
.rat {
  position: absolute; left: 50%; bottom: -4px; width: 100%; display: flex; flex-direction: column; align-items: center;
  background: none; border: 0; padding: 0; cursor: pointer; color: inherit;
  transform: translate(-50%, 110%); transition: transform .2s cubic-bezier(.3, 1.4, .6, 1);
}
.hole.up .rat { transform: translate(-50%, 0); }
.hole.leaving .rat { transition-duration: .25s; transition-timing-function: ease-in; }
.sign {
  position: relative; z-index: 1; max-width: 96%; margin-bottom: -6px; padding: 9px 10px; border-radius: 9px;
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  font-weight: 600; font-size: clamp(.82rem, 2.2vw, 1rem); line-height: 1.25; transform: rotate(-2deg); white-space: nowrap;
}
.rat-svg { width: 104px; height: 88px; display: block; }
.hole.caught .sign { background: var(--green-soft); border-color: var(--green); color: #1d6b37; }
.hole.caught .rat-svg { animation: squish .4s ease forwards; }
.hole.wrong .sign { background: #fde3dc; border-color: var(--red); color: var(--red); }
.hole.wrong .rat-svg { animation: shake .35s; }
@keyframes squish { 40% { transform: scale(1.15, .8); } 100% { transform: scale(.9, 1.05); } }
.combo { position: absolute; top: 8px; right: 16px; z-index: 3; font-family: var(--f-display); font-weight: 800; font-size: 1.5rem; color: var(--gold); text-shadow: 0 3px 0 rgba(0, 0, 0, .4); }
.combo.pop { animation: bump .35s ease; }
.countdown { position: fixed; inset: 0; display: grid; place-items: center; z-index: 70; pointer-events: none; font-family: var(--f-display); font-weight: 800; font-size: clamp(6rem, 22vw, 12rem); color: var(--paper); text-shadow: 0 8px 0 rgba(0, 0, 0, .35); }
.countdown[hidden] { display: none; }
.countdown span { animation: countIn .8s ease both; }
@keyframes countIn { from { opacity: 0; transform: scale(2); } 30% { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(.8); } }

/* ---------- Misi 3 ---------- */
.m3-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.poster { margin: 18px 0; border-radius: 14px; padding: 18px; background: #fffaf0; border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--green); }
.poster-title { font-family: var(--f-display); font-weight: 800; font-size: 1.4rem; color: var(--green); margin-bottom: 10px; }
.answer { min-height: 72px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; padding: 10px; border-radius: 10px; border: 2px dashed #b8ab8d; background: repeating-linear-gradient(transparent 0 46px, rgba(0, 0, 0, .06) 46px 48px); }
.answer:empty::before { content: "Ketik kad di bawah untuk membina ayat"; color: #9a9483; font-size: .95rem; padding: 8px 4px; }
.answer.solved { border-color: var(--green); border-style: solid; background: var(--green-soft); }
.m3-label { font-weight: 600; margin: 8px 0; font-size: .95rem; color: var(--ink-soft); }
.tiles { display: flex; flex-wrap: wrap; gap: 10px; min-height: 52px; }
.tile {
  padding: 11px 15px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 1.02rem;
  background: var(--manila); color: var(--ink); border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  transition: transform .1s; animation: tileIn .25s ease both;
}
.tile:hover { transform: translateY(-2px) rotate(-1deg); }
.tile:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.answer .tile { background: #fff; }
.tile.okpos { border-color: var(--green); box-shadow: 0 3px 0 var(--green); background: var(--green-soft); }
.tile.bad { border-color: var(--red); background: #fde3dc; color: var(--red); animation: shake .35s; }
@keyframes tileIn { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
.m3-msg { min-height: 1.6em; margin: 14px 0 0; font-weight: 500; }
.m3-msg.good { color: #1d6b37; }
.m3-msg.bad { color: var(--red); }

/* ---------- Keputusan ---------- */
.report { padding-top: 34px; }
.report h2 { font-size: clamp(2rem, 6vw, 3rem); font-weight: 800; padding-right: 150px; }
.newbest { display: inline-block; margin: 4px 0 0; background: var(--gold); color: var(--ink); font-weight: 600; padding: 4px 12px; border-radius: 999px; font-size: .9rem; }
.newbest[hidden] { display: none; }
.score-table { width: 100%; border-collapse: collapse; margin: 18px 0 8px; font-size: 1rem; }
.score-table td { padding: 10px 4px; border-bottom: 1px dashed #c7b998; }
.score-table td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.score-table tr.total td { border-bottom: 0; border-top: 2px solid var(--ink); font-family: var(--f-display); font-size: 1.35rem; font-weight: 800; }
.review h4 { font-size: 1.1rem; margin: 18px 0 8px; }
.review ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.review li { padding: 9px 12px; border-radius: 10px; background: #fffaf0; border: 1px solid #ddd0b2; font-size: .95rem; line-height: 1.45; }
.review li.miss { border-left: 4px solid var(--red); }
.review li.hit { border-left: 4px solid var(--green); }
.review li.oops { border-left: 4px solid var(--gold); }
.review s { color: var(--red); }
.review ins { color: #1d6b37; text-decoration: none; font-weight: 600; }
.review .cat { display: inline-block; font-size: .78rem; background: #ebe2cc; padding: 1px 8px; border-radius: 999px; margin-left: 6px; color: var(--ink-soft); }
.review .rv-tip { margin: -2px 0 8px; font-size: .88rem; color: var(--ink-soft); }
.review li.rv { padding: 0; }
.review details summary { list-style: none; cursor: pointer; padding: 9px 36px 9px 12px; position: relative; border-radius: 10px; }
.review details summary::-webkit-details-marker { display: none; }
.review details summary::after { content: ''; position: absolute; right: 14px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft); transform: translateY(-70%) rotate(45deg); transition: transform .2s; }
.review details[open] summary::after { transform: translateY(-30%) rotate(-135deg); }
.review details summary:hover { background: #fbf3e2; }
.review details summary:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.review details p { margin: 0; padding: 0 12px 11px; font-size: .9rem; color: var(--ink-soft); border-top: 1px dashed #ddd0b2; padding-top: 9px; }
.final-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 4px; }
.final-grid div { background: #fffaf0; border: 2px solid #ddd0b2; border-radius: 12px; padding: 12px 14px; }
.final-grid span { display: block; font-size: .85rem; color: var(--ink-soft); }
.final-grid b { font-family: var(--f-display); font-size: 1.3rem; }
.final h3 { font-size: 1.4rem; margin-top: 22px; }
#cert { width: 100%; height: auto; border-radius: 10px; box-shadow: 0 8px 22px rgba(0, 0, 0, .25); display: block; }

/* ---------- Kedudukan kelas ---------- */
.btn[hidden] { display: none; }
#s-class .report h2 { margin-top: 0; padding-right: 0; }
.cl-list { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 8px; }
.cl-row { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; background: #fffaf0; border: 1px solid #ddd0b2; }
.cl-row.me { background: #fff3c4; border: 2px solid var(--gold); }
.cl-rank { font-family: var(--f-display); font-weight: 800; font-size: 1.35rem; text-align: center; color: var(--ink-soft); }
.cl-row.r1 .cl-rank { color: #c28a00; }
.cl-row.r2 .cl-rank { color: #7c8790; }
.cl-row.r3 .cl-rank { color: #a8643a; }
.cl-row.r1, .cl-row.r2, .cl-row.r3 { box-shadow: 0 3px 0 rgba(0, 0, 0, .08); }
.cl-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-name .you { display: inline-block; margin-left: 6px; font-size: .78rem; background: var(--gold); color: var(--ink); padding: 1px 8px; border-radius: 999px; vertical-align: middle; }
.cl-ms { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 3px; font-size: .8rem; color: var(--ink-soft); }
.cl-ms .stars svg { width: 12px; height: 12px; }
.cl-total { font-family: var(--f-display); font-weight: 800; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.cl-empty { color: var(--ink-soft); }

/* ---------- Kesan ---------- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 90; }
.float { position: absolute; transform: translate(-50%, -50%); font-family: var(--f-display); font-weight: 800; font-size: 1.5rem; animation: floatUp .95s ease-out forwards; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); white-space: nowrap; }
.float.pos { color: var(--gold); }
.float.neg { color: #ff7b5c; }
.float.info { color: #fff; font-size: 1.05rem; font-family: var(--f-body); font-weight: 600; background: rgba(10, 18, 16, .85); padding: 6px 12px; border-radius: 999px; text-shadow: none; }
@keyframes floatUp { from { opacity: 0; margin-top: 0; } 15% { opacity: 1; } to { opacity: 0; margin-top: -60px; } }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); z-index: 95; max-width: calc(100vw - 140px);
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
  padding: 12px 18px; border-radius: 12px; font-weight: 500; opacity: 0; visibility: hidden;
  transition: transform .3s cubic-bezier(.2, 1.4, .4, 1), opacity .2s, visibility .3s;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

/* ---------- Responsif ---------- */
@media (max-width: 900px) {
  .cases { grid-template-columns: 1fr; max-width: 480px; margin: 0 auto; }
  .case-body { min-height: 0; }
  .m1-layout { grid-template-columns: 1fr; }
  .m1-side { position: static; order: -1; flex-direction: row; align-items: stretch; }
  .side-card { flex: 1; padding: 14px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
  .side-card h4 { width: 100%; font-size: .95rem; }
  .found-count { font-size: 2rem; margin: 0; }
  .found-count span { font-size: 1.1rem; }
  .found-dots { margin: 0; }
  .log { display: none; }
  .hint-btn { width: auto; flex-direction: column; gap: 6px; padding: 10px 14px; font-size: .85rem; }
}
@media (max-width: 640px) {
  .screen { padding: 18px 12px 100px; }
  body.in-mission .screen { padding-top: 120px; }
  #hud { flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px; }
  .hud-mission { flex: 1; font-size: 1rem; }
  .hud-meter { order: 5; width: 100%; margin-left: 0; }
  .meter { flex: 1; width: auto; }
  .paper { padding: 22px 18px; }
  .drains { grid-template-columns: repeat(2, 1fr); gap: 0 8px; }
  .hole { height: 158px; }
  .rat-svg { width: 76px; height: 64px; }
  .sign { padding: 6px 8px; font-size: .8rem; }
  .grate { height: 38px; bottom: 10px; }
  .hole-mask { bottom: 26px; }
  .street { padding: 14px 8px 10px; }
  .m2-instr { font-size: .95rem; margin-bottom: 8px; }
  .timebar { margin-bottom: 10px; }
  body.in-mission .sound-ctl { display: none; }
  .opts { grid-template-columns: 1fr; }
  .report h2 { padding-right: 0; margin-top: 46px; }
  .final-grid { grid-template-columns: 1fr; }
  .row-actions .btn { flex: 1 1 auto; }
  .passage p { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
