/* Clue Detective: Memphis style. Yellow = clue, pink = cause, teal = effect. */
:root {
  --ink: #1b1b2f; --cream: #fff6e5; --yellow: #ffd23f; --pink: #ff6b9a; --teal: #3dd6c6; --purple: #6c4cf0; --lav: #c3b3ff;
  --pink-text: #c8174f; --teal-text: #067a70;
  --line: 3px solid var(--ink); --shadow: 5px 5px 0 var(--ink); --r: 18px;
  --display: "Fredoka", "Trebuchet MS", Arial, sans-serif;
  --body: "Nunito", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--cream); color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.4; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); margin: 0; }
p { margin: 0 0 8px; }
.small { font-size: 14px; opacity: 0.85; }

/* colour code */
.hl-clue { background: var(--yellow); padding: 0 4px; border-radius: 6px; }
.hl-inf { color: var(--pink-text); }
.hl-res { color: var(--teal-text); }
mark { padding: 1px 5px; border-radius: 6px; color: var(--ink); font-weight: 800; }
mark.m-clue { background: var(--yellow); }
mark.m-inf { background: var(--pink); }
mark.m-res { background: var(--teal); }

/* buttons */
.btn { border: var(--line); border-radius: 999px; padding: 10px 20px; font-family: var(--display); font-weight: 600; font-size: 18px; background: #fff; box-shadow: 3px 3px 0 var(--ink); transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn.primary { background: var(--purple); color: var(--cream); }
.btn.ghost { background: #fff; }
.btn.big { font-size: 22px; padding: 14px 28px; }
.btn.small { font-size: 15px; padding: 6px 14px; }
.btn:disabled { opacity: .4; }
.link-btn { background: none; border: 0; text-decoration: underline; font-weight: 700; display: block; margin: 4px auto 0; }
.icon-btn { width: 44px; height: 44px; border: var(--line); border-radius: 50%; background: #fff; font-size: 22px; line-height: 1; display: grid; place-items: center; box-shadow: 2px 2px 0 var(--ink); padding: 0; }

/* ---------- home ---------- */
#home { position: relative; min-height: 100dvh; padding: 28px 20px 24px; max-width: 560px; margin: 0 auto; overflow: hidden; }
.memphis i { position: absolute; display: block; z-index: 0; }
.m-circle { width: 120px; height: 120px; border-radius: 50%; background: var(--pink); border: var(--line); right: -40px; top: 30px; }
.m-tri { width: 0; height: 0; border-left: 34px solid transparent; border-right: 34px solid transparent; border-bottom: 58px solid var(--teal); left: -8px; top: 250px; transform: rotate(-18deg); }
.m-squiggle { width: 150px; height: 26px; right: 12px; top: 175px;
  background: radial-gradient(circle at 10px 0, transparent 9px, var(--purple) 10px 15px, transparent 16px) 0 13px / 40px 26px repeat-x,
              radial-gradient(circle at 30px 26px, transparent 9px, var(--purple) 10px 15px, transparent 16px) 0 -13px / 40px 26px repeat-x; }
.m-dots { width: 110px; height: 70px; left: 14px; bottom: 40px; background: radial-gradient(var(--ink) 3.5px, transparent 4px) 0 0 / 20px 20px; opacity: .7; }
.hero, .how, .cases, .foot { position: relative; z-index: 1; }
.badge { display: inline-block; background: var(--ink); color: var(--cream); font-family: var(--display); font-weight: 600; border-radius: 999px; padding: 4px 14px; font-size: 15px; }
.logo { font-size: 58px; line-height: .95; margin: 10px 0 12px; }
.logo span { color: var(--purple); -webkit-text-stroke: 2px var(--ink); text-shadow: 4px 4px 0 var(--yellow); }
.lede { font-size: 19px; font-weight: 700; }
.how { list-style: none; padding: 0; margin: 18px 0; display: flex; gap: 8px; }
.how li { flex: 1; border: var(--line); border-radius: 14px; padding: 8px 6px; font-family: var(--display); font-weight: 600; text-align: center; box-shadow: 3px 3px 0 var(--ink); }
.how b { display: block; font-size: 22px; }
.how .y { background: var(--yellow); } .how .p { background: var(--pink); } .how .t { background: var(--teal); }
.cases { display: grid; gap: 16px; }
.case-card { display: grid; gap: 4px; text-align: left; border: var(--line); border-radius: var(--r); background: #fff; padding: 16px 18px; box-shadow: var(--shadow); }
.case-card:not(.locked):active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.case-card.locked { opacity: .55; box-shadow: none; border-style: dashed; }
.case-num { font-family: var(--display); font-weight: 600; font-size: 14px; color: var(--purple); text-transform: uppercase; letter-spacing: 1px; }
.case-title { font-family: var(--display); font-weight: 700; font-size: 26px; }
.case-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.go { font-family: var(--display); font-weight: 600; background: var(--yellow); border: var(--line); border-radius: 999px; padding: 4px 14px; }
.star { font-size: 24px; color: #d9cfbf; -webkit-text-stroke: 1px var(--ink); }
.star.on { color: var(--yellow); }
.foot { margin-top: 22px; text-align: center; display: grid; gap: 8px; justify-items: center; }

/* ---------- game layout ---------- */
#game { height: 100dvh; display: flex; flex-direction: column; max-width: 1100px; margin: 0 auto; }
.bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px 6px; }
.bar-title { flex: 1; font-size: 19px; line-height: 1.1; }
.tabs { display: flex; gap: 6px; padding: 0 12px 8px; }
.tabs button { flex: 1; border: var(--line); border-radius: 999px; background: #fff; font-family: var(--display); font-weight: 600; font-size: 15px; padding: 6px 4px; }
.tabs button.on.y { background: var(--yellow); } .tabs button.on.p { background: var(--pink); } .tabs button.on.t { background: var(--teal); }
.tabs button.on { box-shadow: 2px 2px 0 var(--ink); }
.stage { position: relative; flex: 0 0 36dvh; transition: flex-basis .3s; margin: 0 12px; border: var(--line); border-radius: var(--r); overflow: hidden; background: var(--cream); box-shadow: var(--shadow); }
body[data-part="3"] .stage { flex-basis: 28dvh; }
#scene { width: 100%; height: 100%; display: block; touch-action: pan-y; }
.stage-hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); margin: 0; background: var(--ink); color: var(--cream); border-radius: 999px; padding: 4px 14px; font-weight: 700; font-size: 15px; white-space: nowrap; pointer-events: none; animation: bob 1.6s ease-in-out infinite; }
.no3d { padding: 20px; font-weight: 700; }
.panel { flex: 1; overflow-y: auto; padding: 14px 12px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 860px) {
  #game { display: grid; grid-template-columns: 1.2fr 1fr; grid-template-rows: auto auto 1fr; }
  .bar, .tabs { grid-column: 1 / -1; }
  .stage { grid-row: 3; margin-bottom: 14px; }
  .panel { grid-row: 3; }
}

/* guide + bubble */
.guide { display: flex; gap: 8px; align-items: flex-end; }
.avatar { width: 84px; height: auto; flex: none; transform-origin: bottom center; }
.avatar.talking { animation: talk .5s ease-in-out infinite; }
.bubble { position: relative; flex: 1; background: #fff; border: var(--line); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); margin-bottom: 18px; }
.bubble::before { content: ""; position: absolute; left: -12px; bottom: 18px; width: 18px; height: 18px; background: #fff; border-left: var(--line); border-bottom: var(--line); transform: rotate(45deg); }
.step-title { font-family: var(--display); font-weight: 700; font-size: 20px; margin-bottom: 6px; }
.bubble-body .say { font-size: 19px; font-weight: 800; }
.tag { display: inline-block; font-family: var(--display); font-weight: 600; font-size: 14px; border: 2px solid var(--ink); border-radius: 999px; padding: 2px 10px; text-transform: uppercase; letter-spacing: 1px; }
.tag.pink { background: var(--pink); } .tag.teal { background: var(--teal); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { border: 2.5px solid var(--ink); border-radius: 999px; padding: 6px 12px; font-family: var(--display); font-weight: 600; font-size: 16px; background: #fff; }
.chip.clue { background: var(--yellow); } .chip.inf { background: var(--pink); } .chip.res { background: var(--teal); }
.chips.pick .chip { background: #fff; box-shadow: 2px 2px 0 var(--ink); }
.chips.pick .chip.on { background: var(--teal); transform: translate(2px, 2px); box-shadow: none; }

.chain { display: grid; gap: 8px; }
.link { margin: 0; border: 2.5px solid var(--ink); border-radius: 14px; padding: 8px 12px; font-weight: 700; }
.link.c1 { background: var(--yellow); } .link.c2 { background: #ffe0ea; } .link.c3 { background: #d6f6f2; }

.controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 14px 0 6px; }
.dots { display: flex; justify-content: center; gap: 6px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink); background: #fff; }
.dots i.done { background: var(--lav); } .dots i.on { background: var(--purple); width: 22px; border-radius: 6px; }

/* practice */
.clue-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.clue { border: 2.5px solid var(--ink); border-radius: 14px; padding: 8px 12px; font-weight: 700; }
.clue.found { background: var(--yellow); }
.clue.missing { background: repeating-linear-gradient(45deg, #fff, #fff 8px, #f3ead8 8px, #f3ead8 16px); color: #8a7f6c; text-align: center; letter-spacing: 4px; }
.choices { display: grid; gap: 10px; margin: 10px 0; }
.choice { text-align: left; border: var(--line); border-radius: 14px; background: #fff; padding: 12px 14px; font-weight: 700; font-size: 17px; box-shadow: 3px 3px 0 var(--ink); }
.choice.right { background: #d6f6f2; border-color: var(--teal-text); }
.choice.inf.right { background: #ffe0ea; border-color: var(--pink-text); }
.choice.wrong { opacity: .45; text-decoration: line-through; box-shadow: none; }
.feedback { border-radius: 14px; padding: 10px 12px; font-weight: 700; border: 2.5px solid var(--ink); }
.feedback.ok { background: var(--teal); } .feedback.no { background: #ffe0ea; }
.build { background: #fff; border: var(--line); border-radius: 14px; padding: 12px 14px; font-size: 19px; font-weight: 800; box-shadow: 3px 3px 0 var(--ink); }
.slot { display: inline-block; min-width: 40px; border-bottom: 3px dashed var(--ink); color: #8a7f6c; }
.slot.res { color: var(--teal-text); }

/* speak */
.frame { background: var(--ink); color: var(--cream); border-radius: 14px; padding: 12px 14px; font-weight: 700; font-size: 17px; }
.frame .hl-inf { color: var(--pink); } .frame .hl-res { color: var(--teal); }
.blank { display: inline-block; padding: 0 8px; border-radius: 8px; color: var(--ink); font-weight: 800; }
.blank.y { background: var(--yellow); } .blank.p { background: var(--pink); } .blank.t { background: var(--teal); }
.helper { border: 2.5px dashed var(--ink); border-radius: 14px; padding: 8px 12px; margin: 10px 0; background: #fff; }
.helper summary { font-weight: 800; cursor: pointer; }
.mic-wrap { display: grid; justify-items: center; gap: 6px; margin: 16px 0 8px; }
.mic { width: 92px; height: 92px; border-radius: 50%; border: var(--line); background: var(--pink); font-size: 40px; box-shadow: var(--shadow); }
.mic.on { background: var(--teal); animation: pulse 1s ease-in-out infinite; }
.mic-status { font-weight: 700; margin: 0; text-align: center; }
.heard { background: #fff; border: var(--line); border-radius: 14px; padding: 12px; font-size: 18px; line-height: 1.7; }
.type-form { display: grid; gap: 8px; }
.type-form textarea { font: inherit; border: var(--line); border-radius: 14px; padding: 10px; resize: vertical; }
.checking { text-align: center; font-weight: 700; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid var(--ink); border-top-color: var(--pink); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
.result-card { border: var(--line); border-radius: var(--r); background: #fff; padding: 14px; box-shadow: var(--shadow); margin-top: 12px; text-align: center; }
.result-card.s3 { background: #fffbe9; }
.big-stars { font-size: 46px; margin: 0; letter-spacing: 6px; }
.big-stars span { color: #e3d9c8; -webkit-text-stroke: 2px var(--ink); }
.big-stars span.on { color: var(--yellow); animation: pop-in .4s both; }
.big-stars span.on:nth-child(2) { animation-delay: .15s; } .big-stars span.on:nth-child(3) { animation-delay: .3s; }
.result-card h2 { font-size: 26px; margin-bottom: 6px; }
.parts { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 8px; text-align: left; }
.parts .row { display: flex; gap: 10px; align-items: flex-start; border: 2.5px solid var(--ink); border-radius: 14px; padding: 8px 10px; }
.parts .row.y { background: #fff3c4; } .parts .row.p { background: #ffe0ea; } .parts .row.t { background: #d6f6f2; }
.parts .row.no { background: #fff; border-style: dashed; }
.tick { font-size: 26px; line-height: 1; }
.row.ok .tick { color: var(--yellow); -webkit-text-stroke: 1.5px var(--ink); }
.tip { background: var(--lav); border: 2.5px solid var(--ink); border-radius: 14px; padding: 8px 12px; font-weight: 700; text-align: left; }
.fixes { text-align: left; }
.fixes s { opacity: .7; }

/* motion */
@keyframes pop-in { from { opacity: 0; transform: scale(.85); } }
.pop-in { animation: pop-in .35s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.shake { animation: shake .4s; }
@keyframes jelly { 30% { transform: scale(1.12, .9); } 60% { transform: scale(.94, 1.06); } }
.jelly { animation: jelly .5s; }
@keyframes talk { 50% { transform: rotate(-2deg) scale(1.02); } }
@keyframes pulse { 50% { transform: scale(1.08); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bob { 50% { transform: translate(-50%, -4px); } }

/* celebrations from fx.js */
.confetti { position: fixed; left: 50%; top: 40%; width: 10px; height: 10px; z-index: 50; pointer-events: none; animation: confetti var(--d) ease-out forwards; }
@keyframes confetti { 30% { transform: translate(var(--x), var(--up)) rotate(calc(var(--r) / 2)); } to { transform: translate(var(--x), var(--down)) rotate(var(--r)); opacity: 0; } }
.particle { position: fixed; bottom: -40px; z-index: 50; pointer-events: none; animation: float-up var(--d) ease-out var(--delay) forwards; opacity: 0; }
.particle.down { bottom: auto; top: -40px; animation-name: float-down; }
@keyframes float-up { 10% { opacity: 1; } to { transform: translate(var(--drift), -90vh); opacity: 0; } }
@keyframes float-down { 10% { opacity: 1; } to { transform: translate(var(--drift), 90vh); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
