/* 3D Pinball in a Windows 2000 window (Windows Standard colors, Tahoma 8 pt) on the default desktop color. */
:root {
  --face: #d4d0c8;
  --hilite: #fff;
  --shadow: #808080;
  --dark: #404040;
  --navy: #0a246a;
  --sky: #a6caf0;
  --ui: 11px Tahoma, "MS Sans Serif", Verdana, Geneva, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: #3a6ea5;
  font: var(--ui);
  color: #000;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }

#back {
  position: absolute; top: 6px; left: 8px; z-index: 3;
  color: #fff; font: 12px Tahoma, Verdana, sans-serif; text-decoration: none; text-shadow: 1px 1px #000;
}
#back:hover, #back:focus-visible { text-decoration: underline; }

#desktop {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 26px 8px 8px;
  padding: max(26px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
           max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

/* --- window chrome ---------------------------------------------------------------------------------- */
.window {
  background: var(--face);
  border: 1px solid; border-color: var(--face) var(--dark) var(--dark) var(--face);
  box-shadow: inset 1px 1px var(--hilite), inset -1px -1px var(--shadow);
  padding: 3px;
}
.title {
  display: flex; align-items: center; gap: 2px;
  height: 18px; padding: 0 2px 0 3px;
  background: linear-gradient(to right, var(--navy), var(--sky));
  color: #fff; font-weight: bold;
  user-select: none; -webkit-user-select: none;
}
.window.inactive .title { background: linear-gradient(to right, #808080, #c0c0c0); color: var(--face); }
.title img { flex: none; margin-right: 1px; }
.title .caption { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tb {
  flex: none; position: relative; width: 16px; height: 14px; padding: 0;
  background: var(--face); border: 0;
  box-shadow: inset -1px -1px var(--dark), inset 1px 1px var(--hilite), inset -2px -2px var(--shadow), inset 2px 2px var(--face);
}
.tb.close { margin-left: 2px; }
.tb:active { box-shadow: inset 1px 1px var(--dark), inset -1px -1px var(--hilite), inset 2px 2px var(--shadow), inset -2px -2px var(--face); }
.tb:active i { transform: translate(1px, 1px); }
.tb i { position: absolute; inset: 0; }
.tb i::before, .tb i::after { content: ""; position: absolute; background: #000; }
.g-min::before { left: 4px; top: 9px; width: 6px; height: 2px; }
.g-max::before { left: 3px; top: 2px; width: 9px; height: 9px; background: none; border: 1px solid #000; border-top-width: 2px; }
.g-close::before, .g-close::after { left: 3px; top: 6px; width: 9px; height: 2px; transform: rotate(45deg); }
.g-close::after { transform: rotate(-45deg); }

/* --- menu bar --------------------------------------------------------------------------------------- */
.menubar { display: flex; height: 19px; margin-top: 1px; user-select: none; -webkit-user-select: none; }
.menu { position: relative; }
.menu > button {
  height: 19px; padding: 0 6px; background: none; border: 1px solid transparent;
}
.menu > button:hover, .menubar.active .menu > button:focus-visible {
  border-color: var(--hilite) var(--shadow) var(--shadow) var(--hilite);
}
.menu.open > button { border-color: var(--shadow) var(--hilite) var(--hilite) var(--shadow); }
.menu.open > button span, .menu.open > button { padding: 1px 5px 0 7px; }
.menubar:not(.keys) u { text-decoration: none; }
.drop {
  display: none; position: absolute; left: 0; top: 100%; z-index: 20;
  min-width: 150px; padding: 2px;
  background: var(--face);
  border: 1px solid; border-color: var(--face) var(--dark) var(--dark) var(--face);
  box-shadow: inset 1px 1px var(--hilite), inset -1px -1px var(--shadow), 2px 2px 0 rgba(0, 0, 0, .25);
}
.menu.open > .drop, .sub.open > .drop { display: block; }
.sub { position: relative; }
.sub > .drop { left: 100%; top: -3px; margin-left: -3px; }
.drop button {
  display: flex; align-items: center; width: 100%; height: 17px; padding: 0 18px 0 19px;
  background: none; border: 0; text-align: left; white-space: nowrap; position: relative;
}
.drop button:hover, .drop button:focus, .sub.open > button { background: var(--navy); color: #fff; outline: none; }
.drop button[aria-disabled="true"] { color: var(--shadow); text-shadow: 1px 1px var(--hilite); }
.drop button[aria-disabled="true"]:hover, .drop button[aria-disabled="true"]:focus { color: var(--shadow); text-shadow: none; }
.drop kbd { margin-left: auto; padding-left: 24px; font: inherit; }
.drop [aria-checked="true"]::before { content: ""; position: absolute; left: 6px; top: 4px; width: 7px; height: 7px;
  background: currentColor; clip-path: polygon(0 43%, 28% 71%, 100% 0, 100% 29%, 28% 100%, 0 71%); }
.drop [role="menuitemradio"][aria-checked="true"]::before { left: 7px; top: 6px; width: 5px; height: 5px; border-radius: 50%; clip-path: none; }
.sub > button::after { content: ""; position: absolute; right: 6px; top: 4px;
  border: 4px solid transparent; border-left-color: currentColor; border-right: 0; }
.drop hr { height: 0; margin: 3px 1px; border: 0; border-top: 1px solid var(--shadow); border-bottom: 1px solid var(--hilite); }

/* --- the game --------------------------------------------------------------------------------------- */
#client { position: relative; margin-top: 1px; background: #000; }
#canvas { display: block; width: 600px; height: 416px; touch-action: none; outline: none; }
#loading {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: #fff;
}
#loading[hidden] { display: none; }
#loading .bar { width: 160px; height: 14px; padding: 2px; background: var(--face);
  box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--hilite); }
#loading .bar i { display: block; height: 100%; width: 0; background: var(--navy); }

#touch { position: absolute; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
#touch[hidden] { display: none; }
#touch.off { pointer-events: none; }
#touch .zone { position: absolute; }
/* (zones and labels placed by page.js placeZones) */
#touch .zone span, #pad .zone span {
  position: absolute; padding: 1px 4px; color: #fff; background: rgba(0, 0, 0, .55); font-size: 11px;
  transition: opacity 1s; pointer-events: none; white-space: nowrap;
}
#touch.used .zone span { opacity: 0; }
#touch.used .zone span.aside { opacity: .45; } /* in the black beside the table: they stay, dimmed */
#touch .zone.down, #pad .zone.down { background: rgba(255, 255, 255, .08); }

/* phones held upright (body.portrait): the table across the screen, then Bump and Launch, then the score panel
   (copied from the game's frame by page.js) with the flippers' halves of the screen over it */
#pad { display: none; }
/* (upright is always the maximized window, as on a small screen, a tablet's too) */
body.portrait #desktop { flex-direction: column; justify-content: flex-start; align-items: stretch;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
body.portrait #pinball { border: 0; box-shadow: none; padding: 0; width: 100%; }
body.portrait #client { display: flex; justify-content: center; }
body.portrait #back { top: calc(env(safe-area-inset-top) + var(--title-h, 18px) + 1px); left: auto;
  right: calc(env(safe-area-inset-right) + 8px); line-height: var(--menu-h, 19px); color: #000; text-shadow: none;
  font-size: 14px; padding: 0 4px; }
#panel { display: block; margin: 0 auto; }
body.portrait #pinball:not([hidden]) { flex: 1; display: flex; flex-direction: column; min-height: 0; }
body.portrait #client { flex: none; overflow: hidden; }
body.portrait.crop #client { justify-content: flex-start; }
body.portrait.crop #canvas { flex: none; }
body.portrait #pad:not([hidden]) {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
#pad .row { flex: none; display: flex; gap: 6px; padding: 6px; }
#pad .row .btn { flex: 1 1 0; height: 52px; min-width: 0; font: bold 15px Tahoma, Verdana, sans-serif; }
#pad .row .btn:last-child { flex-grow: 1.6; }
#pad .row small { font-weight: normal; font-size: 12px; }
#pad .row .btn.down { box-shadow: inset 1px 1px var(--dark), inset -1px -1px var(--hilite), inset 2px 2px var(--shadow);
  padding-top: 2px; }
#pad .flip { flex: 1; position: relative; min-height: 0; background: #000; overflow: hidden; }
#pad .flip .zone { position: absolute; top: 0; bottom: 0; width: 50%; left: 0; }
#pad .flip .zone + .zone { left: 50%; border-left: 1px dashed rgba(255, 255, 255, .14); }
#pad .flip .zone span { bottom: 10px; left: 12px; font-size: 13px; padding: 3px 6px; color: #ddd; background: rgba(255, 255, 255, .08); }
#pad .flip .zone + .zone span { left: auto; right: 12px; }
body.tight #pad .flip .zone span { display: none; } /* no room under the panel: the labels go over the table */
body.portrait:not(.tight) #touch span { display: none; }

/* --- the desktop icon (after Exit or Minimize) ---------------------------------------------------- */
#desktop-icon {
  position: absolute; top: 34px; left: 12px; width: 76px; padding: 2px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: 0; color: #fff; cursor: default;
}
#desktop-icon[hidden] { display: none; }
#desktop-icon span { padding: 0 2px; }
#desktop-icon:focus { outline: none; }
#desktop-icon:focus span { background: var(--navy); outline: 1px dotted #ff0; }
#desktop-icon:focus img { filter: brightness(.6) sepia(1) hue-rotate(190deg) saturate(4); }

/* --- dialogs ---------------------------------------------------------------------------------------- */
dialog.window { color: #000; margin: auto; max-width: calc(100vw - 16px); }
dialog::backdrop { background: transparent; }
dialog .body { padding: 10px 10px 8px; }
.buttons { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }
.btn {
  min-width: 75px; height: 23px; padding: 0 8px; background: var(--face); border: 0;
  box-shadow: inset -1px -1px var(--dark), inset 1px 1px var(--hilite), inset -2px -2px var(--shadow), inset 2px 2px var(--face);
}
.btn:active { box-shadow: inset 1px 1px var(--dark), inset -1px -1px var(--hilite), inset 2px 2px var(--shadow); }
.btn:focus-visible { outline: 1px dotted #000; outline-offset: -5px; }
.btn:disabled { color: var(--shadow); text-shadow: 1px 1px var(--hilite); }
.btn:disabled:active { box-shadow: inset -1px -1px var(--dark), inset 1px 1px var(--hilite), inset -2px -2px var(--shadow), inset 2px 2px var(--face); }
.sunken { background: #fff; box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--hilite), inset 2px 2px var(--dark), inset -2px -2px var(--face); padding: 8px 10px; }
.sunken p { margin: 0 0 8px; }
.sunken p:last-child { margin-bottom: 0; }

#scores table { border-collapse: collapse; width: 100%; background: #fff; box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--hilite); }
#scores th { font-weight: normal; text-align: left; padding: 2px 8px; background: var(--face);
  box-shadow: inset -1px -1px var(--shadow), inset 1px 1px var(--hilite); }
#scores td { padding: 2px 8px; height: 22px; }
#scores td:first-child { text-align: center; }
#scores td:last-child { text-align: right; min-width: 100px; }
#scores td:nth-child(2) { width: 120px; }
#scores input { width: 100%; font: inherit; padding: 1px 2px; border: 0;
  box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--hilite), inset 2px 2px var(--dark); }

#controls .hint { margin: 0 0 8px; max-width: 420px; line-height: 1.4; }
#controls table { border-collapse: separate; border-spacing: 0 4px; }
#controls th { font-weight: normal; text-align: left; padding-right: 10px; white-space: nowrap; }
#controls td { padding-right: 4px; }
.input {
  width: 112px; height: 21px; padding: 0 4px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: #fff; border: 0; box-shadow: inset 1px 1px var(--shadow), inset -1px -1px var(--hilite), inset 2px 2px var(--dark), inset -2px -2px var(--face);
}
.input.none { color: var(--shadow); }
#controls td:last-child .input { width: 150px; }
.input.listening { background: var(--navy); color: #fff; }
.input:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }
#scores .who { margin: 0 0 8px; }
#scores .note { margin: 8px 0 0; }
#scores .error { margin: 8px 0 0; color: #a00; }
#scores tr.mine td { background: var(--navy); color: #fff; }
#scores td input { width: 52px; font: bold 11px Tahoma, Verdana, sans-serif; letter-spacing: 2px; text-transform: uppercase; }

#about { width: 380px; }
.about-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.about-head p { margin: 0; line-height: 1.5; }
.credits { max-height: 46vh; overflow: auto; line-height: 1.45; }
#help { width: 420px; }
.help-text { max-height: 60vh; overflow: auto; line-height: 1.45; }
.help-text table { border-collapse: collapse; margin-bottom: 8px; }
.help-text td { padding: 1px 12px 1px 0; vertical-align: top; }
.help-text td:first-child { white-space: nowrap; font-weight: bold; }
a { color: #00f; }

/* small screens: the window is maximized (no frame, no desktop around it), with the way back on the menu bar */
@media (max-width: 700px), (max-height: 560px) {
  #desktop { flex-direction: column; justify-content: flex-start; align-items: stretch;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  #pinball { border: 0; box-shadow: none; padding: 0; width: 100%; }
  #pinball .title, #pinball .menubar { padding-right: 2px; }
  #client { display: flex; justify-content: center; }
  #back { top: calc(env(safe-area-inset-top) + 19px); left: auto; right: calc(env(safe-area-inset-right) + 8px);
    line-height: 20px; color: #000; text-shadow: none; font-size: 11px; }
  #desktop-icon { top: 8px; }
}

/* full screen: the game alone */
#pinball:fullscreen { padding: 0; border: 0; box-shadow: none; background: #000; display: flex; align-items: center; justify-content: center; }
#pinball:fullscreen .title, #pinball:fullscreen .menubar { display: none; }
body.portrait #pinball:fullscreen { flex-direction: column; align-items: stretch; justify-content: flex-start; }

/* touch screens: the same window, with menus, title bar buttons and dialogs big enough for fingers. Nothing here
   applies with a mouse. */
@media (pointer: coarse) {
  :root { --title-h: 26px; --menu-h: 38px; --tb-w: 30px; --tb-h: 22px; }
  body { touch-action: manipulation; } /* no double-tap zoom */
  #desktop { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  .title { height: var(--title-h); font-size: 13px; }
  .tb { width: var(--tb-w); height: var(--tb-h); }
  .tb i { inset: auto; left: 50%; top: 50%; width: 16px; height: 14px; margin: -7px 0 0 -8px; }
  .menubar { height: var(--menu-h); }
  .menu > button { height: var(--menu-h); padding: 0 12px; font-size: 14px; }
  .menu.open > button { padding: 1px 11px 0 13px; }
  .drop { min-width: 220px; padding: 3px; }
  .drop button { height: 42px; padding: 0 22px 0 30px; font-size: 14px; }
  .drop kbd { display: none; } /* F keys: no keyboard */
  .drop [aria-checked="true"]::before { left: 10px; top: calc(50% - 4px); width: 9px; height: 9px; }
  .drop [role="menuitemradio"][aria-checked="true"]::before { left: 11px; top: calc(50% - 3px); width: 7px; height: 7px; }
  .drop hr { margin: 5px 1px; }
  /* Select Players opens under its item, not beside it (no room on a phone) */
  .sub > .drop { position: static; display: none; min-width: 0; margin: 0; padding: 0 0 0 18px;
    border: 0; box-shadow: none; background: none; }
  .sub > button::after { right: 10px; top: calc(50% - 2px); border: 5px solid transparent; border-top-color: currentColor; border-bottom: 0; }

  dialog.window { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); font-size: 13px;
    -webkit-user-select: text; user-select: text; }
  dialog.window[open] { display: flex; flex-direction: column; }
  dialog form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
  dialog .body { display: flex; flex-direction: column; min-height: 0; overflow: auto; }
  dialog .title { flex: none; }
  .credits, .help-text { flex: 1 1 auto; min-height: 60px; max-height: none; }
  .btn { min-width: 88px; height: 40px; padding: 0 12px; font-size: 14px; }
  .buttons { gap: 8px; flex: none; }
  #scores td, #scores th { padding: 4px 10px; height: 30px; }
  #scores td:nth-child(2) { width: auto; }
  #scores td:last-child { min-width: 0; }
  #scores td input { width: 72px; height: 30px; font-size: 16px; } /* 16px: iOS doesn't zoom in to type */
  #controls .hint { max-width: none; }
  #controls table { border-spacing: 0 6px; }
  #controls table { width: 100%; table-layout: fixed; }
  #controls th { width: 64px; white-space: normal; padding-right: 6px; }
  .input, #controls td:last-child .input { width: 100%; height: 36px; font-size: 13px; }
  /* OK and Cancel stay in sight while the rest scrolls */
  dialog .body > .buttons { position: sticky; bottom: -8px; margin: 10px -10px -8px; padding: 0 10px 8px;
    background: var(--face); }
}
/* the maximized window on a touch screen: the way back sits on the taller menu bar */
@media (pointer: coarse) and (max-width: 700px), (pointer: coarse) and (max-height: 560px) {
  #back { top: calc(env(safe-area-inset-top) + var(--title-h)); line-height: var(--menu-h); font-size: 14px;
    padding: 0 4px; }
}
/* a phone on its side: the screen is short, so the bars are a little thinner */
@media (pointer: coarse) and (max-height: 500px) {
  :root { --title-h: 22px; --menu-h: 32px; --tb-w: 28px; --tb-h: 19px; }
  .drop button { height: 36px; }
  #scores td, #scores th { padding: 1px 10px; height: 24px; }
  #scores td input { height: 24px; }
  dialog .body { padding-top: 6px; }
  .buttons { margin-top: 6px; }
  #scores .who, #controls .hint { margin-bottom: 4px; }
}
