:root{
  --ink:#17131d;
  --ink-2:#2a2530;
  --bone:#c9c2ae;
  --bone-hi:#e9e2cf;
  --bone-lo:#8f8874;
  --bone-mid:#b6af9b;
  --black:#0b0910;
  --cream:#f1e8d2;
  --amber:#e8a33d;
  --amber-hi:#ffd889;
  --rust:#c2543a;
  --cyan:#63d2e8;
  --slot:#d99a35;
}
*{box-sizing:border-box}
html,body{height:100%;margin:0;overflow:hidden;background:#0d0b12}
body{
  color:var(--ink);
  font-family:'IBM Plex Mono',monospace;
  -webkit-tap-highlight-color:transparent;
  user-select:none;
}
button{font:inherit;color:inherit}
img{display:block}
img{image-rendering:pixelated}
#monitor{
  position:relative;
  height:100vh;
  height:100dvh;
  width:100vw;
  display:grid;
  grid-template-rows:minmax(0,1fr) auto;
  gap:clamp(4px,.7vh,8px);
  padding:clamp(40px,7.4vh,66px) clamp(4px,.8vh,9px) clamp(4px,.8vh,9px);
  background:
    linear-gradient(180deg,var(--bone-hi) 0,var(--bone) 3px,var(--bone) calc(100% - 3px),var(--bone-lo) 100%);
  background-color:var(--bone);
  border:3px solid var(--ink);
  box-shadow:
    inset 3px 3px 0 rgba(255,255,255,.35),
    inset -3px -3px 0 rgba(0,0,0,.28),
    inset 0 0 0 1px var(--bone-lo);
}

/* title sits in the left corner of the chrome surround, not on a panel */
.wordmark{
  position:absolute;
  top:clamp(5px,.8vh,9px);
  left:clamp(10px,1.5vw,22px);
  height:clamp(26px,5.4vh,50px);
  width:auto;
  max-width:min(58%,60vw);
  object-fit:contain;
  object-position:left center;
  filter:drop-shadow(0 1px 0 rgba(0,0,0,.25));
  pointer-events:none;
  z-index:6;
}
.mode{
  position:absolute;
  top:clamp(7px,1.1vh,12px);
  right:clamp(10px,1.5vw,22px);
  z-index:6;
  flex:0 0 auto;
  padding:clamp(4px,.7vh,8px) clamp(7px,1vw,12px);
  font-family:'Silkscreen',monospace;
  font-size:clamp(8px,1.25vh,12px);
  letter-spacing:.14em;
  text-transform:uppercase;
  color:var(--ink);
  background:var(--bone-mid);
  border:2px solid var(--ink);
  box-shadow:
    inset 0 2px 0 var(--bone-hi),
    inset 0 -2px 0 var(--bone-lo),
    0 2px 0 var(--ink);
  cursor:pointer;
}
.mode:active{transform:translateY(1px);box-shadow:inset 0 2px 0 var(--bone-hi),inset 0 -2px 0 var(--bone-lo),0 1px 0 var(--ink)}
.mode:focus-visible,.key:focus-visible,.well:focus-visible,.slot:focus-visible,.fire:focus-visible{
  outline:2px solid var(--amber);
  outline-offset:2px;
}

/* battlefield */
.field{
  position:relative;
  min-height:0;
  overflow:hidden;
  background:#0b0912;
  border:2px solid #000;
  box-shadow:inset 0 0 0 1px #3b3440,inset 0 0 0 3px #050408;
}
.field canvas{
  display:block;
  width:100%!important;
  height:100%!important;
  image-rendering:pixelated;
  image-rendering:crisp-edges;
}

/* wind cluster, the only overlay on the field */
.wind{
  position:absolute;
  top:clamp(6px,1.2vh,12px);
  left:clamp(6px,1.2vh,12px);
  z-index:4;
  padding:clamp(5px,.9vh,9px) clamp(8px,1vw,13px) clamp(4px,.7vh,7px);
  background:#171320;
  border:2px solid var(--bone);
  box-shadow:
    3px 3px 0 rgba(0,0,0,.65),
    inset 0 0 0 1px #000,
    inset 2px 2px 0 rgba(255,255,255,.07);
  color:var(--cream);
  pointer-events:none;
}
.wind-label{
  font-family:'Silkscreen',monospace;
  font-size:clamp(7px,1.1vh,10px);
  letter-spacing:.16em;
  color:var(--bone);
  text-shadow:1px 1px 0 #000;
  margin-bottom:1px;
}
.wind-main{display:flex;align-items:baseline;gap:clamp(5px,.8vw,9px)}
.wind-force{
  font-family:'VT323',monospace;
  font-size:clamp(26px,4.8vh,48px);
  line-height:.78;
  letter-spacing:.04em;
  color:var(--cream);
  text-shadow:2px 2px 0 #000;
  min-width:1.5em;
  text-align:right;
}
.wind-dir{
  font-family:'Silkscreen',monospace;
  font-size:clamp(8px,1.4vh,13px);
  letter-spacing:.08em;
  color:var(--cream);
  text-shadow:1px 1px 0 #000;
}
.round-line{
  margin-top:2px;
  font-family:'Silkscreen',monospace;
  font-size:clamp(8px,1.3vh,12px);
  letter-spacing:.12em;
  color:var(--bone);
  text-shadow:1px 1px 0 #000;
}

/* match over */
.gameover{
  position:absolute;
  inset:0;
  z-index:8;
  display:grid;
  place-items:center;
  background:rgba(7,5,11,.62);
}
.gameover[hidden]{display:none}
.gameover-plate{
  padding:clamp(16px,3vh,30px) clamp(22px,4vw,52px);
  text-align:center;
  background:#171320;
  border:3px solid var(--bone);
  box-shadow:5px 5px 0 #000,inset 0 0 0 2px #000,inset 2px 2px 0 rgba(255,255,255,.06);
}
.winner{
  font-family:'Silkscreen',monospace;
  font-size:clamp(20px,4vh,44px);
  letter-spacing:.1em;
  color:var(--amber);
  text-shadow:3px 3px 0 #000;
  line-height:1.15;
}
.finalrounds{
  margin-top:6px;
  font-family:'VT323',monospace;
  font-size:clamp(20px,3vh,34px);
  color:var(--cream);
  letter-spacing:.05em;
}
.again{
  margin-top:clamp(8px,1.4vh,14px);
  font-family:'Silkscreen',monospace;
  font-size:clamp(9px,1.5vh,13px);
  letter-spacing:.13em;
  color:var(--bone);
}

/* instrument panel */
.panel{
  height:clamp(186px,33vh,330px);
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:clamp(4px,.9vh,8px);
  padding:clamp(5px,.9vh,10px) clamp(8px,1.4vw,18px) clamp(5px,.9vh,10px);
  border:2px solid var(--ink);
  background:var(--bone);
  box-shadow:
    inset 0 3px 0 var(--bone-hi),
    inset 0 -3px 0 var(--bone-lo),
    inset 1px 0 0 rgba(255,255,255,.15),
    inset -1px 0 0 rgba(0,0,0,.15);
  overflow:hidden;
}
.controls{
  flex:0 0 auto;
  height:44%;
  min-height:0;
  display:flex;
  align-items:stretch;
  justify-content:space-between;
  gap:2%;
}
.side{
  position:relative;
  flex:1 1 0;
  min-width:0;
  display:flex;
  align-items:center;
  gap:clamp(5px,.8vw,14px);
  padding:clamp(3px,.6vh,7px) clamp(5px,.8vw,12px);
  border:1px solid rgba(0,0,0,.12);
  background:rgba(0,0,0,.08);
}
.side1{justify-content:flex-start}
.side2{justify-content:flex-end}
.side.active{
  background:rgba(255,248,226,.30);
  border-color:rgba(255,255,255,.38);
  box-shadow:inset 0 2px 0 rgba(255,255,255,.5),inset 0 -2px 0 rgba(0,0,0,.12);
}
.side.active .well,.side.active .key{opacity:1}
.side:not(.active) .well,.side:not(.active) .key{opacity:.56}
.keys{display:flex;gap:clamp(4px,.5vw,7px);flex:0 0 auto}
.key{
  width:clamp(40px,9vh,90px);
  height:clamp(40px,9vh,90px);
  flex:0 0 auto;
  padding:0;
  border:0;
  background:transparent;
  cursor:pointer;
  image-rendering:pixelated;
}
.key img{width:100%;height:100%;object-fit:contain;image-rendering:pixelated}
.key:active:not(:disabled){transform:translateY(2px)}
.key:disabled{cursor:default}
.wells{display:flex;gap:clamp(5px,.8vw,12px);min-width:0;flex:0 1 auto}
.well{
  position:relative;
  width:clamp(68px,11.5vw,176px);
  height:clamp(52px,9.5vh,96px);
  flex:0 1 auto;
  padding:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:var(--black);
  border:0;
  cursor:pointer;
  box-shadow:
    inset 3px 3px 0 #000,
    inset -3px -3px 0 #47412f,
    0 1px 0 var(--bone-hi);
}
.well-label{
  position:absolute;
  top:clamp(3px,.6vh,6px);
  left:0;right:0;
  font-family:'Silkscreen',monospace;
  font-size:clamp(7px,1.15vh,11px);
  letter-spacing:.12em;
  color:#b7ae94;
  text-align:center;
  text-shadow:none;
  line-height:1;
}
.well-value{
  margin-top:.18em;
  font-family:'VT323',monospace;
  font-size:clamp(34px,7.6vh,74px);
  line-height:.76;
  letter-spacing:.03em;
  color:var(--cream);
  text-shadow:2px 2px 0 #000;
}
.well.selected{
  box-shadow:
    inset 3px 3px 0 #000,
    inset -3px -3px 0 #47412f,
    0 0 0 2px var(--amber),
    0 0 0 4px var(--ink),
    0 2px 0 var(--bone-hi);
  background:#141018;
}
.well.selected .well-label{color:var(--amber-hi)}
.well.selected .well-value{color:var(--amber-hi)}

.shellhead{
  flex:0 0 auto;
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:12px;
  height:clamp(17px,2.6vh,26px);
  padding:0 2px;
  min-width:0;
}
.shell-label{
  font-family:'Silkscreen',monospace;
  font-size:clamp(11px,1.65vh,15px);
  letter-spacing:.14em;
  color:var(--ink);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.shell-kicker{color:#6e6654}
#shellName{color:#17131d}
.hint{
  font-family:'IBM Plex Mono',monospace;
  font-size:clamp(8px,1.1vh,11px);
  letter-spacing:.06em;
  color:#655d4d;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.shellrow{
  flex:1 1 auto;
  min-height:0;
  display:flex;
  align-items:stretch;
  gap:clamp(5px,.8vw,12px);
}
.rack{
  position:relative;
  flex:1 1 auto;
  min-width:0;
  background:url(assets/elements/shell_rack.webp) center center/100% 100% no-repeat;
  image-rendering:pixelated;
}
.slot{
  position:absolute;
  top:11.6%;
  height:76.8%;
  left:var(--l);
  width:var(--w);
  padding:0;
  border:0;
  background:transparent;
  cursor:pointer;
  z-index:1;
  display:flex;
  align-items:center;
  justify-content:center;
}
.slot img{
  width:78%;
  height:78%;
  object-fit:contain;
  image-rendering:pixelated;
  filter:brightness(.82) saturate(.86);
  opacity:.94;
}
.slot:hover img{filter:brightness(1) saturate(.95)}
.slot.selected{
  background:var(--slot);
  border:2px solid #774c13;
  box-shadow:
    inset 2px 2px 0 #ffd27f,
    inset -2px -2px 0 #9a601b,
    0 2px 0 #000,
    0 0 0 1px #2b1a08;
  transform:translateY(-2px);
  z-index:3;
}
.slot.selected img{filter:none;opacity:1}
.slot:disabled{cursor:default}
.fire{
  flex:0 0 auto;
  width:clamp(72px,12vw,180px);
  height:100%;
  padding:0;
  border:0;
  background:transparent;
  cursor:pointer;
  image-rendering:pixelated;
}
.fire img{width:100%;height:100%;object-fit:contain;object-position:center;image-rendering:pixelated;filter:drop-shadow(0 2px 0 rgba(0,0,0,.25))}
.fire:active:not(:disabled){transform:translateY(2px)}
.fire:disabled{cursor:default;opacity:.5}

/* compact layouts */
@media (orientation:portrait){
  #monitor{padding:clamp(36px,6.4vh,56px) 4px 4px;gap:4px}
  .wordmark{height:clamp(24px,4.6vh,40px);max-width:56%;left:8px;top:4px}
  .mode{font-size:8px;padding:3px 6px;right:8px;top:5px}
  .panel{
    height:clamp(212px,36vh,300px);
    gap:4px;
    padding:6px 7px;
  }
  /* portrait stacks the two gun crews: player above, enemy below */
  .controls{height:50%;gap:2px;flex-direction:column}
  .side{flex:1 1 0;gap:5px;padding:3px 6px}
  .side1{justify-content:flex-start}
  .side2{justify-content:flex-end}
  .keys{gap:4px}
  .key{width:clamp(34px,6.4vh,52px);height:clamp(34px,6.4vh,52px)}
  .wells{gap:5px}
  .well{width:clamp(54px,15vw,82px);height:clamp(44px,6.4vh,58px)}
  .well-label{font-size:7px;top:2px;letter-spacing:.06em}
  .well-value{font-size:clamp(26px,6vh,42px)}
  .shellhead{height:16px}
  .shell-label{font-size:10px;letter-spacing:.1em}
  .hint{display:none}
  .shellrow{gap:4px}
  .fire{width:clamp(62px,17vw,96px)}
  .wind{top:6px;left:6px;padding:4px 6px 3px}
  .wind-main{gap:4px}
  .wind-label{font-size:7px}
  .wind-force{font-size:27px}
  .wind-dir{font-size:9px}
  .round-line{font-size:8px;margin-top:1px}
  .gameover-plate{padding:14px 18px}
  .winner{font-size:clamp(18px,5.5vw,32px)}
}
@media (max-height:560px){
  #monitor{padding-top:clamp(32px,5.8vh,40px)}
  .wordmark{height:clamp(22px,4.4vh,32px)}
  .panel{height:38vh;min-height:128px;padding:4px 6px;gap:3px}
  .controls{height:44%}
  .key{width:clamp(30px,8.2vh,52px);height:clamp(30px,8.2vh,52px)}
  .well{height:clamp(42px,7.6vh,62px)}
  .well-value{font-size:clamp(26px,6vh,44px)}
  .well-label{font-size:7px;top:2px}
  .shellhead{height:14px}
  .hint{display:none}
  .wind{padding:3px 5px 2px}
  .wind-label{font-size:6px}
  .wind-force{font-size:23px}
  .wind-dir{font-size:8px}
  .round-line{font-size:7px}
}
