/* Slothfall - colour retro theme (MIT). Font: Press Start 2P (SIL OFL 1.1, OFL-PressStart2P.txt). */
@font-face { font-family: "PressStart"; src: url("PressStart2P-Regular.ttf") format("truetype"); }
:root {
  --cell: 28px; --bg: #0a0b1e; --panel: #12153a; --edge: #3d4bd8; --edge2: #8a7dff; --text: #e8ebff; --dim: #8f96c8;
  --I: #19e3ff; --J: #2f63ff; --L: #ff9a1f; --O: #ffd60a; --S: #2fdc5a; --T: #b14dff; --Z: #ff3b4f; --G: #6c708e;
  /* piece palette: our own colours, deliberately not the standard piece-to-colour mapping */
  --pI: #ff4fd8; --pJ: #ffb02e; --pL: #3cf0c8; --pO: #8f6bff; --pS: #ff5a5a; --pT: #4fb4ff; --pZ: #c8f03c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 20%, #1c1f55 0%, var(--bg) 65%);
  font-family: "PressStart", "Courier New", monospace; color: var(--text);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
/* soft CRT: scanlines + vignette over everything, never blocking input */
body::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,.16) 0 1px, transparent 1px 3px),
              radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,.45) 100%); }
#stage { display: flex; align-items: flex-start; gap: 22px; transform-origin: center center; padding: 10px; }
#game { display: flex; flex-direction: column; align-items: center; gap: 12px; }
#title { display: flex; align-items: center; gap: 14px; }
#logo { font-size: 30px; letter-spacing: 2px; }
#logo span { text-shadow: 3px 3px 0 #000, 0 0 12px currentColor; }
#logo span:nth-child(7n+1) { color: var(--pZ); } #logo span:nth-child(7n+2) { color: var(--pL); } #logo span:nth-child(7n+3) { color: var(--pO); }
#logo span:nth-child(7n+4) { color: var(--pS); } #logo span:nth-child(7n+5) { color: var(--pI); } #logo span:nth-child(7n+6) { color: var(--pJ); } #logo span:nth-child(7n+7) { color: var(--pT); }
#mascot { width: 64px; height: 64px; image-rendering: pixelated; border: 3px solid var(--edge); border-radius: 6px; background: #000; }
#tag { font-size: 8px; color: var(--dim); margin-top: 10px; }
#play { display: flex; gap: 16px; align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 12px; width: 150px; }
.box { background: var(--panel); border: 3px solid var(--edge); box-shadow: 0 0 0 3px #05061a, inset 0 0 0 2px #1e2366, 0 6px 0 #05061a; padding: 9px 10px; }
.box h3 { margin: 0 0 8px; font-size: 9px; font-weight: normal; color: var(--edge2); letter-spacing: 1px; }
.box .big { font-size: 18px; } .box .mid { font-size: 12px; }
/* the well */
#well { position: relative; border: 4px solid var(--edge); box-shadow: 0 0 0 4px #05061a, 0 0 24px rgba(61,75,216,.6), inset 0 0 0 2px #1e2366; background: #070818; }
#board { display: grid; grid-template-columns: repeat(10, var(--cell)); grid-template-rows: repeat(20, var(--cell)); }
.cell { width: var(--cell); height: var(--cell); border: 1px solid rgba(70,80,170,.13); }
.cell[data-t] { border: none; background: var(--c);
  box-shadow: inset 3px 3px 0 rgba(255,255,255,.55), inset -3px -3px 0 rgba(0,0,0,.38), inset 0 0 0 1px rgba(0,0,0,.35); }
.cell[data-t="I"] { --c: var(--pI); } .cell[data-t="J"] { --c: var(--pJ); } .cell[data-t="L"] { --c: var(--pL); } .cell[data-t="O"] { --c: var(--pO); }
.cell[data-t="S"] { --c: var(--pS); } .cell[data-t="T"] { --c: var(--pT); } .cell[data-t="Z"] { --c: var(--pZ); } .cell[data-t="G"] { --c: var(--G); }
.cell.a { filter: brightness(1.12); }
.cell[data-g] { box-shadow: inset 0 0 0 2px rgba(255,255,255,.28); background: rgba(255,255,255,.04); }
.cell.trail { animation: trail .18s linear; }
.cell[data-trail="I"] { --tc: var(--pI); } .cell[data-trail="J"] { --tc: var(--pJ); } .cell[data-trail="L"] { --tc: var(--pL); } .cell[data-trail="O"] { --tc: var(--pO); }
.cell[data-trail="S"] { --tc: var(--pS); } .cell[data-trail="T"] { --tc: var(--pT); } .cell[data-trail="Z"] { --tc: var(--pZ); }
@keyframes trail { from { background: color-mix(in srgb, var(--tc, #fff) 45%, transparent); } to { background: transparent; } }
#well.thud { animation: thud .12s steps(2); } #well.shake { animation: shake .2s steps(4); } #well.shake4 { animation: shake4 .45s steps(9); }
@keyframes thud { 50% { transform: translateY(3px); } }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes shake4 { 20%, 60% { transform: translate(-6px, 2px); } 40%, 80% { transform: translate(6px, -2px); } }
#flash { position: absolute; inset: 0; pointer-events: none; }
#flash .bar { position: absolute; left: 0; right: 0; height: var(--cell); background: #fff; animation: bar .32s steps(4) forwards; }
@keyframes bar { 0%, 50% { opacity: 1; } 25%, 75% { opacity: .2; } 100% { opacity: 0; transform: scaleX(1.2); } }
#pop { position: absolute; left: 0; right: 0; top: 40%; text-align: center; font-size: 15px; opacity: 0; pointer-events: none; color: var(--O); text-shadow: 3px 3px 0 #000; }
#pop[data-n="4"] { color: var(--I); font-size: 17px; }
#pop.show { animation: pop .9s steps(9); }
@keyframes pop { 0% { opacity: 1; transform: scale(.6); } 25% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-30px); } }
#status { position: absolute; left: 0; right: 0; top: 45%; text-align: center; font-size: 16px; color: #fff; text-shadow: 3px 3px 0 #000; pointer-events: none; }
#status[data-phase="title"], #status[data-phase="over"], #status[data-phase="clear"] { background: rgba(5,6,26,.82); padding: 18px 0; animation: blink 1s steps(2) infinite; }
#status[data-phase="clear"] { color: var(--O); }
@keyframes blink { 50% { opacity: .55; } }
/* pressure: piece window against human reaction */
#center { display: flex; flex-direction: column; gap: 10px; }
#pressure { font-size: 8px; color: var(--dim); }
#pw-track { position: relative; height: 16px; background: #05061a; border: 2px solid #2a3190; }
#pw-window { position: absolute; left: 0; top: 0; bottom: 0; background: #20264f; }
#pw-left { height: 100%; background: linear-gradient(90deg, var(--S), var(--O)); }
body.below-human #pw-left { background: linear-gradient(90deg, var(--Z), var(--O)); }
#pw-human { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: 3px dashed #fff; }
#pw-human span { position: absolute; left: 6px; top: 22px; white-space: nowrap; color: #fff; font-size: 7px; }
#pw-text { margin-top: 14px; color: var(--text); }
body.below-human #pw-text { color: var(--Z); }
body.below-human #pw-text::after { content: "  < human reaction"; }
#banner { position: absolute; left: 0; right: 0; top: 18%; text-align: center; font-size: 13px; color: var(--I); text-shadow: 3px 3px 0 #000; opacity: 0; pointer-events: none; }
#banner.warn { color: var(--Z); }
#banner.show { animation: pop 1.1s steps(11); }
#well.garbage { animation: garbage .5s steps(5); }
@keyframes garbage { 0%, 40%, 80% { box-shadow: 0 0 0 4px #05061a, 0 0 30px 6px rgba(255,59,79,.9), inset 0 -40px 30px -20px rgba(255,59,79,.7); } 20%, 60%, 100% { box-shadow: 0 0 0 4px #05061a, 0 0 24px rgba(61,75,216,.6); } }
/* side boxes */
#timerbox { height: 10px; background: #05061a; border: 2px solid #2a3190; margin-top: 8px; }
#timerbar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--Z), var(--O), var(--S)); }
#next { display: flex; flex-direction: column; gap: 10px; align-items: center; min-height: 60px; }
.slot { width: 100%; height: 34px; display: flex; align-items: center; justify-content: center; }
.mini { display: grid; grid-template-columns: repeat(4, 14px); grid-template-rows: repeat(2, 14px); }
.mini i[data-t] { box-shadow: inset 2px 2px 0 rgba(255,255,255,.5), inset -2px -2px 0 rgba(0,0,0,.35); }
.mini i[data-t="I"] { background: var(--pI); } .mini i[data-t="J"] { background: var(--pJ); } .mini i[data-t="L"] { background: var(--pL); } .mini i[data-t="O"] { background: var(--pO); }
.mini i[data-t="S"] { background: var(--pS); } .mini i[data-t="T"] { background: var(--pT); } .mini i[data-t="Z"] { background: var(--pZ); }
.mini.unknown { display: block; width: 56px; height: 28px; line-height: 28px; text-align: center; font-size: 16px; color: #3a4290; border: 2px dashed #2a3190; }
#next-box.blind h3::after { content: " ???"; color: var(--Z); }
#speedtag { display: none; font-size: 8px; line-height: 1.6; text-align: center; color: #fff; background: linear-gradient(90deg, #ff3b4f, #b14dff); padding: 8px 6px; border: 3px solid #05061a; animation: blink 1s steps(2) infinite; }
body.superhuman #speedtag { display: block; }
.keys { font-size: 7px; color: var(--dim); line-height: 1.9; }
#pills { display: flex; gap: 14px; }
#pills button { font-family: inherit; font-size: 9px; color: var(--text); background: var(--panel); border: 3px solid var(--edge); box-shadow: 0 4px 0 #05061a; padding: 8px 12px; cursor: pointer; }
#pills button:active { transform: translateY(3px); box-shadow: 0 1px 0 #05061a; }
/* spectator panel */
#ai-panel { width: 300px; background: #0d0f2c; border: 3px solid var(--edge2); box-shadow: 0 0 0 3px #05061a, 0 0 22px rgba(138,125,255,.35); padding: 16px; font-size: 9px; line-height: 1.8; }
#ai-panel h2 { font-size: 12px; margin: 0 0 12px; font-weight: normal; color: var(--O); text-shadow: 2px 2px 0 #000; }
#ai-panel .row { display: flex; justify-content: space-between; border-bottom: 1px dashed #262b6b; padding: 5px 0; color: var(--dim); }
#ai-panel .val { color: var(--text); }
#ai-panel .human { font-size: 22px; color: var(--Z); }
#ai-top { list-style: none; padding: 0; margin: 10px 0 0; }
#ai-top li { display: grid; grid-template-columns: 74px 40px 1fr; gap: 6px; align-items: center; padding: 3px 0; font-size: 7px; color: var(--dim); }
#ai-top li.chosen { color: var(--S); }
#ai-top .bar { height: 9px; background: #1a1e4d; } #ai-top .bar b { display: block; height: 100%; background: var(--I); }
#ai-top li.chosen .bar b { background: var(--S); }
.note { color: #6870a8; font-size: 7px; margin-top: 12px; line-height: 1.7; }
/* hell mode and the rising-garbage warning */
#hell-rule { font-size: 7px; color: var(--dim); margin-top: 6px; line-height: 1.6; }
body.hell #hell-rule { color: var(--Z); font-size: 8px; }
body.garbage-soon #garbage-box { border-color: var(--Z); animation: blink .3s steps(2) infinite; }
body.garbage-soon #garbage { color: var(--Z); }
body.garbage-soon #well::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--cell) * 1);
  background: repeating-linear-gradient(90deg, rgba(255,59,79,.55) 0 14px, rgba(255,59,79,.15) 14px 28px); pointer-events: none; animation: blink .3s steps(2) infinite; }
/* human play layer (play.js): mode menu, result screen */
#menu, #result { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(5,6,26,.78); }
#menu[hidden], #result[hidden] { display: none; }
#menu { background: radial-gradient(ellipse at 50% 20%, #1c1f55 0%, var(--bg) 70%); }
#menu .card, #result .card { width: min(560px, 94vw); background: var(--panel); border: 4px solid var(--edge); box-shadow: 0 0 0 4px #05061a, 0 0 30px rgba(61,75,216,.6);
  padding: 22px 26px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.mlogo { font-size: 26px; color: var(--O); text-shadow: 3px 3px 0 #000, 0 0 12px currentColor; }
.msub { font-size: 8px; color: var(--dim); line-height: 1.8; }
.msub a, .cmp a { color: var(--I); }
.mnote { font-size: 8px; color: var(--dim); line-height: 1.9; }
.mwarn, #kbwarn { font-size: 9px; color: #fff; background: var(--Z); padding: 10px; line-height: 1.8; border: 3px solid #05061a; }
#kbwarn { position: fixed; left: 0; right: 0; top: 0; z-index: 45; text-align: center; }
.pick { font-family: inherit; font-size: 13px; color: var(--text); background: #1e2366; border: 3px solid var(--edge2); box-shadow: 0 5px 0 #05061a; padding: 12px 22px; cursor: pointer; min-width: 280px; }
.pick.hell { background: linear-gradient(90deg, #ff3b4f, #b14dff); color: #fff; }
.pick:hover { filter: brightness(1.15); } .pick:active { transform: translateY(3px); box-shadow: 0 2px 0 #05061a; }
.keytab { font-size: 8px; color: var(--text); border-collapse: collapse; margin-top: 4px; }
.keytab td { padding: 4px 10px; border-bottom: 1px dashed #262b6b; text-align: left; } .keytab td:first-child { color: var(--O); text-align: right; }
.rhead { font-size: 22px; color: var(--Z); text-shadow: 3px 3px 0 #000; } .rhead.clear { color: var(--O); }
.you, .cmp { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; width: 100%; }
.you div, .cmp div { flex: 1; background: #05061a; border: 2px solid #2a3190; padding: 10px 8px; display: flex; flex-direction: column; gap: 8px; }
.you span, .cmp span { font-size: 7px; color: var(--dim); line-height: 1.7; } .you b { font-size: 18px; color: var(--S); font-weight: normal; }
.cmp b { font-size: 9px; color: var(--text); font-weight: normal; line-height: 1.7; }
