/* Register the screen and existing inputs to the four bands of the cabinet artwork. */
@media (orientation: portrait) {
  body { background: #02161a; }
  main, .playing main {
    --machine: min(100vw, 76rem);
    --edge: min(2.05vw, 1.35rem);
    --ringw: 100%;
    width: var(--machine);
    height: auto;
    min-height: 100svh;
    margin: 0 auto;
    padding: env(safe-area-inset-top) 0 max(.5rem,env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: var(--edge) minmax(0,1fr) var(--edge);
    grid-template-rows: calc(var(--machine)*.335) auto calc(var(--machine)*.172) calc(var(--machine)*.287);
    grid-auto-rows: max-content;
    gap: 0;
    align-content: start;
    align-items: stretch;
    justify-content: stretch;
    background: #04171b;
    isolation: isolate;
  }
  main::before, main::after, .cabinet-bezel, .cabinet-deck {
    grid-column: 1 / -1;
    pointer-events: none;
    border: solid transparent;
    border-width: 0 var(--edge);
    border-image-slice: 0 131 fill;
    border-image-repeat: stretch;
  }
  main::before {content:""; grid-row:1; border-image-source:url("./upright-crown.webp");}
  main::after {content:""; grid-row:4; border-image-source:url("./upright-base.webp");}
  .cabinet-bezel {grid-row:2; border-image-source:url("./upright-bezel.webp");}
  .cabinet-deck {grid-row:3; border-image-source:url("./upright-deck.webp");}
  .arena, #setup #titleFilm, #transitionFilm {
    position: relative;
    inset: auto;
    grid-area: 2 / 2;
    align-self: center;
    width: 100%;
    max-width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    background: #030408;
  }
  .arena {aspect-ratio: auto;}
  #transitionFilm {z-index: 2;}
  body:not(.playing) .arena {display: none;}
  #setup:not([hidden]), #setup.opening:not([hidden]) {display: contents;}
  #setup.opening #titleFilm {grid-area: 2 / 2; object-fit: contain;}
  #setup.opening #playOpening {grid-area: 2 / 2;}
  #setup .setup-panel, #setup.opening .setup-panel {
    grid-area: 5 / 1 / 6 / -1;
    width: 100%;
    max-height: none;
    background: #0b191f;
    align-self: start;
    padding: .65rem max(.8rem,env(safe-area-inset-left)) .75rem;
    border-radius: 0;
  }
  main:has(#setup:not(.opening):not([hidden])) .cabinet-bezel {
    aspect-ratio: auto;
    min-height: calc((var(--machine) - 2 * var(--edge)) * .5625);
  }
  main:has(#setup:not(.opening):not([hidden])) .cabinet-bezel::after {
    content:"";display:block;height:100%;background: url("../entrances/tiki-opening.webp") center/contain no-repeat;
  }
  .mast, body:not(.playing) .mast, .playing .mast {
    position: static;
    grid-area: 7 / 1 / 8 / -1;
    display: flex;
    justify-content: center;
    height: auto; min-height: 0; max-width: none; width: 100%;
    padding: .4rem 0;
    background: #08151a;
  }
  .mast h1 {
    position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);
  }
  #floor {
    grid-area: 5 / 1 / 6 / -1;
    width: 100%; padding: .4rem .65rem;
  }
  body:not(.playing) #floor {display:none;}
  .playing #pads:not([hidden]) {display:contents;}
  .playing .pad:first-child {
    grid-area: 3 / 2;
    width: 100%; max-width: none;
    position:relative;
    display:block;
  }
  .playing .pad:first-child button {
    --center: 50%;
    position:absolute;
    left:var(--center);
    transform:translateX(-50%);
    top:7%; height:90%;
    width:12.25%; min-width:0; min-height:44px;
    display:flex;align-items:flex-end;justify-content:center;
    padding:0 0 1%;
    border:0; background:transparent;
    font:bold clamp(9px,2.65vw,18px)/1 Arial,sans-serif;
    color:white; text-shadow:0 1px 2px black,1px 0 2px black,-1px 0 2px black;
  }
  .playing .pad:first-child button::before {display:none;}
  /* Physical points on the control shelf, measured within the bezel's center band. */
  .playing .pad:first-child button:nth-child(1) {--center:11.5%; width:19%;}
  .playing .pad:first-child button:nth-child(2) {--center:30.5%; width:19%;}
  .playing .pad:first-child button:nth-child(3) {--center:51%;}
  .playing .pad:first-child button:nth-child(4) {--center:63.4%;}
  .playing .pad:first-child button:nth-child(5) {--center:75.8%;}
  .playing .pad:first-child button:nth-child(6) {--center:87.8%;}
  .playing .pad:first-child button:active, .playing .pad:first-child button:focus-visible {
    border-radius:.45rem; background:#fff2; box-shadow:inset 0 -2px #ffe5ae;
  }
  .playing .pad:nth-child(2) {
    grid-area:6 / 1 / 7 / -1;
    width:100%;max-width:100%;padding:.25rem;justify-content:center;
  }
  .playing.solo .pad:nth-child(2), .playing.private .pad:nth-child(2) {display:none;}
  .playing #floor:has(#finish:not([hidden])) ~ #pads {display:none;}
  body:not(.playing) #pads {display:none;}
}
@media (orientation: portrait) {
  .cabinet-deck {
    position: relative;
    border-image-source: url("./joystick-deck.webp");
  }
  .cabinet-stick {
    position: absolute;
    left: 16.02%;
    top: -2.58%;
    width: 10.2%;
    height: 58.76%;
    background: url("./joystick-handle.webp") center / 100% 100% no-repeat;
    clip-path: polygon(50% 1%,64% 2%,78% 8%,88% 15%,96% 25%,98% 36%,95% 47%,88% 56%,78% 64%,67% 69%,67% 95%,64% 98%,35% 98%,32% 96%,32% 69%,19% 63%,9% 54%,3% 45%,1% 34%,4% 24%,11% 15%,21% 8%,36% 2%);
    transform-origin: 50% 96%;
    transform: rotate(var(--tilt, 0deg));
    transition: transform 100ms cubic-bezier(.2,.78,.35,1);
  }
}
@media (orientation: portrait) and (prefers-reduced-motion: reduce) {
  .cabinet-stick {transition: none;}
}
/* In the portrait lobby the selection deck sits above the cabinet's plinth. */
@media (orientation:portrait) {
 body:not(.playing) main {
   grid-template-rows:calc(var(--machine)*.335) auto calc(var(--machine)*.172) auto auto calc(var(--machine)*.287);
   --tile:clamp(95px,27vw,188px);
 }
 body:not(.playing) main::after {grid-row:6}
 body:not(.playing) .selection-shell {
   display:block;grid-area:4 / 1 / 6 / -1;pointer-events:none;
   background:#210934 url('./selector.webp') center/100% 100% no-repeat;
 }
 body:not(.playing) #setup .setup-panel,body:not(.playing) .mast {
   background:none;box-shadow:none;border:0;position:relative;z-index:1;min-width:0;
 }
 body:not(.playing) #setup .setup-panel {
   grid-area:4 / 1 / 5 / -1;
   padding:clamp(16px,4vw,40px) 6% .35rem;
 }
 body:not(.playing) .mast {grid-area:5 / 1 / 6 / -1;padding:0 6% clamp(16px,4vw,40px)}
 #setup .setup-head {gap:.28rem;flex-wrap:wrap}
 #setup .setup-head h2 {
   font:italic 950 clamp(14px,3.8vw,30px)/1.1 system-ui;
   text-transform:uppercase;color:#ffe593;text-shadow:0 2px #933b0a,0 4px 5px #130318;
 }
 #setup :is(select,input) {
   border:1px solid #d09758;border-radius:.6rem;min-height:42px;min-width:0;
   background:#24103c;color:white;font-size:16px;
   box-shadow:inset 0 2px 6px #0d051d;
 }
 #setup #mode {font-size:14px;padding:.25rem}
 #soloPick {min-width:0}
 #soloName {font-weight:850;font-size:clamp(17px,4.5vw,30px);color:white}
 #soloName::before {content:"P1";display:inline-block;background:linear-gradient(#ffe685,#ec9520);color:#38102b;font:italic 950 .8em system-ui;border-radius:.35rem;padding:1px 6px;margin-right:.5em}
 #setup #fighterRail {scroll-snap-type:x proximity;gap:9px;padding:8px 5px 10px;scroll-padding-inline:5px;scrollbar-color:#edac3e #220b3b}
 #setup #fighterRail button,#setup .scouting img,#setup .seat img:not([hidden]) {
   border-radius:14px;width:var(--tile);height:var(--tile);padding:2px;
   background:radial-gradient(ellipse at 50% 72%,#803eba,#290e54 74%);
   box-shadow:inset 0 0 0 2px #331237,0 3px #100620;
   border:2px solid #ae72dc;overflow:hidden;scroll-snap-align:start;
 }
 #setup #fighterRail button[aria-pressed=true],#setup .seat img:not([hidden]) {
   background:radial-gradient(ellipse at 50% 72%,#ff9822,#7a2452 68%,#331247);
   border:3px solid #ffe091;box-shadow:0 0 8px #ffaf32,inset 0 0 8px #ffc861;
 }
 #fighterRail button:disabled {opacity:1}
 #setup #fighterRail button:disabled img {opacity:.82;filter:saturate(.6)}
 #fighterRail button:disabled::after {font-size:15px;background:#190a31dc;border-radius:9px 0 0;padding:4px}
 #setup #career {display:grid;grid-template-columns:auto minmax(0,1fr);gap:.36rem .55rem}
 #setup #career[hidden] {display:none}
 #setup #careerRecord,#setup #career .scouting {display:flex;grid-column:1/-1;margin:0}
 #careerRecord {font-size:.85rem;padding:4px 0}
 #setup #career select,#setup #soloStart,#setup #versusStart {width:100%}
 #setup .scouting img {background:radial-gradient(#2074ac,#191042);border-color:#62d9ef}
 #setup #scout {color:#f5eaff;line-height:1.34;font-size:clamp(13px,3.55vw,21px)}
 #setup #soloStart,#setup #resetCareer {grid-column:1/-1}
 #setup #soloStart,#setup #versusStart {min-height:48px;font-weight:900}
 #setup #seats {grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}
 #setup .seat {display:flex;flex-direction:column;justify-content:center;text-align:center;min-width:0;background:#220e48d9;border:1px solid #c67edf;border-radius:13px;padding:6px}
 #setup .seat img:not([hidden]) {display:block;order:-1}
 #setup .seat select,#setup .seat label {width:100%;max-width:100%;padding:.1rem}
 #setup .seat:nth-child(2) img:not([hidden]) {background:radial-gradient(#2074ac,#191042);border-color:#62d9ef;box-shadow:0 0 8px #40bfff}
 #setup #venue {max-width:95%}
}
@media (orientation:portrait) {
  body:not(.playing) main {overflow-x:clip}
  #setup #mode {font-size:16px}
  #careerRecord {justify-content:space-between;gap:.3em}
  #careerRecord::after {content:"Swipe ↔";color:#8ef0ff;white-space:nowrap}
}
