/* Shared Windows 3.1-style chrome for the game collection. */
:root {
  --desk: #008080;
  --face: #c0c0c0;
  --light: #ffffff;
  --shadow: #808080;
  --dark: #000000;
  --title: #000080;
  --title-text: #ffffff;
  --menu-hi: #000080;
  --font: "MS Sans Serif", "Microsoft Sans Serif", Tahoma, Verdana, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--desk);
  font: bold 13px/1.3 var(--font);
  color: #000;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, input, select { font: inherit; }

/* ---------- window ---------- */
.win {
  position: absolute;
  inset: 0;
  margin: auto;
  display: flex;
  flex-direction: column;
  background: var(--face);
  border: 2px solid var(--dark);
  outline: 2px solid var(--face);
  box-shadow: inset 1px 1px 0 var(--light), inset -1px -1px 0 var(--shadow);
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
}
@media (min-width: 700px) and (min-height: 560px) {
  .win.main { inset: 12px; }
}
.titlebar {
  display: flex;
  align-items: stretch;
  height: 22px;
  flex: none;
  background: var(--title);
  color: var(--title-text);
  border-bottom: 1px solid var(--dark);
  user-select: none;
}
.titlebar .ttl {
  flex: 1;
  text-align: center;
  line-height: 21px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
}
.tbtn {
  flex: none;
  width: 22px;
  border: 0;
  padding: 0;
  background: var(--face);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: inset 1px 1px 0 var(--light), inset -1px -1px 0 var(--shadow), inset 0 0 0 1px var(--face);
  font-size: 10px;
  line-height: 1;
}
.tbtn.sys { border-right: 1px solid var(--dark); }
.tbtn.sys::before {
  content: "";
  width: 13px;
  height: 4px;
  background: var(--light);
  border: 1px solid var(--dark);
  box-shadow: 1px 1px 0 var(--shadow);
}
.tbtn.max { border-left: 1px solid var(--dark); }
.tbtn:active { box-shadow: inset 1px 1px 0 var(--shadow); }

/* ---------- menu bar ---------- */
.menubar {
  display: flex;
  flex: none;
  background: var(--light);
  border-bottom: 1px solid var(--dark);
  user-select: none;
  position: relative;
  z-index: 50;
  flex-wrap: wrap;
}
.menubar .mtop {
  padding: 2px 8px;
  cursor: default;
  position: relative;
  font-weight: normal;
}
.menubar .mtop.open { background: var(--menu-hi); color: #fff; }
.menubar .mright { margin-left: auto; padding: 2px 8px; font-weight: normal; white-space: nowrap; }
.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 190px;
  background: var(--light);
  color: #000;
  border: 1px solid var(--dark);
  box-shadow: 2px 2px 0 rgba(0,0,0,.5);
  padding: 1px 0;
  z-index: 60;
  white-space: nowrap;
}
.dropdown .mi {
  display: flex;
  gap: 24px;
  padding: 3px 12px 3px 20px;
  position: relative;
}
.dropdown .mi .k { margin-left: auto; }
.dropdown .mi.checked::before { content: "\2713"; position: absolute; left: 6px; }
.dropdown .mi:hover:not(.disabled), .dropdown .mi.hot:not(.disabled) { background: var(--menu-hi); color: #fff; }
.dropdown .mi.disabled { color: var(--shadow); }
.dropdown .sep { height: 0; border-top: 1px solid var(--dark); margin: 3px 1px; }
.u { text-decoration: underline; }

/* ---------- client / status ---------- */
.client {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: var(--face);
}
.statusbar {
  flex: none;
  display: flex;
  gap: 4px;
  padding: 2px;
  font-weight: normal;
  border-top: 1px solid var(--shadow);
}
.statusbar > span {
  flex: 1;
  padding: 1px 6px;
  box-shadow: inset 1px 1px 0 var(--shadow), inset -1px -1px 0 var(--light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
canvas.pixel { image-rendering: pixelated; image-rendering: crisp-edges; }
.center-fit { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

/* ---------- buttons & bevels ---------- */
.btn {
  min-width: 72px;
  padding: 4px 10px;
  background: var(--face);
  border: 1px solid var(--dark);
  border-radius: 2px;
  box-shadow: inset 1px 1px 0 var(--light), inset 2px 2px 0 var(--light), inset -1px -1px 0 var(--shadow), inset -2px -2px 0 var(--shadow);
  cursor: pointer;
  color: #000;
}
.btn:active:not(:disabled), .btn.down {
  box-shadow: inset 1px 1px 0 var(--shadow), inset 2px 2px 0 var(--shadow);
  padding: 5px 9px 3px 11px;
}
.btn:disabled { color: var(--shadow); cursor: default; text-shadow: 1px 1px 0 var(--light); }
.btn.default { border-width: 2px; }
.btn:focus-visible { outline: 1px dotted #000; outline-offset: -5px; }
.sunken { box-shadow: inset 1px 1px 0 var(--shadow), inset -1px -1px 0 var(--light); background: #fff; }
.raised { box-shadow: inset 1px 1px 0 var(--light), inset -1px -1px 0 var(--shadow); }
.lcd {
  background: #000;
  color: #f00;
  font: bold 18px/1 "Courier New", monospace;
  padding: 2px 4px;
  box-shadow: inset 1px 1px 0 var(--shadow), inset -1px -1px 0 var(--light);
  text-align: right;
}

/* ---------- dialogs ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.dlg {
  position: relative;
  inset: auto;
  margin: 0;
  max-width: min(520px, 100%);
  min-width: min(280px, 100%);
  max-height: 100%;
  box-shadow: inset 1px 1px 0 var(--light), inset -1px -1px 0 var(--shadow), 4px 4px 0 rgba(0,0,0,.45);
}
.dlg .titlebar .ttl { text-align: center; }
.dlg .body {
  padding: 14px 16px 6px;
  font-weight: normal;
  overflow: auto;
  min-height: 0;
}
.dlg .body p { margin: 0 0 10px; }
.dlg .body h3 { margin: 12px 0 4px; font-size: 13px; }
.dlg .body ul { margin: 0 0 10px; padding-left: 20px; }
.dlg .body li { margin-bottom: 3px; }
.dlg .body table { border-collapse: collapse; width: 100%; }
.dlg .body td, .dlg .body th { padding: 2px 6px; text-align: left; }
.dlg .body td.n, .dlg .body th.n { text-align: right; }
.dlg .buttons { display: flex; gap: 8px; justify-content: center; padding: 8px 12px 12px; flex-wrap: wrap; flex: none; }
.dlg input[type=text], .dlg input[type=number], .dlg select {
  padding: 2px 4px;
  border: 0;
  box-shadow: inset 1px 1px 0 var(--shadow), inset 2px 2px 0 #000, inset -1px -1px 0 var(--light);
  background: #fff;
  font-weight: normal;
  width: 100%;
}
.dlg label { display: block; margin: 4px 0; }
.dlg label.inline { display: flex; align-items: center; gap: 6px; }
.dlg fieldset { border: 1px solid var(--shadow); box-shadow: 1px 1px 0 var(--light); margin: 0 0 10px; padding: 6px 10px; }
.dlg legend { padding: 0 4px; }

/* ---------- touch pad ---------- */
.touchpad {
  position: absolute;
  bottom: 8px;
  z-index: 40;
  display: none;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 4px;
  opacity: .8;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.touchpad.left { left: 8px; }
.touchpad.right { right: 8px; }
.touchpad .tp {
  background: var(--face);
  border: 1px solid #000;
  box-shadow: inset 2px 2px 0 var(--light), inset -2px -2px 0 var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #000;
}
.touchpad .tp.on { box-shadow: inset 2px 2px 0 var(--shadow); background: #a8a8a8; }
.touchpad .tp.blank { visibility: hidden; }
.touchpad.actions { grid-template-columns: repeat(1, 78px); grid-template-rows: none; grid-auto-rows: 52px; }
.touchpad.actions .tp { font-size: 14px; }
@media (pointer: coarse) {
  .touchpad.auto { display: grid; }
}
.touchpad.force { display: grid; }
@media (pointer: coarse) {
  .client.has-pad .center-fit { bottom: 176px; align-items: flex-end; }
}
