/* Marble Drop web shell — a bronze workbench around Leonardo's vellum.
   Palette: verdigris surround, brass fittings, sepia ink on vellum sheets. */
:root {
  --surround: #1b2622;
  --surround-2: #22312c;
  --verdigris: #4f8a76;
  --brass: #b48a3c;
  --brass-hi: #e0bd72;
  --vellum: #d8c69c;
  --vellum-hi: #e6d8b4;
  --ink: #34210f;
  --ink-soft: #6a4d2e;
  --sanguine: #8a3420;
  --bar-h: 44px;
  --serif: "IM Fell English", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Alegreya Sans", "Gill Sans", "Trebuchet MS", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--surround);
  background-image: radial-gradient(120% 90% at 50% 40%, var(--surround-2) 0%, var(--surround) 70%);
  color: var(--vellum);
  font: 16px/1.4 var(--sans);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 2px; }

/* ---------------------------------------------------------------- top bar */
.bar {
  position: fixed; inset: 0 0 auto 0; height: var(--bar-h);
  padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--brass) 55%, transparent);
  background: linear-gradient(#26342f, #1d2925);
  z-index: 10;
}
.menus { display: flex; height: 100%; }
.menu { position: relative; height: 100%; }
.menu > button {
  height: 100%; padding: 0 12px; background: none; border: 0; cursor: pointer;
  color: var(--vellum); letter-spacing: .01em;
}
.menu > button:hover, .menu.open > button { color: var(--brass-hi); background: rgba(255, 255, 255, .04); }
.menu-panel {
  position: absolute; top: calc(100% + 1px); left: 0; min-width: 230px;
  padding: 6px 0; margin: 0; list-style: none;
  background: var(--vellum); color: var(--ink);
  border: 1px solid var(--brass); border-top: 0;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .45);
  display: none;
}
.menu.open .menu-panel { display: block; }
.menu-panel button {
  display: flex; justify-content: space-between; gap: 24px; width: 100%;
  padding: 7px 16px; background: none; border: 0; text-align: left; cursor: pointer; color: var(--ink);
}
.menu-panel button:hover, .menu-panel button:focus-visible { background: var(--vellum-hi); outline: none; }
.menu-panel button[aria-checked="true"]::before { content: "●"; margin-right: -14px; position: relative; left: -12px; color: var(--sanguine); font-size: 9px; align-self: center; }
.menu-panel button:disabled { color: color-mix(in srgb, var(--ink) 40%, transparent); cursor: default; }
.menu-panel kbd { font: inherit; color: var(--ink-soft); }
.menu-panel hr { border: 0; border-top: 1px solid color-mix(in srgb, var(--ink) 25%, transparent); margin: 5px 10px; }

.status { flex: 1; min-width: 0; text-align: center; }
.puzzle {
  font-family: var(--serif); font-size: 19px; color: var(--brass-hi);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
}
.quick { display: flex; align-items: center; gap: 4px; }
.qbtn {
  width: 32px; height: 30px; border-radius: 15px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--brass) 70%, transparent);
  background: rgba(0, 0, 0, .18); color: var(--brass-hi); line-height: 1;
}
.qbtn.wide { width: 38px; }
.qbtn[aria-pressed="true"] { background: var(--brass); color: var(--surround); }
.qbtn.off { color: color-mix(in srgb, var(--vellum) 35%, transparent); text-decoration: line-through; }
.speed { min-width: 18px; text-align: center; font-variant-numeric: tabular-nums; color: var(--vellum); }

/* ---------------------------------------------------------------- board */
.stage {
  position: fixed; inset: var(--bar-h) 0 0 0;
  display: grid; place-items: center;
  padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
}
#board {
  display: block; touch-action: none; user-select: none; -webkit-user-select: none;
  box-shadow: 0 0 0 1px rgba(180, 138, 60, .45), 0 18px 50px rgba(0, 0, 0, .55);
  image-rendering: auto;
}
#board.mouse { cursor: none; }
#board.pixelated { image-rendering: pixelated; }

.paused {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 14px; text-align: center;
  background: rgba(20, 28, 25, .55); backdrop-filter: blur(2px);
}
.paused p { margin: 0; font: 34px var(--serif); color: var(--vellum-hi); }
.paused[hidden], .loading[hidden] { display: none; }

.loading {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 6px;
  background: var(--surround);
}
.loading p { margin: 0; color: color-mix(in srgb, var(--vellum) 70%, transparent); }
/* Leonardo wrote in mirror script: the title arrives reversed and turns to face the reader once the codex is open */
.mirror { margin: 0; font: 400 clamp(44px, 9vw, 92px)/1 var(--serif); color: var(--brass-hi); }
.mirror span { display: inline-block; transform: scaleX(-1); transition: transform 900ms cubic-bezier(.6, 0, .2, 1); }
.loading.ready .mirror span { transform: scaleX(1); }
@media (prefers-reduced-motion: reduce) { .mirror span { transition: none; } }

/* ---------------------------------------------------------------- vellum sheets (dialogs) */
.btn {
  padding: 8px 18px; border-radius: 3px; cursor: pointer;
  border: 1px solid var(--brass); background: var(--brass); color: #1f150a; font-weight: 500;
}
.btn.quiet { background: transparent; color: var(--ink); border-color: color-mix(in srgb, var(--ink) 45%, transparent); }
.btn.danger { background: var(--sanguine); border-color: var(--sanguine); color: var(--vellum-hi); }
.sheet {
  padding: 0; border: 1px solid var(--brass); max-width: min(620px, calc(100vw - 24px)); width: 100%;
  background: var(--vellum); color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
}
.sheet::backdrop { background: rgba(10, 16, 14, .6); }
.sheet-inner { display: flex; flex-direction: column; max-height: min(86vh, 760px); }
.sheet h2 {
  margin: 0; padding: 18px 22px 10px; font: 400 28px/1.15 var(--serif); color: var(--ink);
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 20%, transparent);
}
.sheet-body { padding: 14px 22px; overflow: auto; font-size: 16px; line-height: 1.5; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 22px 18px; flex-wrap: wrap; }
.sheet label { display: block; margin: 6px 0; }
.sheet input[type=text] {
  width: 100%; padding: 8px 10px; font: inherit; color: var(--ink);
  background: var(--vellum-hi); border: 1px solid color-mix(in srgb, var(--ink) 40%, transparent); border-radius: 2px;
}
.sheet select { font: inherit; padding: 6px 8px; background: var(--vellum-hi); color: var(--ink); border: 1px solid color-mix(in srgb, var(--ink) 40%, transparent); }
.note { color: var(--ink-soft); font-size: 14px; }
.error { color: var(--sanguine); }

.plist { list-style: none; margin: 0; padding: 0; }
.plist li + li { border-top: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); }
.plist button {
  display: grid; grid-template-columns: 34px 2.2em 1fr auto; align-items: center; gap: 10px; width: 100%;
  padding: 6px 4px; background: none; border: 0; text-align: left; cursor: pointer; color: var(--ink);
}
.plist button:hover:not(:disabled), .plist button:focus-visible { background: var(--vellum-hi); }
.plist button:disabled { opacity: .45; cursor: default; }
.plist img { width: 32px; height: 32px; image-rendering: pixelated; }
.plist .num { font-variant-numeric: tabular-nums; color: var(--ink-soft); text-align: right; }
.plist .nm { font-family: var(--serif); font-size: 18px; }
.plist .st { color: var(--ink-soft); font-size: 14px; }
.plist .current { box-shadow: inset 3px 0 var(--verdigris); }
.sorts { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.sorts label { display: inline-flex; gap: 6px; align-items: center; margin: 0; }

table.scores { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.scores td, table.scores th { padding: 4px 6px; text-align: left; }
table.scores th { font-weight: 500; color: var(--ink-soft); border-bottom: 1px solid color-mix(in srgb, var(--ink) 25%, transparent); }
table.scores td:last-child, table.scores th:last-child { text-align: right; }

.help { font-family: var(--serif); font-size: 18px; line-height: 1.55; max-width: 64ch; }
.help p { margin: 0 0 .55em; white-space: pre-wrap; tab-size: 8; }
.help .h { font-size: 24px; }
.help a { color: #2d5f50; text-decoration: underline; text-decoration-thickness: 1px; cursor: pointer; }
.help img { max-width: 100%; }
.help-nav { display: flex; gap: 10px; margin-bottom: 8px; font-family: var(--sans); }
.credits { text-align: center; font-family: var(--serif); }
.credits .c4 { font-size: 22px; margin-top: .6em; }
.credits .c2 { color: var(--ink-soft); font-style: italic; margin-top: .5em; }
.credits p { margin: 0; }
.slider { width: 100%; accent-color: var(--verdigris); }
.radios { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px 12px; }
.radios label { display: flex; gap: 8px; align-items: center; margin: 0; }

/* ---------------------------------------------------------------- small screens */
.rotate { display: none; }
@media (orientation: portrait) and (max-width: 600px) {
  .stage { align-content: center; gap: 14px; grid-auto-flow: row; }
  .rotate { display: block; margin: 0; text-align: center; color: color-mix(in srgb, var(--vellum) 70%, transparent); font-size: 14px; }
}
@media (max-width: 720px) {
  :root { --bar-h: 48px; }
  .menu > button { padding: 0 9px; }
  .puzzle { font-size: 16px; }
  .quick .speed, #btnSlower, #btnFaster { display: none; }
}
@media (max-width: 480px) {
  .status { display: none; }
  .menus { flex: 1; }
}
@media (max-height: 460px) and (orientation: landscape) {
  :root { --bar-h: 38px; }
  .stage { padding: 2px; }
}
