:root {
  --bs: 360px;
  --bg: #1f1a17;
  --panel: #2d2520;
  --text: #f3eadf;
  --light-sq: #ecd9b6;
  --dark-sq: #7a4b2a;
  --frame: #3a2416;
  --hl: #ffe48a;
  --red: #c43a2f;
  --gold: #e2b33c;
  --colin: #7dff8a;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button { font-family: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
#app {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  max-width: 680px; margin: 0 auto;
  position: relative; overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #33281f 0%, var(--bg) 70%);
}

/* ---------------- top bar & opponent ---------------- */
#topbar {
  flex: none; height: calc(44px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 4px 0;
  display: flex; align-items: center;
}
#chapTitle {
  flex: 1; text-align: center; font-size: 13px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.iconbtn {
  width: 44px; height: 44px; border: 0; background: none; color: var(--text);
  font-size: 20px; border-radius: 10px; opacity: .8;
}
.iconbtn:active { background: #ffffff14; }
#opponent {
  flex: none; height: 62px; display: flex; align-items: center; gap: 8px; padding: 0 12px; position: relative;
}
.avatar { width: 54px; height: 54px; flex: none; filter: drop-shadow(0 3px 4px #0008); }
.avatar svg { width: 100%; height: 100%; display: block; }
.ln { fill: none; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.bark {
  position: relative; max-width: 58%; padding: 6px 10px; border-radius: 10px;
  background: #0b1d10; color: var(--colin); border: 1px solid #2f6b3a;
  font: 13px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  opacity: 0; transform: translateX(-8px); transition: opacity .2s, transform .2s;
}
.bark.on { opacity: 1; transform: none; }
.bark::before {
  content: ''; position: absolute; left: -7px; top: 50%; margin-top: -6px;
  border: 6px solid transparent; border-right-color: #2f6b3a; border-left: 0;
}
#hud {
  margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; line-height: 1.25;
  opacity: 0; transition: opacity .3s; text-align: right;
}
#hud.on { opacity: 1; }
.hudtxt b { font-size: 13px; }
.hudtxt .bar { height: 5px; width: 110px; background: #0006; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.hudtxt .bar i { display: block; height: 100%; width: 30%; background: var(--colin); animation: barmove 1.4s ease-in-out infinite; }
@keyframes barmove { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
.resign { padding: 8px 14px; border-radius: 999px; border: 0; background: #ffffff1a; color: var(--text); font-weight: 800; font-size: 13px; box-shadow: inset 0 0 0 1px #ffffff33; animation: fadein .3s; }
.vane {
  width: 36px; height: 36px; border-radius: 50%; background: #10202c; border: 2px solid #4a7a9a;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.vane span { display: block; transform: rotate(var(--a)); color: #9fd3ff; font-size: 18px; transition: transform .6s; }

/* ---------------- stage & board ---------------- */
#stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; }
#boardWrap { width: var(--bs); height: var(--bs); position: relative; }
#board {
  position: absolute; inset: 0; border-radius: 3px;
  background: var(--light-sq);
  box-shadow: 0 0 0 5px var(--frame), 0 0 0 7px #24150c, 0 12px 30px #000a;
  touch-action: none;
  transition: filter .6s, box-shadow .6s;
}
#squares, #pieces, #fx { position: absolute; inset: 0; }
#fx { pointer-events: none; z-index: 20; }
.sq { position: absolute; width: 12.5%; height: 12.5%; left: calc(var(--c) * 12.5%); top: calc(var(--r) * 12.5%); transition: background .6s; }
.sq.light { background: var(--light-sq); }
.sq.dark { background: var(--dark-sq); }
.sq.last { box-shadow: inset 0 0 0 999px #ffd27a26; }
.sq.sel::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 3px var(--hl); }
.sq.tgt::after {
  content: ''; position: absolute; left: 34%; top: 34%; width: 32%; height: 32%; border-radius: 50%;
  background: #ffe48ac0; box-shadow: 0 0 10px var(--hl); animation: pulse 1s ease-in-out infinite;
}
.sq.poop::before {
  content: ''; position: absolute; inset: 22%;
  background: radial-gradient(circle at 40% 40%, #fff 0 30%, #e8e8e0 31% 45%, transparent 46%),
              radial-gradient(circle at 70% 65%, #f4f4ee 0 18%, transparent 19%),
              radial-gradient(circle at 25% 72%, #f4f4ee 0 14%, transparent 15%);
}
.sq.void { background: transparent !important; }
.sq.glow { box-shadow: inset 0 0 0 999px #ffe48a40, inset 0 0 12px #ffe48a; }
@keyframes pulse { 0%, 100% { transform: scale(.85); opacity: .8; } 50% { transform: scale(1.05); opacity: 1; } }

/* ---------------- pieces ---------------- */
.pc {
  position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%;
  transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%));
  transition: transform var(--mv, 230ms) cubic-bezier(.3, .7, .4, 1), opacity .3s;
  z-index: 2; pointer-events: none;
}
.pc.moving { z-index: 6; }
.pc-in { position: absolute; inset: 9%; transition: transform .15s, filter .2s; }
.disc { position: absolute; inset: 0; border-radius: 50%; }
.disc::before {
  content: ''; position: absolute; inset: 17%; border-radius: 50%;
  border: calc(var(--bs) * .005) solid #0000002e; box-shadow: 0 1px 0 #ffffff22, inset 0 1px 0 #00000022;
}
.pc.red .disc {
  background: radial-gradient(circle at 35% 30%, #ea6052, #c43a2f 55%, #a52b21);
  box-shadow: 0 calc(var(--bs) * .006) 0 #7c1d16, 0 calc(var(--bs) * .012) calc(var(--bs) * .014) #0008;
}
.pc.black .disc {
  background: radial-gradient(circle at 35% 30%, #55555c, #2d2d32 55%, #1d1d21);
  box-shadow: 0 calc(var(--bs) * .006) 0 #0a0a0b, 0 calc(var(--bs) * .012) calc(var(--bs) * .014) #0008;
}
.pc.grey .disc {
  background: radial-gradient(circle at 35% 30%, #d8d6d0, #9c9a94 60%, #77746e);
  box-shadow: 0 calc(var(--bs) * .006) 0 #4d4b47, 0 calc(var(--bs) * .012) calc(var(--bs) * .014) #0008;
}
.pc.king .disc { box-shadow: 0 calc(var(--bs) * .006) 0 #0004, 0 calc(var(--bs) * .013) 0 currentColor, 0 calc(var(--bs) * .02) calc(var(--bs) * .014) #0008; }
.pc.red.king { color: #8e231b; }
.pc.black.king { color: #050506; }
.pc.grey.king { color: #4d4b47; }
.crown { display: none; position: absolute; left: 24%; right: 24%; top: -14%; filter: drop-shadow(0 1px 1px #0008); }
.crown svg { display: block; width: 100%; }
.pc.king .crown { display: block; }
.eyes { display: none; position: absolute; left: 21%; right: 21%; top: 30%; height: 34%; justify-content: space-between; }
#board.awake .eyes { display: flex; }
.k-egg .eyes, .k-pigeon .eyes, .k-thing .eyes, .k-duck .eyes { display: none !important; }
.eye {
  width: 42%; height: 100%; background: #fff; border-radius: 50%; position: relative; overflow: hidden;
  animation: blink 6s infinite; animation-delay: var(--bd, 0s);
  box-shadow: inset 0 -1px 2px #0003;
}
.eye i {
  position: absolute; width: 50%; height: 50%; left: 25%; top: 25%; border-radius: 50%; background: #111;
  transform: translate(calc(var(--ex, 0) * 48%), calc(var(--ey, 0) * 48%));
  transition: transform .12s;
}
@keyframes blink { 0%, 95%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.08); } }
.acc { position: absolute; pointer-events: none; }
.acc svg { display: block; width: 100%; }
.acc.cap { left: 2%; right: 2%; top: -20%; }
.acc.plaster { right: -6%; top: -2%; width: 40%; transform: rotate(32deg); }
.pc.sel-pc .pc-in { transform: translateY(-7%) scale(1.07); filter: drop-shadow(0 0 calc(var(--bs) * .012) var(--hl)); }
.pc.must .pc-in { animation: must 1s ease-in-out infinite; }
@keyframes must { 0%, 100% { filter: drop-shadow(0 0 0 #ffe48a00); } 50% { filter: drop-shadow(0 0 calc(var(--bs) * .016) #ffe48a); } }
.pc.dim { opacity: .4; }
.pc.spawn .pc-in { animation: spawn .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes spawn { from { transform: scale(0); } to { transform: scale(1); } }
.pc.hop .pc-in { animation: hop var(--mv, 230ms) ease-out; }
@keyframes hop { 0% { transform: scale(1); } 45% { transform: scale(1.25) translateY(-10%); } 100% { transform: scale(1); } }
.pc.wobble .pc-in { animation: wobble .45s; }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
.pc.lookup .pc-in { animation: lookup .4s; }
@keyframes lookup { 50% { transform: translateY(-12%) scale(1.08); } }
.pc.flip .pc-in { animation: flip .7s; }
@keyframes flip { 0% { transform: rotateY(0) scale(1); } 50% { transform: rotateY(90deg) scale(1.2); } 100% { transform: rotateY(0) scale(1); } }
.pc.shake .pc-in { animation: tremble .25s 3; }
.pc.gone {
  transition: transform .85s cubic-bezier(.4, -0.3, .7, .4), opacity .85s;
  transform: translate(calc(var(--c) * 100% + var(--fx)), calc(var(--r) * 100% + var(--fy))) rotate(var(--fr));
  opacity: 0; z-index: 9;
}
.pc.strike .pc-in { filter: saturate(.7) brightness(.95); }
.placard:empty { display: none; }
.placard {
  position: absolute; left: 50%; bottom: 74%; transform: translateX(-50%) rotate(-6deg);
  background: #fffbe8; color: #1a1a1a; border: 1px solid #333; border-radius: 2px;
  font: 800 calc(var(--bs) * .021)/1.05 Impact, "Arial Narrow", sans-serif; letter-spacing: .02em;
  padding: 2px 3px; white-space: nowrap; z-index: 4; box-shadow: 0 2px 2px #0006;
  animation: placard 1.6s ease-in-out infinite;
}
.placard::after { content: ''; position: absolute; left: 50%; top: 100%; width: 2px; height: calc(var(--bs) * .03); background: #8a6a40; }
@keyframes placard { 0%, 100% { transform: translateX(-50%) rotate(-6deg); } 50% { transform: translateX(-50%) rotate(5deg) translateY(-2px); } }
/* named pieces get a little name badge when the board is awake */
#board.awake .pc.n-gary::before, #board.awake .pc.n-brenda::before {
  position: absolute; left: 50%; bottom: -6%; transform: translateX(-50%);
  font: 700 calc(var(--bs) * .019)/1 sans-serif; color: #fff; background: #000a; padding: 1px 3px; border-radius: 3px;
  z-index: 3; white-space: nowrap;
}
#board.awake .pc.n-gary::before { content: 'GARY'; }
#board.awake .pc.n-brenda::before { content: 'BRENDA'; }

/* eggs */
.eggshape {
  position: absolute; inset: 4% 17% 2%; border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 30% 28%, #fff, #f1e6cf 55%, #d9c7a4);
  box-shadow: 0 calc(var(--bs) * .008) calc(var(--bs) * .01) #0007;
}
.pc.red .eggshape::after, .pc.black .eggshape::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(circle at 30% 60%, var(--spk) 0 6%, transparent 7%), radial-gradient(circle at 65% 40%, var(--spk) 0 7%, transparent 8%), radial-gradient(circle at 55% 75%, var(--spk) 0 5%, transparent 6%), radial-gradient(circle at 40% 30%, var(--spk) 0 4%, transparent 5%);
}
.pc.red { --spk: #c43a2f; }
.pc.black { --spk: #2d2d32; }
.pc.wobbling .pc-in { animation: eggwob .5s ease-in-out infinite; }
@keyframes eggwob { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
.pigeonart { position: absolute; inset: -6%; }
.pigeonart svg { width: 100%; height: 100%; display: block; }
.k-pigeon .pc-in { animation: strut 1.2s ease-in-out infinite; }
@keyframes strut { 0%, 100% { transform: translateX(-3%) rotate(-3deg); } 50% { transform: translateX(3%) rotate(3deg); } }
.thing { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: calc(var(--bs) * .07); filter: drop-shadow(0 3px 3px #0008); }
.tileQ { display: inline-flex; align-items: flex-end; justify-content: center; width: 1.1em; height: 1.1em; background: #f0dcae; color: #222; border-radius: .12em; font: 800 .8em/1 Georgia, serif; padding-bottom: .1em; box-shadow: 0 .06em 0 #b39b6a; }
.tileQ sub { font-size: .35em; }

/* the Box: ghosts of captured pieces */
.pc.k-ghost .disc {
  background: radial-gradient(circle at 40% 35%, #fffffff0, #cbbaffa0 60%, #9d86ff60);
  box-shadow: 0 0 calc(var(--bs) * .025) #c9b8ffcc;
}
.pc.k-ghost.red .disc { background: radial-gradient(circle at 40% 35%, #fff0ee, #ff9d93a8 60%, #ff6a5c55); box-shadow: 0 0 calc(var(--bs) * .025) #ffb0a8cc; }
.pc.k-ghost .pc-in { animation: ghostbob 2.6s ease-in-out infinite; animation-delay: var(--bd); opacity: .85; }
@keyframes ghostbob { 0%, 100% { transform: translateY(-4%); } 50% { transform: translateY(5%); } }
.pc.freed { transition: transform 1.4s ease-in, opacity 1.4s; transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100% - 300%)); opacity: 0; }

/* the Arbiter's rules as pieces */
.rulelabel {
  position: absolute; left: -10%; right: -10%; top: 60%;
  font: 800 max(9px, calc(var(--bs) * .023))/1.05 Georgia, serif; color: #2a2015; text-align: center;
  background: #f8f1dee6; border: 1px solid #6d5a3a; border-radius: 3px; padding: 1px 1px;
  text-transform: uppercase; letter-spacing: -.02em; z-index: 3;
}
.pc.rulelose .rulelabel { font-size: max(12px, calc(var(--bs) * .034)); background: #fff3c4; }
.pc.rulelose .disc { background: radial-gradient(circle at 35% 30%, #fff3b0, #e2b33c 55%, #a37a14); box-shadow: 0 0 calc(var(--bs) * .03) #e2b33c, 0 calc(var(--bs) * .006) 0 #6d520c; }
.pc.rulelose.shielded .disc::after { content: ''; position: absolute; inset: -14%; border-radius: 50%; border: 2px dashed #ffe48a; animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pc.footnote .disc { background: radial-gradient(circle at 35% 30%, #ece7da, #bdb6a3 60%, #8f8875); }
.pc.ally .pc-in::after { content: ''; position: absolute; right: -2%; top: -2%; width: 24%; height: 24%; border-radius: 50%; background: var(--red); border: 2px solid #fff; }

/* physics chapter */
.pc.phys { transition: none; }
.pc.phys.escaped { transition: transform .8s ease-in, opacity .8s; transform: translate(calc(var(--c) * 100%), -500%); opacity: 0; }
.vest { position: absolute; left: 8%; right: 8%; top: 64%; background: #d8ff3a; color: #222; font: 900 calc(var(--bs) * .0135)/1.5 sans-serif; text-align: center; border-radius: 2px; letter-spacing: .02em; }
.aimsvg { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; overflow: visible; }
.aimsvg.on { opacity: 1; }
.aimline { stroke: #ffe48a; stroke-width: .09; stroke-dasharray: .2 .14; stroke-linecap: round; }
.aimdot { fill: #ffe48a80; }
.goalline { position: absolute; left: 0; right: 0; top: -2px; height: 4px; background: repeating-linear-gradient(90deg, #ffe48a 0 10px, transparent 10px 18px); animation: march 1s linear infinite; }
@keyframes march { to { background-position: 18px 0; } }

/* ---------------- bubbles, floaters, captions ---------------- */
.bubble {
  position: absolute; left: calc((var(--c) + .5) * 12.5%); top: calc(var(--r) * 12.5% + 2%);
  transform: translate(-50%, -100%); width: max-content; max-width: 48%;
  background: #fffdf5; color: #1d1712; border-radius: 10px; padding: 5px 8px;
  font: 700 calc(min(var(--bs) * .036, 14px))/1.2 sans-serif; text-align: center;
  box-shadow: 0 3px 8px #0007; z-index: 22; animation: bubin .2s cubic-bezier(.3, 1.6, .5, 1);
  transition: opacity .3s;
}
.bubble::after { content: ''; position: absolute; left: 50%; top: 100%; margin-left: -6px; border: 6px solid transparent; border-top-color: #fffdf5; border-bottom: 0; }
.bubble.left { transform: translate(-18%, -100%); }
.bubble.left::after { left: 18%; }
.bubble.right { transform: translate(-82%, -100%); }
.bubble.right::after { left: 82%; }
.bubble.below { top: calc((var(--r) + 1) * 12.5% - 2%); transform: translate(-50%, 0); }
.bubble.below::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom: 6px solid #fffdf5; }
.bubble.below.left { transform: translate(-18%, 0); }
.bubble.below.right { transform: translate(-82%, 0); }
.bubble.out { opacity: 0; }
@keyframes bubin { from { transform: translate(-50%, -100%) scale(.4); opacity: 0; } }
.floater {
  position: absolute; left: calc((var(--c) + .5) * 12.5%); top: calc((var(--r) + .2) * 12.5%);
  transform: translateX(-50%); white-space: nowrap; z-index: 24; pointer-events: none;
  font: 900 calc(var(--bs) * .042)/1 sans-serif; color: #fff;
  text-shadow: 0 2px 0 #000, 0 0 6px #000;
  animation: floatup 1.4s ease-out forwards;
}
.floater.scream { color: #ffd2c9; font-style: italic; }
.floater.gold { color: #ffd76a; }
.floater.small { font-size: calc(var(--bs) * .032); }
@keyframes floatup { 0% { transform: translate(-50%, 0) scale(.6); opacity: 0; } 15% { transform: translate(-50%, -20%) scale(1.1); opacity: 1; } 100% { transform: translate(-50%, -180%) scale(1); opacity: 0; } }
#caption {
  position: absolute; left: 3%; right: 3%; bottom: 3%;
  padding: 8px 10px; border-radius: 8px; background: #0d0a08e0; color: #f3eadf;
  font-size: 13.5px; line-height: 1.35; text-align: center;
  opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s;
  z-index: 45; pointer-events: none;
}
#caption.on { opacity: 1; transform: none; }
#app.arb-in #caption { right: 24%; left: 2%; }
#caption.cap-narrator { font-family: Georgia, "Times New Roman", serif; font-style: italic; background: #120f1ae8; border-left: 3px solid #e2b33c; text-align: left; }
#caption.cap-narrator::before { content: '\1F399\FE0F  '; font-style: normal; }
#caption.cap-arbiter { font-family: Georgia, serif; background: #fffdf6f0; color: #2a1a12; }

/* ---------------- bottom: status & dialogue ---------------- */
#bottom { flex: none; height: calc(142px + env(safe-area-inset-bottom)); position: relative; padding: 2px 8px env(safe-area-inset-bottom); }
#status { text-align: center; font-size: 14px; line-height: 1.4; padding: 10px 8px; color: #e8dccb; }
#status b { color: #fff; }
#status .goal { display: inline-block; padding: 6px 12px; border-radius: 999px; background: #ffffff10; border: 1px solid #ffffff1c; }
#status .hint { display: block; margin-top: 6px; font-size: 12.5px; opacity: .7; }
#dialogue {
  position: absolute; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom));
  min-height: calc(100% - 10px - env(safe-area-inset-bottom)); max-height: 64vh;
  display: flex; gap: 10px; padding: 10px 12px 12px 10px; border-radius: 14px;
  background: #f6eedc; color: #2a211b;
  box-shadow: 0 -6px 24px #0009, inset 0 0 0 2px #cdb995;
  z-index: 60; overflow: hidden;
}
#dialogue.hidden { display: none; }
#dialogue.choosing { max-height: 72vh; }
#dialogue .portrait { width: 62px; height: 62px; flex: none; border-radius: 10px; background: #e6d8bb; overflow: hidden; }
#dialogue .portrait svg { width: 100%; height: 100%; display: block; }
#dialogue .body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#dialogue .name { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #8a3b2a; }
#dialogue .text { font-size: 16.5px; line-height: 1.36; margin-top: 3px; overflow-y: auto; }
#dialogue .text em { font-style: italic; font-weight: 700; }
#dialogue .more { position: absolute; right: 12px; bottom: 8px; font-size: 12px; opacity: 0; color: inherit; }
#dialogue.done:not(.choosing) .more { opacity: .55; animation: bob 1s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
.choices { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; overflow-y: auto; }
.choices:empty { display: none; }
.choice {
  text-align: left; font-size: 15px; font-weight: 650; line-height: 1.25;
  padding: 10px 12px; border-radius: 10px; border: 0; background: #2d2520; color: #f6eedc;
}
.choice:active { transform: scale(.98); background: #4a3b32; }
.emoji-portrait { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 36px; }
/* speaker styles */
#dialogue.sp-colin { background: #0b1d10; color: var(--colin); box-shadow: 0 -6px 24px #0009, inset 0 0 0 2px #2f6b3a; }
#dialogue.sp-colin .text { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 15px; }
#dialogue.sp-colin .name { color: #b8ffbf; }
#dialogue.sp-colin .portrait { background: #13261a; }
#dialogue.sp-arbiter { background: #fffdf6; box-shadow: 0 -6px 24px #0009, inset 3px 0 0 #c43a2f, inset 0 0 0 2px #d8cdb5; }
#dialogue.sp-arbiter .text { font-family: Georgia, "Times New Roman", serif; }
#dialogue.sp-arbiter .name { color: #7a1d1d; }
#dialogue.sp-narrator { background: #16131e; color: #efe6d4; box-shadow: 0 -6px 24px #0009, inset 0 0 0 2px #e2b33c66; }
#dialogue.sp-narrator .text { font-family: Georgia, serif; font-style: italic; }
#dialogue.sp-narrator .name { color: #e2b33c; }
#dialogue.sp-narrator .portrait { background: #24202e; }
#dialogue.sp-gary .name { color: #b0281e; }
#dialogue.sp-brenda .name { color: #222; }
#dialogue.sp-pigeon .name, #dialogue.sp-duck .name { color: #4a5a6a; }
#dialogue.sp-ghost { background: #2a2140; color: #ece4ff; box-shadow: 0 -6px 24px #0009, inset 0 0 0 2px #8f7ad1; }
#dialogue.sp-ghost .name { color: #c8b8ff; }
#dialogue.sp-you .portrait { display: none; }
#dialogue.sp-manual { background: #fbf6e6; }
#dialogue.sp-manual .text { font-family: "Courier New", Courier, monospace; font-size: 15px; }

/* ---------------- the Arbiter ---------------- */
#arbiter {
  position: absolute; right: -6px; bottom: -4px; width: min(29vw, 160px); aspect-ratio: 1 / 2;
  transform: translateX(115%); transition: transform .55s cubic-bezier(.3, 1.3, .5, 1);
  z-index: 35; pointer-events: none; filter: drop-shadow(-4px 6px 10px #000a);
}
#arbiter.in { transform: translateX(0); }
#arbiter svg { width: 100%; height: 100%; display: block; }
.arbBubble {
  position: absolute; right: 70%; top: 6%; width: max-content; max-width: 52vw;
  background: #fffdf6; color: #2a1a12; font: 700 13px/1.25 Georgia, serif; padding: 6px 9px; border-radius: 10px;
  box-shadow: 0 3px 8px #0008; opacity: 0; transform: scale(.6); transition: .2s;
}
.arbBubble.on { opacity: 1; transform: none; }
.phweet {
  position: absolute; left: 50%; top: 40%; z-index: 50; pointer-events: none;
  font: 900 34px/1 Impact, "Arial Black", sans-serif; color: #fff; letter-spacing: .02em;
  text-shadow: 0 3px 0 #c43a2f, 0 0 20px #000;
  transform: translate(-50%, -50%) rotate(-8deg); animation: phweet 1.2s ease-out forwards;
}
@keyframes phweet { 0% { transform: translate(-50%, -50%) rotate(-8deg) scale(.3); opacity: 0; } 20% { transform: translate(-50%, -50%) rotate(-4deg) scale(1.15); opacity: 1; } 100% { transform: translate(-50%, -80%) rotate(-6deg) scale(1); opacity: 0; } }

/* ---------------- effects ---------------- */
.shake { animation: shake .45s; }
.bigshake { animation: shake .6s 2; }
@keyframes shake { 0%, 100% { transform: translate(0); } 20% { transform: translate(-6px, 2px); } 40% { transform: translate(5px, -3px); } 60% { transform: translate(-4px, 3px); } 80% { transform: translate(3px, -1px); } }
@keyframes tremble { 0%, 100% { transform: translate(0); } 50% { transform: translate(2%, -1%); } }
.gusting .pc-in { animation: tremble .18s infinite; }
.windline {
  position: absolute; width: 34%; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, #ffffffd0, transparent);
  animation: windmove 1s linear forwards; opacity: 0;
}
@keyframes windmove { 0% { transform: rotate(var(--a)) translateX(-160%); opacity: 0; } 20% { opacity: 1; } 100% { transform: rotate(var(--a)) translateX(260%); opacity: 0; } }
.flash { position: fixed; inset: 0; background: #fff; z-index: 300; pointer-events: none; animation: flash .7s forwards; }
@keyframes flash { from { opacity: .9; } to { opacity: 0; } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 250; overflow: hidden; }
.confetti i { position: absolute; top: -30px; width: 8px; height: 14px; background: hsl(var(--h) 80% 60%); animation: fall var(--d) linear forwards; }
.confetti i.char { background: none; width: auto; height: auto; font-size: 28px; font-style: normal; }
@keyframes fall { to { transform: translate(var(--x), 110vh) rotate(720deg); } }
.flyer { position: absolute; z-index: 26; transform: translate(-50%, -50%); transition: left var(--ms) linear, top var(--ms) linear; font-size: calc(var(--bs) * .1); pointer-events: none; }
.flyer.pawfly .paw { display: block; font-size: calc(var(--bs) * .24); transform: rotate(90deg); filter: drop-shadow(0 4px 6px #000a); }
.flyer.demon { font-size: calc(var(--bs) * .07); animation: tremble .15s infinite; }

/* power cut: only the eyes remain */
#app.powercut .sq, #app.powercut .disc, #app.powercut .eggshape, #app.powercut .crown, #app.powercut .acc { filter: brightness(.06); }
#app.powercut #board { background: #000; box-shadow: 0 0 0 5px #050505; }
#app.powercut .eye { box-shadow: 0 0 6px #fff, 0 0 12px #bfe; }
#app.powercut #stage { background: #000; }

/* ---------------- overlay & cards ---------------- */
#overlay { position: absolute; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: #0f0b09ee; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
#overlay.hidden { display: none; }
#overlay.show { animation: fadein .35s; }
@keyframes fadein { from { opacity: 0; } }
.card { width: min(90%, 420px); max-height: 100%; overflow-y: auto; text-align: center; padding: 22px 18px; }
.card .kicker { font-size: 12px; letter-spacing: .28em; text-transform: uppercase; opacity: .65; }
.card h1 { font: 700 32px/1.1 Georgia, "Times New Roman", serif; margin: 10px 0 8px; }
.card .sub { font-style: italic; opacity: .85; font-size: 15px; line-height: 1.4; }
.card .cbody { margin: 16px 0 6px; line-height: 1.5; font-size: 15px; text-align: left; }
.card .cbody p { margin: 0 0 10px; }
.cbtns { margin-top: 18px; }
.btn { display: block; width: 100%; margin: 10px 0 0; padding: 14px 12px; border-radius: 12px; border: 0; font-size: 17px; font-weight: 700; background: #3a302a; color: var(--text); }
.btn.primary { background: var(--red); color: #fff; box-shadow: 0 4px 0 #7c1d16; }
.btn:active { transform: translateY(2px); }
.btn.small { font-size: 14px; padding: 10px; }
.btn[disabled] { opacity: .35; }
.card.chapter h1 { font-size: 34px; }
.card.chapter .acr { margin-top: 18px; font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace; color: var(--colin); opacity: .85; }
.card.fail h1 { color: #ff9d8a; }

/* title screen */
.title-screen { text-align: center; width: min(92%, 440px); }
.title-screen .logo { font: 700 clamp(40px, 13vw, 64px)/1 Georgia, "Times New Roman", serif; letter-spacing: .04em; margin: 8px 0 6px; white-space: nowrap; }
.title-screen .logo span { display: inline-block; transition: transform .6s, opacity .6s; }
.title-screen .logo span.loose { animation: loose 3s ease-in-out infinite; }
.title-screen .logo span.fallen { transform: translateY(60px) rotate(40deg); opacity: .25; }
.title-screen .logo span.newF { color: var(--gold); }
@keyframes loose { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(9deg) translateY(3px); } }
.title-screen .tag { opacity: .7; font-size: 14px; margin-bottom: 26px; }
.title-screen .mini { display: flex; justify-content: center; gap: 10px; margin: 20px 0 6px; }
.title-screen .mini i { width: 34px; height: 34px; border-radius: 50%; display: block; box-shadow: 0 4px 0 #0007; }
.title-screen .mini i.r { background: radial-gradient(circle at 35% 30%, #ea6052, #c43a2f 60%); }
.title-screen .mini i.b { background: radial-gradient(circle at 35% 30%, #55555c, #2d2d32 60%); }
.title-screen .foot { margin-top: 22px; font-size: 12px; opacity: .45; }
.chapgrid { display: grid; grid-template-columns: 1fr; gap: 8px; text-align: left; margin-top: 12px; }
.chapgrid button { text-align: left; padding: 11px 12px; border-radius: 10px; border: 0; background: #3a302a; color: var(--text); font-size: 15px; font-weight: 600; }
.chapgrid button small { display: block; opacity: .6; font-weight: 400; font-size: 12.5px; margin-top: 2px; }
.chapgrid button[disabled] { opacity: .3; }
.rulesbody { text-align: left; font-size: 14.5px; line-height: 1.5; }
.rulesbody li { margin-bottom: 6px; }
.rulesbody .amend { color: #ff9d8a; font-family: "Comic Sans MS", "Chalkboard SE", "Marker Felt", cursive; }
.toggles { text-align: left; }
.toggles label { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid #ffffff12; font-size: 15px; }
.toggles label small { display: block; opacity: .6; font-size: 12px; }
.toggles input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--red); flex: none; }
.toggles select { margin-left: auto; font-size: 15px; padding: 6px; border-radius: 8px; background: #3a302a; color: var(--text); border: 0; }

/* fake advert */
#overlay.adov { background: #000c; }
.ad {
  position: relative; width: min(86%, 360px); min-height: 300px; border-radius: 16px; overflow: visible;
  background: linear-gradient(160deg, #ff3fa4, #ffb800 60%, #00d2ff); color: #fff; text-align: center;
  padding: 30px 18px 22px; box-shadow: 0 10px 40px #000;
}
.ad h2 { font: 900 26px/1.05 Impact, "Arial Black", sans-serif; margin: 6px 0 12px; text-shadow: 0 3px 0 #0005; }
.ad p { font-size: 16px; font-weight: 700; text-shadow: 0 2px 0 #0004; }
.ad .stars { font-size: 13px; font-weight: 600; opacity: .9; }
.adtag { position: absolute; top: 8px; left: 10px; font-size: 10px; font-weight: 800; background: #0006; padding: 2px 6px; border-radius: 4px; letter-spacing: .1em; text-transform: uppercase; }
.adx { position: absolute; top: 8px; left: 88%; width: 38px; height: 38px; border-radius: 50%; border: 0; background: #000a; color: #fff; font-size: 18px; transform: translate(-50%, 0); transition: left .18s, top .18s; z-index: 3; }
.adhint { position: absolute; left: 0; right: 0; bottom: -34px; font-size: 13px; color: #fff; opacity: .7; }

/* zoom-out cutscene */
#overlay.zoomov { background: #000; }
.zoom { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.zsvg { width: min(100vw, 100vh, 680px); height: min(100vw, 100vh, 680px); }
.zcap, .zline {
  position: absolute; left: 50%; transform: translate(-50%, 8px); width: min(90%, 460px); text-align: center;
  opacity: 0; transition: opacity .4s, transform .4s; pointer-events: none;
}
.zcap { top: calc(18px + env(safe-area-inset-top)); font: italic 18px/1.4 Georgia, serif; color: #fff; text-shadow: 0 2px 8px #000, 0 0 2px #000; background: #0008; padding: 10px 14px; border-radius: 10px; }
.zline { bottom: calc(44px + env(safe-area-inset-bottom)); font-size: 16px; background: #f6eedcf2; color: #2a211b; padding: 10px 14px; border-radius: 12px; }
.zline b { color: #b0281e; }
.zcap.on, .zline.on { opacity: 1; transform: translate(-50%, 0); }
.zhint { position: absolute; bottom: calc(12px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; font-size: 11px; opacity: .4; color: #fff; }

.skipbtn { position: absolute; z-index: 5; right: 12px; top: calc(12px + env(safe-area-inset-top)); padding: 8px 14px; border-radius: 999px; border: 0; background: #ffffff22; color: #fff; font-weight: 800; font-size: 13px; box-shadow: inset 0 0 0 1px #ffffff44; }
#stage .introskip { top: 8px; z-index: 70; background: #000a; }
#overlay.zoomov .skipbtn { top: auto; bottom: calc(10px + env(safe-area-inset-bottom)); }

/* credits */
#overlay.creditsov { background: #0b0807; overflow: hidden; align-items: flex-start; }
.credits { width: 100%; height: 100%; overflow: hidden; position: relative; }
.roll { position: absolute; left: 0; right: 0; top: 100%; text-align: center; padding: 0 20px; }
.roll.go { animation: roll 30s linear forwards; }
@keyframes roll { from { transform: translateY(0); } to { transform: translateY(calc(-100% - 100vh)); } }
.dafts-title { font: 700 64px/1 Georgia, serif; letter-spacing: .06em; color: var(--gold); margin: 0; }
.roll .cs { font-style: italic; opacity: .8; }
.roll .ck { font-size: 12px; letter-spacing: .3em; text-transform: uppercase; opacity: .55; margin-top: 18px; }
.roll .cr { margin: 6px 0; }
.roll .cr span { display: block; font-size: 13px; opacity: .6; }
.roll .cg { height: 36px; }

/* mystery */
.suspects { display: flex; gap: 6px; justify-content: center; margin-top: 4px; }
.suspects button { width: 54px; height: 54px; border-radius: 10px; border: 2px solid #ffffff22; background: #2d2520; padding: 2px; position: relative; }
.suspects button svg, .suspects button .emoji-portrait { width: 100%; height: 100%; display: block; border-radius: 7px; }
.suspects button.done::after { content: '\2713'; position: absolute; right: -4px; top: -6px; background: #2f6b3a; color: #fff; width: 18px; height: 18px; border-radius: 50%; font-size: 12px; line-height: 18px; }
.clues { font-size: 12.5px; opacity: .8; margin-top: 6px; }
.accuse { margin-top: 8px; padding: 9px 16px; font-size: 15px; font-weight: 800; border-radius: 999px; border: 0; background: var(--red); color: #fff; box-shadow: 0 3px 0 #7c1d16; }
.boxbtns { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.boxbtns button { padding: 8px 14px; border-radius: 999px; border: 0; background: #3a302a; color: var(--text); font-weight: 700; font-size: 14px; }

/* ---------------- themes ---------------- */
.theme-savannah { --light-sq: #e9c97c; --dark-sq: #8f6d2c; --frame: #5b3f12; }
.theme-savannah #app, #app.theme-savannah { background: linear-gradient(180deg, #f39a4c 0%, #c0573a 30%, #3a2218 70%); }
#app.theme-savannah #stage::before { content: '\1F333'; position: absolute; left: 2%; top: -6%; font-size: 64px; opacity: .55; filter: brightness(.25) saturate(0); }
#app.theme-savannah #stage::after { content: '\1F333'; position: absolute; right: 4%; top: -2%; font-size: 44px; opacity: .45; filter: brightness(.25) saturate(0); }
#app.theme-noir { filter: sepia(.55) grayscale(.35) contrast(1.08); }
#app.theme-noir #stage::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 40;
  background: repeating-linear-gradient(104deg, transparent 0 18px, #ffffff12 18px 19px);
  background-size: 200% 200%; animation: rain .4s linear infinite;
}
@keyframes rain { from { background-position: 0 0; } to { background-position: -40px 120px; } }
#app.theme-box { background: radial-gradient(ellipse at 50% 50%, #3b1d3f, #12070f 75%); --light-sq: #3a1838; --dark-sq: #5e2a58; --frame: #1e0a1c; }
#app.theme-box #board { box-shadow: 0 0 0 5px #1e0a1c, 0 0 40px #b07aff44, 0 12px 30px #000c; background: transparent; }
#app.theme-box .sq.dark { background: radial-gradient(circle at 50% 40%, #74356c, #4a1f45); }
#app.theme-box .sq.light { background: #2a1028; }
#app.theme-box .sq.node { box-shadow: inset 0 0 0 2px #e2b33c33; }
#app.theme-flick #board { box-shadow: 0 0 0 5px var(--frame), 0 0 0 7px #24150c, 0 12px 30px #000a, 0 -30px 50px -20px #ffe48a66; }
#app.theme-final { background: radial-gradient(ellipse at 50% 35%, #4a1c1c, #160808 75%); --light-sq: #e3dccb; --dark-sq: #6f6a5f; --frame: #2b2620; }
#app.theme-final .sq.light.opened { background: #fff6d6; box-shadow: inset 0 0 14px #ffe48a; }
#app.theme-epilogue { background: radial-gradient(ellipse at 50% 35%, #5a4520, #1a1208 75%); }

/* utility */
.hidden { display: none !important; }
@media (max-height: 640px) {
  #opponent { height: 52px; }
  .avatar { width: 46px; height: 46px; }
  #bottom { height: calc(128px + env(safe-area-inset-bottom)); }
  #dialogue .text { font-size: 15px; }
  #dialogue .portrait { width: 50px; height: 50px; }
}
@media (prefers-reduced-motion: reduce) {
  .placard, .k-pigeon .pc-in, .pc.k-ghost .pc-in, .eye { animation: none !important; }
}
