:root{
  --ink:#0B0B10;
  --char:#1A1D24;
  --brass:#C9A227;
  --gold:#F2C230;
  --cream:#E8E1D2;
  --oxblood:#7A1F1F;
  --teal:#2E6E6B;
  --red:#D64545;
  --hud-h:clamp(38px,5.6vw,56px);
  --rail-btn:clamp(34px,4.2vw,48px);
  --marquee-w:clamp(280px,78vw,430px);
}

*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{
  background:#050507;
  color:var(--cream);
  font-family:'Oswald',system-ui,sans-serif;
  overflow:hidden;
  -webkit-tap-highlight-color:transparent;
}
button{font:inherit;color:inherit;cursor:pointer}
img{display:block}
[hidden]{display:none !important}

.scene{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  isolation:isolate;
  padding:max(3px,env(safe-area-inset-top)) max(3px,env(safe-area-inset-right)) max(3px,env(safe-area-inset-bottom)) max(3px,env(safe-area-inset-left));
}
.backdrop{
  position:absolute;
  inset:-2%;
  width:104%;
  height:104%;
  object-fit:cover;
  filter:sepia(.2) saturate(.92) brightness(.64) contrast(1.06);
  z-index:-4;
}
.alley{
  position:absolute;
  left:50%;
  bottom:-1%;
  transform:translateX(-50%);
  width:min(1120px,104vw);
  opacity:.8;
  filter:sepia(.18) brightness(.5) saturate(.9);
  z-index:-3;
  pointer-events:none;
}
.halftone{
  position:absolute;
  inset:0;
  z-index:-2;
  pointer-events:none;
  opacity:.14;
  mix-blend-mode:overlay;
  background-image:radial-gradient(circle at 1px 1px,rgba(232,225,210,.55) .9px,transparent 1.1px);
  background-size:4px 4px;
}
.scene::after{
  content:"";
  position:absolute;
  inset:0;
  z-index:-1;
  pointer-events:none;
  background:
    radial-gradient(ellipse at 20% 7%,rgba(242,194,48,.2),transparent 42%),
    radial-gradient(ellipse at 50% 52%,transparent 38%,rgba(0,0,0,.66) 100%),
    linear-gradient(180deg,rgba(0,0,0,.12),rgba(0,0,0,.34));
}

/* the transparent machine layer: the canvas is the full render surface, the wall shows through */

.cabinet{
  position:relative;
  width:min(96vw,1000px);
  height:min(98dvh,980px);
  display:flex;
  flex-direction:column;
  gap:4px;
  z-index:1;
}
.cabinet > *:not(#game){
  position:relative;
  z-index:1;
}
#game{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  z-index:0;
  background:transparent;
  pointer-events:none;
}

/* marquee */

.marquee{
  flex:0 0 auto;
  align-self:center;
  background:#0B0B10;
  border-top:1px solid var(--brass);
  border-bottom:1px solid var(--brass);
  box-shadow:4px 5px 0 rgba(0,0,0,.5);
  padding:1px 10px 0;
  line-height:0;
}
.marquee img{
  width:var(--marquee-w);
  height:auto;
  filter:drop-shadow(2px 3px 0 rgba(0,0,0,.6));
}

/* HUD */

.hudrow{
  flex:0 0 auto;
  width:100%;
  max-width:620px;
  margin:0 auto;
  display:flex;
  align-items:flex-end;
  justify-content:center;
  gap:clamp(4px,1vw,8px);
  padding:0 4px;
  min-height:calc(var(--hud-h)*1.25);
}
.hudbar{
  flex:1 1 auto;
  height:var(--hud-h);
  display:flex;
  align-items:center;
  justify-content:space-around;
  gap:clamp(2px,.6vw,6px);
  padding:0 4px;
  background-color:#0B0B10;
  background-image:repeating-linear-gradient(90deg,rgba(255,255,255,.018) 0 1px,transparent 1px 7px);
  border:1px solid #4b3b14;
  box-shadow:inset 0 0 0 1px #000,0 4px 0 rgba(0,0,0,.45);
}
.mugcard{
  position:relative;
  height:calc(var(--hud-h)*1.25);
  aspect-ratio:1.42;
  flex:0 0 auto;
  background:#E8E1D2;
  border:2px solid var(--brass);
  box-shadow:inset 0 0 0 1px #3d3010,3px 4px 0 rgba(0,0,0,.5);
  overflow:hidden;
  background-image:
    repeating-linear-gradient(180deg,rgba(20,20,25,.22) 0 1px,transparent 1px 9px),
    radial-gradient(circle at 1px 1px,rgba(20,20,25,.15) .7px,transparent 1px);
  background-size:auto,4px 4px;
}
.chart{
  position:absolute;
  left:5%;
  top:7%;
  bottom:20%;
  width:13%;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  font-family:'Special Elite',monospace;
  font-size:calc(var(--hud-h)*.13);
  color:#191a1e;
  opacity:.62;
  border-left:1px solid rgba(11,11,16,.45);
  padding-left:2px;
  line-height:1;
}
.mugface{
  position:absolute;
  left:12%;
  bottom:6%;
  width:78%;
  height:92%;
  object-fit:contain;
  object-position:center bottom;
  z-index:2;
  filter:drop-shadow(1px 1px 0 rgba(0,0,0,.25));
}
.mugtag{
  position:absolute;
  right:4%;
  top:5%;
  z-index:3;
  background:var(--oxblood);
  color:var(--cream);
  font-size:calc(var(--hud-h)*.13);
  letter-spacing:.1em;
  padding:0 3px 0 4px;
  line-height:1.4;
  transform:rotate(2deg);
}
.life img{width:100%;height:100%;object-fit:contain}
.life.dead img{opacity:.25;filter:grayscale(1)}
.life.dead::after{
  content:"";
  position:absolute;
  left:-8%;
  right:-8%;
  top:47%;
  height:2px;
  background:#e0413c;
  transform:rotate(-34deg);
}
.lifepanel{
  height:calc(var(--hud-h) - 4px);
  display:flex;
  align-items:center;
  padding:0 clamp(3px,.5vw,6px);
  background:#0c0c11;
  border:1px solid #4b3b14;
  box-shadow:inset 0 0 0 1px #000,inset 0 0 0 2px rgba(201,162,39,.14);
  flex:0 0 auto;
}
.lives{
  display:flex;
  align-items:center;
  gap:1px;
}
.life{
  position:relative;
  height:calc(var(--hud-h)*.62);
  width:calc(var(--hud-h)*.5);
  flex:0 0 auto;
}
.plaque{
  position:relative;
  height:calc(var(--hud-h) - 4px);
  aspect-ratio:399/171;
  flex:0 0 auto;
}
.plaque img{width:100%;height:100%;object-fit:fill}
.plaqueText{
  position:absolute;
  left:15.5%;
  right:15.5%;
  top:25%;
  bottom:25%;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:0;
  color:#191a1e;
  font-family:'Special Elite',monospace;
  line-height:.92;
  white-space:nowrap;
  pointer-events:none;
}
.plaqueText i{
  font-style:normal;
  font-size:calc(var(--hud-h)*.15);
  letter-spacing:.08em;
  opacity:.82;
}
.plaqueText b{
  font-weight:400;
  font-size:calc(var(--hud-h)*.29);
  letter-spacing:.03em;
}
.levelbadge{
  position:relative;
  height:calc(var(--hud-h) - 4px);
  aspect-ratio:251/307;
  flex:0 0 auto;
}
.levelbadge img{width:100%;height:100%;object-fit:contain}
.levelbadge span{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding-top:4%;
  color:#1a1a1d;
  font-family:'Special Elite',monospace;
  font-size:calc(var(--hud-h)*.34);
  line-height:1;
  pointer-events:none;
}

/* the four crews line up along the top of the board */

.lineup{
  flex:0 0 auto;
  height:clamp(64px,11vh,88px);
  display:flex;
  align-items:flex-end;
  justify-content:center;
  gap:clamp(8px,2.4vw,32px);
  margin-bottom:-8px;
  pointer-events:none;
}
.gang{
  height:100%;
  min-width:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-end;
  gap:1px;
}
.gang img{
  height:100%;
  width:auto;
  max-width:110px;
  object-fit:contain;
  filter:drop-shadow(3px 5px 0 rgba(0,0,0,.55));
}
.gang span{
  font-family:'Oswald',sans-serif;
  font-weight:600;
  font-size:clamp(6px,.85vw,10px);
  letter-spacing:.12em;
  line-height:1;
  color:rgba(232,225,210,.92);
  text-shadow:0 1px 0 #000,0 0 2px rgba(0,0,0,.6);
  white-space:nowrap;
}
.gang small{
  display:block;
  margin-top:1px;
  font-weight:200;
  font-size:.82em;
  letter-spacing:.18em;
  opacity:.65;
  text-align:center;
}

/* board */

.boardwrap{
  flex:1 1 auto;
  min-height:0;
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  background:transparent;
  overflow:hidden;
  touch-action:none;
}
.stage{
  position:absolute;
  left:0;
  top:0;
  z-index:2;
  font-size:4px;
  line-height:1;
  touch-action:none;
  overflow:hidden;
  user-select:none;
  -webkit-user-select:none;
}

.turf{
  position:absolute;
  transform:translate(-50%,-50%) rotate(-1.6deg);
  text-align:center;
  color:rgba(232,225,210,.46);
  pointer-events:none;
  z-index:2;
  text-shadow:0 .12em 0 rgba(0,0,0,.55);
}
.turf span{
  display:block;
  font-family:'Oswald',sans-serif;
  font-weight:600;
  font-size:2.15em;
  letter-spacing:.22em;
  line-height:.95;
  padding-left:.22em;
}
.turf small{
  display:block;
  margin-top:.35em;
  font-family:'Oswald',sans-serif;
  font-weight:200;
  font-size:.78em;
  letter-spacing:.24em;
  opacity:.8;
}
.turf::after{
  content:"";
  display:block;
  width:2.2em;
  height:1px;
  margin:.5em auto 0;
  background:currentColor;
  opacity:.6;
}
.turf-west{left:8.5%;top:33.3%;color:rgba(78,158,153,.62)}
.turf-north{left:42.7%;top:14.8%;color:rgba(214,69,69,.6)}
.turf-east{left:91.5%;top:44.4%;color:rgba(214,120,150,.58)}
.turf-south{left:58.5%;top:85.2%;color:rgba(201,138,39,.62)}

/* hint and controls */

.hint{
  flex:0 0 auto;
  align-self:center;
  font-family:'Special Elite',monospace;
  font-size:clamp(7px,1.05vw,11px);
  letter-spacing:.06em;
  color:#17181c;
  background:var(--cream);
  padding:2px 9px 1px;
  border:1px solid #8a6f1e;
  transform:rotate(-1deg);
  box-shadow:2px 2px 0 rgba(0,0,0,.6);
  white-space:nowrap;
  max-width:100%;
  z-index:3;
}
.hint span{opacity:.66;margin-left:.7em}

.rail{
  flex:0 0 auto;
  align-self:center;
  padding:5px 12px 4px;
  border:2px solid #3d3010;
  background-color:#8a6f1e;
  background-image:repeating-linear-gradient(90deg,rgba(0,0,0,.16) 0 1px,transparent 1px 4px);
  box-shadow:inset 0 1px 0 #c9a227,inset 0 -2px 0 rgba(0,0,0,.45),0 5px 0 rgba(0,0,0,.45);
  z-index:1;
}
.railbar{
  display:flex;
  align-items:flex-end;
  justify-content:center;
  gap:clamp(8px,1.7vw,20px);
}
.ctrl{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:2px;
}
.ctrl > span{
  font-family:'Oswald',sans-serif;
  font-weight:600;
  font-size:clamp(6px,1vw,10px);
  letter-spacing:.13em;
  line-height:1;
  color:var(--cream);
  text-shadow:0 1px 0 rgba(0,0,0,.8);
  white-space:nowrap;
}
.rbtn{
  width:var(--rail-btn);
  height:var(--rail-btn);
  padding:0;
  border:0;
  background:none;
  transition:transform .07s linear,filter .07s linear;
}
.rbtn img{width:100%;height:100%;object-fit:contain}
.rbtn:active{transform:translateY(2px);filter:brightness(.88)}
.rbtn:focus-visible{outline:2px solid var(--cream);outline-offset:2px}
.rbtn.dim{opacity:.5}
.soundwrap{margin-left:clamp(2px,.6vw,8px)}
.soundbtn{
  width:calc(var(--rail-btn)*.72);
  height:calc(var(--rail-btn)*.72);
  border-radius:50%;
  border:2px solid #3a2f10;
  background:var(--brass);
  box-shadow:inset 0 0 0 2px #8a6f1e,0 2px 0 rgba(0,0,0,.5);
  display:grid;
  place-items:center;
  padding:0;
}
.soundbtn svg{width:64%;height:64%;overflow:visible}
.soundbtn .spk{fill:#1a1a1d;stroke:none}
.soundbtn .wave{fill:none;stroke:#1a1a1d;stroke-width:1.8;stroke-linecap:round}
.soundbtn .slash{fill:none;stroke:#e0413c;stroke-width:2.4;stroke-linecap:round;display:none}
.soundbtn.muted .wave{display:none}
.soundbtn.muted .slash{display:block}
.soundbtn:active{transform:translateY(1px)}
.soundbtn:focus-visible{outline:2px solid var(--cream);outline-offset:2px}

/* overlays */

.callout{
  position:absolute;
  left:50%;
  top:44%;
  transform:translate(-50%,-50%) rotate(-2deg);
  background:var(--cream);
  color:#14161b;
  font-family:'Limelight',serif;
  font-size:3.35em;
  line-height:1;
  letter-spacing:.02em;
  padding:.34em 1em .3em;
  border-top:2px solid var(--brass);
  border-bottom:2px solid var(--brass);
  box-shadow:.18em .18em 0 rgba(0,0,0,.6);
  white-space:nowrap;
  z-index:8;
  opacity:0;
  pointer-events:none;
  transition:opacity .12s linear;
  max-width:96%;
  text-align:center;
}
.callout.show{opacity:1}
.callout.small{font-size:2.4em}

.card{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%) rotate(-1.1deg);
  width:min(86%,520px);
  background:var(--cream);
  color:#15161b;
  border:1px solid #0B0B10;
  box-shadow:.55em .65em 0 rgba(0,0,0,.58);
  padding:1.25em 1.5em 1.1em;
  text-align:center;
  z-index:9;
  background-image:radial-gradient(circle at 1px 1px,rgba(20,20,25,.14) .8px,transparent 1px);
  background-size:4px 4px;
  font-family:'Oswald',sans-serif;
}
.card::before{
  content:"";
  position:absolute;
  inset:.35em;
  border:1px solid rgba(11,11,16,.34);
  pointer-events:none;
}
.card-tag{
  display:inline-block;
  background:var(--oxblood);
  color:var(--cream);
  font-weight:700;
  font-size:1.8em;
  letter-spacing:.24em;
  padding:.28em .9em .18em;
  border:1px solid #2c0d0d;
  transform:rotate(-1.6deg);
  margin-bottom:.8em;
}
.card-tag.dark{background:#16171c;color:var(--cream)}
.card h2{
  font-family:'Limelight',serif;
  font-weight:400;
  font-size:4.2em;
  line-height:1.02;
  letter-spacing:.01em;
  margin:.05em 0 .45em;
  color:#121318;
}
.card p{
  font-weight:300;
  font-size:2.45em;
  line-height:1.3;
  margin:0 auto .9em;
  max-width:34em;
}
.paperbtn{
  display:inline-block;
  font-family:'Oswald',sans-serif;
  font-weight:600;
  font-size:2.55em;
  letter-spacing:.13em;
  color:var(--cream);
  background:var(--oxblood);
  border:1px solid #2c0d0d;
  box-shadow:.2em .2em 0 rgba(0,0,0,.55);
  padding:.5em 1.1em .38em;
  margin:.1em 0 .7em;
}
.paperbtn:active{transform:translateY(2px);box-shadow:0 0 0 rgba(0,0,0,.5)}
.card-hint{
  font-family:'Special Elite',monospace;
  font-size:1.6em;
  letter-spacing:.05em;
  opacity:.72;
}
.card-hint span{display:block;font-size:.92em}

.gameover{text-align:left}
.gameover-head{display:flex;align-items:center;gap:1em;margin-bottom:.5em}
.mug{
  width:9.5em;
  height:9.5em;
  object-fit:contain;
  flex:0 0 auto;
  background:#0d0d12;
  border:2px solid var(--brass);
  box-shadow:inset 0 0 0 2px #000;
}
.gameover h2{font-size:3.5em;margin:.15em 0 .1em}
.gameover .card-tag{margin-bottom:.4em}
.finalrow{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  border-top:1px solid rgba(11,11,16,.32);
  padding:.32em 0 .2em;
  font-family:'Special Elite',monospace;
  font-size:2.4em;
}
.finalrow b{font-weight:400;font-size:1.25em}
.finalrow.small{font-size:2em;opacity:.8}
.books{
  border-top:1px solid rgba(11,11,16,.32);
  border-bottom:1px solid rgba(11,11,16,.32);
  margin:.4em 0 .6em;
  padding:.3em 0 .35em;
  font-family:'Special Elite',monospace;
  font-size:2em;
  min-height:2.2em;
}
.books-head{display:block;font-weight:700;letter-spacing:.16em;font-size:1.5em;opacity:.74;margin-bottom:.15em}
.bookrow{display:flex;justify-content:space-between;gap:.6em;line-height:1.28}
.bookrow a{color:var(--oxblood);text-decoration:none}
.bookrow a:hover{text-decoration:underline}
.bookrow .guest{color:#2e2f36}

.shutter{
  position:absolute;
  inset:0;
  z-index:12;
  background:repeating-linear-gradient(90deg,#c9a227 0 7px,#8a6f1e 7px 14px,#6a5517 14px 16px);
  border-top:3px solid #3d3010;
  border-bottom:3px solid #3d3010;
  transform:translateY(-102%);
  transition:transform .36s cubic-bezier(.55,.05,.35,1);
  pointer-events:none;
}
.shutter.closed{transform:translateY(0)}
.powervignette{
  position:absolute;
  inset:0;
  z-index:4;
  pointer-events:none;
  opacity:0;
  transition:opacity .55s linear;
  background:
    radial-gradient(ellipse at center,transparent 42%,rgba(122,31,31,.62) 100%),
    linear-gradient(180deg,rgba(122,31,31,.2),rgba(0,0,0,.24));
  mix-blend-mode:multiply;
}
.powervignette.on{opacity:1}

.shake{animation:cabinetShake .46s steps(2,end) 2}
@keyframes cabinetShake{
  0%{transform:translate(0,0)}
  25%{transform:translate(-3px,2px)}
  50%{transform:translate(2px,-2px)}
  75%{transform:translate(-2px,-1px)}
  100%{transform:translate(0,0)}
}

/* responsive */

@media (min-width:900px){
  :root{--marquee-w:540px;--hud-h:56px;--rail-btn:54px}
}

@media (max-width:899px) and (min-height:430px){
  .cabinet{height:auto;max-height:96dvh}
  .boardwrap{flex:0 0 auto;aspect-ratio:1804/1188;width:100%}
}

@media (max-height:560px){
  .lineup{display:flex;height:36px;margin-bottom:-4px;gap:9px}
  .boardwrap{width:84%;align-self:center}
  :root{--hud-h:36px;--rail-btn:32px;--marquee-w:280px}
  .hint{font-size:7.5px}
  .hint span{display:none}
  .card p{font-size:2.2em}
  .card h2{font-size:3.6em}
}

@media (max-width:560px){
  :root{--marquee-w:350px;--hud-h:38px;--rail-btn:34px}
  .hint .keys{display:none}
  .hint .pause{display:none}
  .turf small{display:none}
  .turf span{font-size:1.8em}
  .hudrow{gap:4px}
  .mugface{left:8%;width:76%}
}

@media (max-width:560px) and (max-height:560px){
  :root{--marquee-w:210px;--hud-h:32px;--rail-btn:34px}
  .cabinet{gap:3px}
  .hint{font-size:7.5px}
  .rail{padding:4px 8px 3px}
}

@media (prefers-reduced-motion:reduce){
  .shake{animation:none}
  .shutter{transition:none}
  .powervignette{transition:none}
}
