:root {
  --ink: #2b1b2f;
  --cream: #fff7ec;
  --pink: #ff6f9c;
  --pink-deep: #d9346a;
  --wood: #7a4a2a;
  --gold: #f4c04d;
  --navy: #22183a;
  --good: #3fbf7f;
  --bad: #e5484d;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(circle at 50% 0, #4a2d5c, var(--navy) 70%);
  color: var(--cream);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  min-height: 100vh;
}
button { font: inherit; cursor: pointer; }
.screen { display: none; }
.screen.active { display: block; }
.muted { color: #b9a6c4; }
.small { font-size: 12px; }

/* ---------- title ---------- */
#title { padding: 24px 16px 48px; }
.title-card { max-width: 760px; margin: 0 auto; text-align: center; }
.title-judge { width: 180px; filter: drop-shadow(0 6px 0 rgba(0,0,0,.25)); }
h1 {
  font-size: clamp(40px, 8vw, 72px); font-weight: 900; margin: 4px 0 0; letter-spacing: 4px;
  color: var(--cream); text-shadow: 4px 4px 0 var(--pink-deep), 8px 8px 0 rgba(0,0,0,.3);
}
h1 span { color: var(--pink); text-shadow: 4px 4px 0 var(--cream), 8px 8px 0 rgba(0,0,0,.3); }
.sub { font-size: 18px; margin: 8px 0 16px; }
.provider { display: inline-block; font-size: 13px; padding: 4px 12px; border-radius: 99px; background: rgba(255,255,255,.1); margin-bottom: 20px; }
.provider.warn { background: rgba(229,72,77,.3); }
.case-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; text-align: left; }
.case {
  background: var(--cream); color: var(--ink); border: 0; border-radius: 14px; padding: 16px; text-align: left;
  box-shadow: 0 5px 0 var(--pink-deep); transition: transform .12s;
}
.case:hover { transform: translateY(-3px) rotate(-.5deg); }
.sides { display: grid; gap: 6px; margin-top: 10px; }
.side-btn { border: 0; border-radius: 10px; padding: 7px 10px; text-align: left; color: white; cursor: pointer; font: inherit; font-size: 13px; }
.side-btn b { font-size: 14px; display: inline; }
.side-btn small { display: block; opacity: .85; font-size: 12px; }
.side-btn.plaintiff { background: #4a4a5a; } .side-btn.defendant { background: #e07a2e; }
.side-btn:hover { filter: brightness(1.12); }
.resume { display: none; margin: 0 0 16px; } .resume.on { display: inline-block; }
.case b { font-size: 19px; display: block; }
.case .charge { display: inline-block; font-size: 12px; background: var(--pink); color: white; border-radius: 6px; padding: 1px 8px; margin: 6px 0; }
.case p { margin: 4px 0 0; font-size: 14px; color: #6b5470; }

/* ---------- stage ---------- */
#court { max-width: 1100px; margin: 0 auto; padding: 12px 16px 24px; }
.stage {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 14px;
  border: 4px solid var(--wood); box-shadow: 0 8px 0 rgba(0,0,0,.35); background: #3a2414;
  user-select: none;
  /* keep stage + input panel inside one screen on short windows */
  width: min(100%, calc((100vh - 250px) * 16 / 9)); min-width: min(100%, 320px); margin: 0 auto;
}
.stage.shake { animation: shake .35s; }
@keyframes shake {
  20% { transform: translate(-8px, 4px); } 40% { transform: translate(7px, -5px); }
  60% { transform: translate(-5px, 3px); } 80% { transform: translate(4px, -2px); }
}
.bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sprite {
  position: absolute; left: 50%; bottom: 0; height: 92%; transform: translateX(-50%);
  filter: drop-shadow(0 0 12px rgba(0,0,0,.35)); transition: opacity .15s;
}
.sprite.enter { animation: enter .25s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateX(-46%); } to { opacity: 1; transform: translateX(-50%); } }

.hud { position: absolute; top: 10px; left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 8px; align-items: center; z-index: 3; }
.meter { display: flex; align-items: center; gap: 8px; background: rgba(34,24,58,.8); padding: 6px 12px; border-radius: 99px; }
.meter-label { font-size: 13px; font-weight: 700; white-space: nowrap; }
.meter-bar { position: relative; width: clamp(90px, 22vw, 240px); height: 14px; background: #4b3b5e; border-radius: 99px; overflow: hidden; }
.meter-fill { position: absolute; inset: 0 auto 0 0; width: 50%; background: linear-gradient(90deg, var(--pink-deep), var(--pink)); border-radius: 99px; transition: width .6s cubic-bezier(.3,1.4,.5,1); }
.meter-mark { position: absolute; top: 0; bottom: 0; left: 58%; width: 2px; background: var(--gold); }
.meter-mark.lose { left: 42%; background: #9aa0b5; }
.meter-num { font-weight: 900; min-width: 2ch; }
.hud-right { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.hud-right > span { background: rgba(34,24,58,.8); padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.chip { background: var(--cream); color: var(--ink); border: 0; border-radius: 99px; padding: 4px 10px; font-size: 13px; font-weight: 700; }

.delta { position: absolute; top: 46px; left: 40px; font-size: 34px; font-weight: 900; opacity: 0; z-index: 4; text-shadow: 3px 3px 0 rgba(0,0,0,.4); }
.delta.show { animation: pop 1.4s ease-out; }
.delta.up { color: #ffd1e1; } .delta.down { color: #9fd0ff; }
@keyframes pop { 0% { opacity: 0; transform: translateY(10px) scale(.6); } 20% { opacity: 1; transform: translateY(0) scale(1.15); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-16px); } }

.shout { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; z-index: 6; pointer-events: none; }
.shout.show { display: flex; animation: shoutIn .9s ease-out forwards; }
.shout span {
  font-size: clamp(36px, 9vw, 96px); font-weight: 900; color: var(--cream); padding: 40px 70px;
  background: var(--pink-deep); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  clip-path: polygon(50% 0, 61% 18%, 82% 6%, 78% 30%, 100% 34%, 84% 50%, 100% 68%, 77% 70%, 82% 94%, 61% 82%, 50% 100%, 39% 82%, 18% 94%, 22% 70%, 0 68%, 16% 50%, 0 34%, 22% 30%, 18% 6%, 39% 18%);
  transform: rotate(-6deg);
}
.shout.blue span { background: #3d6fd9; }
.shout.gold span { background: #d99a1e; }
@keyframes shoutIn { 0% { transform: scale(2.2); opacity: 0; } 18% { transform: scale(.95); opacity: 1; } 28% { transform: scale(1.05); } 80% { opacity: 1; } 100% { opacity: 0; } }

.flash { position: absolute; inset: 0; background: white; opacity: 0; pointer-events: none; z-index: 5; }
.flash.go { animation: flash .35s; }
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }

.textbox {
  position: absolute; left: 3%; right: 3%; bottom: 3%; min-height: 27%; z-index: 4; cursor: pointer;
  background: rgba(26,18,44,.88); border: 3px solid var(--cream); border-radius: 12px; padding: 22px 22px 14px;
}
.nameplate {
  position: absolute; top: -18px; left: 16px; background: var(--pink); color: white; font-weight: 900;
  padding: 3px 16px; border-radius: 8px; border: 3px solid var(--cream); font-size: 16px;
}
.nameplate.prosecutor { background: #4a4a5a; } .nameplate.judge { background: var(--wood); } .nameplate.defense { background: #e07a2e; }
.text { font-size: clamp(15px, 2.1vw, 21px); line-height: 1.6; white-space: pre-wrap; }
.next { position: absolute; right: 14px; bottom: 6px; color: var(--pink); animation: bob .8s infinite; visibility: hidden; }
.next.on { visibility: visible; }
@keyframes bob { 50% { transform: translateY(4px); } }
.note { position: absolute; right: 14px; top: -16px; background: var(--gold); color: var(--ink); font-size: 13px; font-weight: 700; border-radius: 8px; padding: 2px 10px; display: none; }
.note.on { display: block; }

/* ---------- panel ---------- */
.panel { position: relative; margin-top: 14px; background: rgba(255,247,236,.07); border-radius: 14px; padding: 12px; }
.panel.locked .ev-row, .panel.locked .input-row { opacity: .45; pointer-events: none; }
.ev-label { font-size: 13px; color: #d8c6e0; margin-bottom: 6px; }
.ev-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ev {
  background: var(--cream); color: var(--ink); border: 3px solid transparent; border-radius: 10px; padding: 6px 10px;
  font-size: 14px; font-weight: 700; max-width: 260px; text-align: left;
}
.ev small { display: block; font-weight: 400; color: #6b5470; font-size: 12px; }
.ev.sel { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(255,111,156,.35); transform: translateY(-2px); }
.input-row { display: flex; gap: 10px; align-items: stretch; }
textarea {
  flex: 1; resize: none; border-radius: 10px; border: 0; padding: 10px; font: inherit; font-size: 16px;
  background: var(--cream); color: var(--ink);
}
.actions { display: flex; flex-direction: column; gap: 6px; justify-content: flex-end; min-width: 120px; }
.count { font-size: 12px; text-align: right; color: #d8c6e0; }
.btn { border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 900; font-size: 16px; background: var(--cream); color: var(--ink); box-shadow: 0 4px 0 rgba(0,0,0,.3); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.3); }
.btn.say { background: var(--pink); color: white; }
.btn.obj { background: var(--gold); }
.btn.obj.armed { background: var(--pink-deep); color: white; outline: 3px solid var(--cream); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn small { font-size: 12px; margin-left: 4px; }
.thinking { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; font-weight: 900; font-size: 18px; background: rgba(34,24,58,.75); border-radius: 14px; }
.thinking.on { display: flex; }
.thinking span { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,8,25,.75); display: none; align-items: flex-start; justify-content: center; padding: 24px 16px; overflow-y: auto; z-index: 20; }
.modal.on { display: flex; }
.modal-card { position: relative; background: var(--cream); color: var(--ink); border-radius: 16px; padding: 22px; max-width: 620px; width: 100%; }
.modal-card h2 { margin: 0; } .modal-card h3 { margin: 16px 0 6px; font-size: 16px; color: var(--pink-deep); }
.modal-card ul { margin: 0; padding-left: 20px; } .modal-card li { margin: 4px 0; }
.modal-card .muted { color: #8a7490; }
.people { display: grid; gap: 4px; margin-top: 10px; font-size: 14px; }
.close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 26px; color: var(--ink); }

.paper {
  background: #fffaf0; color: var(--ink); max-width: 640px; width: 100%; border-radius: 6px; padding: 28px 30px;
  box-shadow: 0 12px 0 rgba(0,0,0,.3); background-image: repeating-linear-gradient(transparent 0 31px, #f1e3cf 31px 32px);
  animation: drop .5s cubic-bezier(.3,1.4,.5,1);
}
@keyframes drop { from { transform: translateY(-40px) rotate(-2deg); opacity: 0; } }
.paper-head { text-align: center; font-size: 22px; font-weight: 900; letter-spacing: 6px; border-bottom: 3px double var(--ink); padding-bottom: 8px; }
.v-case { text-align: center; margin: 8px 0 14px; color: #6b5470; }
.v-main { display: flex; gap: 18px; align-items: center; margin-bottom: 12px; }
.stamp {
  flex: none; width: 110px; height: 110px; border-radius: 50%; border: 6px solid var(--bad); color: var(--bad);
  display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 900; transform: rotate(-12deg);
  animation: stamp .4s .3s both cubic-bezier(.3,1.6,.5,1);
}
.stamp.good { border-color: var(--good); color: var(--good); } .stamp.mid { border-color: #d99a1e; color: #d99a1e; }
@keyframes stamp { from { transform: scale(2.5) rotate(-12deg); opacity: 0; } }
.v-label { font-weight: 900; color: var(--pink-deep); margin-top: 10px; }
.v-text { line-height: 1.7; } .v-text.big { font-size: 20px; font-weight: 900; }
.scores { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px; margin: 14px 0 4px; font-size: 14px; }
.score-bar { height: 8px; background: #eadbea; border-radius: 99px; overflow: hidden; margin-top: 2px; }
.score-bar div { height: 100%; background: var(--pink); }
.score-bar.opp div { background: #8a8aa0; }
.rec-log { padding-left: 20px; font-size: 14px; } .rec-log li { margin: 6px 0; } .rec-log .who { font-weight: 700; }
.truth { padding-left: 0; list-style: none; margin: 6px 0; }
.truth li { margin: 4px 0; padding-left: 26px; position: relative; }
.truth li::before { position: absolute; left: 0; content: "❓"; }
.truth li.found::before { content: "✅"; }
.v-last { text-align: right; font-weight: 700; margin: 14px 0 6px; }
.v-buttons { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .hud { flex-direction: column; align-items: flex-start; }
  .meter-label, #keyInfo { display: none; }
  .textbox { padding: 18px 12px 10px; }
  .input-row { flex-direction: column; }
  .actions { flex-direction: row; align-items: center; }
  .actions .btn { flex: 1; }
  .paper { padding: 22px 16px; }
  .stamp { width: 84px; height: 84px; font-size: 26px; }
}
