/* All sizes are in em, derived from --k (scale factor set by game.js;
   1 = the base layout with 24px blocks). Borders stay at fixed pixels. */
:root { --k: 1; }

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  min-height: 100vh;
  background: #3a6ea5;
  font-family: "MS Sans Serif", "Microsoft Sans Serif", Tahoma, Arial, sans-serif;
  font-size: calc(13px * var(--k));
  color: #000;
  display: flex;
  padding: 8px; /* fixed; game.js subtracts this when fitting */
}

.window {
  margin: auto; /* centers, but never pushes content off-screen when too small */
  background: #c0c0c0;
  border: 2px solid;
  border-color: #fff #000 #000 #fff;
  box-shadow: inset -1px -1px #808080, inset 1px 1px #dfdfdf;
  padding: 2px;
  user-select: none;
}

.titlebar {
  background: #000080;
  color: #fff;
  font-weight: bold;
  padding: 0.23em 0.46em;
  text-align: center;
  position: relative;
}
/* Application icon in the top-left corner; the title stays centered. */
.app-icon {
  position: absolute;
  left: 0.23em;
  top: 50%;
  transform: translateY(-50%);
  width: 1.23em;
  height: 1.23em;
  display: block;
}

.menubar { display: flex; border-bottom: 1px solid #808080; }
.menu { position: relative; }
.menu-title, .menu-items button {
  font: inherit;
  background: none;
  border: none;
  padding: 0.23em 0.6em;
  cursor: default;
  color: #000;
}
.menu.open .menu-title { background: #000080; color: #fff; }
.menu-items {
  display: none;
  position: absolute;
  left: 0;
  top: 100%;
  z-index: 10;
  min-width: 11.5em;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #fff #000 #000 #fff;
  padding: 2px;
}
.menu.open .menu-items { display: block; }
.menu-items button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  padding: 0.23em 0.92em;
}
.menu-items button span { margin-left: 1.85em; }
.menu-items button { position: relative; }
.menu-items button.checked::before { content: "\2713"; position: absolute; left: 0.15em; }
.menu-items button:hover { background: #000080; color: #fff; }
.menu-items hr { border: none; border-top: 1px solid #808080; border-bottom: 1px solid #fff; margin: 0.23em 1px; }

.client { display: flex; gap: 0.92em; padding: 0.77em; align-items: flex-start; }

.well {
  position: relative;
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
  line-height: 0;
}
#board { display: block; background: #000; cursor: none; }

.message {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  background: #c0c0c0;
  border: 2px solid;
  border-color: #fff #000 #000 #fff;
  padding: 0.77em 1.23em;
  font-weight: bold;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
}
.message:empty { display: none; }

/* Fixed width so a growing score never changes the layout. */
.side { display: flex; flex-direction: column; gap: 0.6em; width: 10em; }
fieldset {
  border: 1px solid #808080;
  box-shadow: 1px 1px #fff, inset 1px 1px #fff;
  margin: 0;
  padding: 0.3em 0.6em 0.6em;
  min-width: 0;
}
/* The 3D highlight is a box-shadow, which (unlike the border) the legend does
   not interrupt; paint the caption on the window color so it hides the lines. */
legend { padding: 0 0.23em; background: #c0c0c0; position: relative; }
#next { display: block; background: #000; margin: 0 auto; border: 1px solid #808080; }
.value {
  background: #fff;
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
  padding: 0.15em 0.46em;
  text-align: right;
  font-family: "Courier New", monospace;
  font-weight: bold;
  overflow-wrap: anywhere; /* very large scores wrap rather than get cut off */
}

dialog {
  padding: 2px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #fff #000 #000 #fff;
  min-width: 21.5em;
  max-width: calc(100vw - 16px);
  font-size: inherit;
}
dialog::backdrop { background: transparent; }
.dlg-body { padding: 0.92em; }
.dlg-body p { margin: 0 0 0.77em; }
#name-input {
  width: 100%;
  font: inherit;
  padding: 0.23em;
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
}
.buttons { display: flex; justify-content: center; gap: 0.6em; margin-top: 0.92em; }
.buttons button {
  font: inherit;
  min-width: 6.15em;
  padding: 0.3em 0.77em;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #fff #000 #000 #fff;
  box-shadow: inset -1px -1px #808080;
}
.buttons button:active { border-color: #000 #fff #fff #000; box-shadow: inset 1px 1px #808080; }

table { border-collapse: collapse; width: 100%; }
th, td { padding: 0.15em 0.6em; text-align: left; white-space: nowrap; }
th { border-bottom: 1px solid #808080; }
#scores-body td:nth-child(n+3), #scores-dialog th:nth-child(n+3) { text-align: right; }
#scores-body td:first-child { text-align: right; }
#scores-body tr.highlight { background: #000080; color: #fff; }
#scores-body td.empty { text-align: center; color: #404040; }
.keys td:first-child { font-weight: bold; }
