/* Bloxorz - a dark void with a warm rust glow, warm sand type, and the board floating in it.
   The palette follows the 2007 original: near-black ground, orange-brown bloom, sand-coloured
   tiles and a rusty block. */

:root {
  --void: #0c0a09;
  --glow-a: #6b3a16;
  --glow-b: #2a1608;
  --sand: #e8d5b4;
  --sand-dim: #b8a78c;
  --rust: #d3762f;
  --rust-deep: #a8501f;
  --line: #2b2320;
  --panel: #14100e;
  --panel-2: #1b1613;
  --ok: #7fc36a;
  --bad: #d9603f;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }
body {
  background: var(--void);
  color: var(--sand);
  font: 15px/1.6 "Eurostile", "Square721 BT", "Bahnschrift", "DIN Alternate", "Avenir Next Condensed", "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  overflow-x: hidden;
}
.void {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(90vw 70vh at 8% -10%, rgba(146, 78, 30, 0.42), rgba(12, 10, 9, 0) 62%),
    radial-gradient(70vw 60vh at 96% 6%, rgba(110, 58, 22, 0.30), rgba(12, 10, 9, 0) 60%),
    radial-gradient(120vw 90vh at 50% 118%, rgba(70, 36, 14, 0.35), rgba(12, 10, 9, 0) 70%),
    var(--void);
}

.page { max-width: 1000px; margin: 0 auto; padding: 26px 16px 8px; }
.page-head { text-align: center; margin-bottom: 18px; }
.eyebrow { margin: 0 0 4px; letter-spacing: .22em; text-transform: uppercase; font-size: 11px; color: var(--rust); }
h1 {
  margin: 0; font-size: clamp(34px, 8vw, 62px); letter-spacing: .1em; font-weight: 700;
  color: #fff; text-shadow: 0 0 26px rgba(211, 118, 47, .55), 0 0 60px rgba(168, 80, 31, .35);
}
.lede { margin: 8px auto 0; max-width: 62ch; color: var(--sand-dim); font-size: 14px; }

.stagewrap { position: relative; margin: 10px auto 0; max-width: 980px; }
#board {
  display: block; width: 100%; height: auto; aspect-ratio: 11 / 6;
  touch-action: none; outline: none;
}
.passcode {
  position: absolute; top: 6px; right: 10px; text-align: right; pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.passcode-label { display: block; font-size: 9px; letter-spacing: .28em; text-transform: uppercase; color: #8a6a4b; }
.digits {
  display: block; font-size: clamp(17px, 3.4vw, 26px); letter-spacing: .22em; color: #ffd9a8;
  text-shadow: 0 0 12px rgba(255, 160, 60, .75), 0 0 30px rgba(200, 100, 30, .4);
}
.glfail {
  position: absolute; inset: 12% 8%; margin: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; background: rgba(20, 16, 14, .92); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px; color: var(--sand);
}
.banner {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%);
  padding: 10px 22px; border-radius: 999px; pointer-events: none;
  background: rgba(12, 10, 9, .78); border: 1px solid rgba(211, 118, 47, .5);
  letter-spacing: .12em; text-transform: uppercase; font-size: 13px; color: #ffd9a8;
  text-shadow: 0 0 14px rgba(255, 160, 60, .6);
}

.dpad { position: absolute; right: 10px; bottom: 8px; display: none; width: 132px; height: 132px; }
.dpad-btn {
  position: absolute; width: 42px; height: 42px; border-radius: 9px; font-size: 15px; line-height: 1;
  background: rgba(30, 24, 20, .82); color: var(--sand); border: 1px solid rgba(211, 118, 47, .45);
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.dpad-btn:active { background: rgba(211, 118, 47, .35); }
.dpad-u { left: 45px; top: 0; }
.dpad-l { left: 0; top: 45px; }
.dpad-r { left: 90px; top: 45px; }
.dpad-d { left: 45px; top: 90px; }
.dpad-s { left: 45px; top: 45px; font-size: 9px; letter-spacing: .06em; }

.statsbar {
  display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; align-items: baseline;
  margin: 10px auto 0; padding: 8px 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #9c8a72;
}
.statsbar b { color: var(--sand); font-size: 14px; font-variant-numeric: tabular-nums; }
.statsbar .of { color: #6d5f4e; }
.stage-name { text-transform: none; letter-spacing: .02em; color: var(--rust); }

.controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0 6px; }
.btn {
  font: inherit; font-size: 13px; letter-spacing: .06em; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  background: #1c1613; color: var(--sand); border: 1px solid var(--line);
}
.btn:hover { border-color: rgba(211, 118, 47, .6); color: #fff; }
.btn:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }
.btn.primary { background: var(--rust-deep); border-color: var(--rust); color: #fff; }
.btn.danger { border-color: rgba(217, 96, 63, .5); color: #e79b84; }

.panel { max-width: 1000px; margin: 26px auto 0; padding: 0 16px; }
.panel-inner {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 12px; padding: 22px 22px 8px;
}
.panel h2 { margin: 0 0 12px; font-size: 22px; letter-spacing: .08em; color: #fff; }
.panel h3 { margin: 22px 0 6px; font-size: 14px; letter-spacing: .14em; text-transform: uppercase; color: var(--rust); }
.panel p { margin: 0 0 10px; color: #cdbda3; font-size: 14px; }
.panel b { color: var(--sand); }
.panel a { color: var(--rust); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.keys { list-style: none; margin: 0; padding: 0; font-size: 14px; color: #cdbda3; }
.keys li { margin: 0 0 6px; }
kbd {
  display: inline-block; min-width: 22px; text-align: center; padding: 2px 6px; margin-right: 2px;
  border-radius: 5px; background: #241d19; border: 1px solid #3a2f28; border-bottom-width: 2px;
  font: inherit; font-size: 12px; color: var(--sand);
}
.added { color: #8d7a63; font-size: 12px; font-style: italic; }
.legend { display: block; width: 100%; height: auto; aspect-ratio: 19 / 5; background: transparent; }
.legend-key { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0 0; font-size: 13px; }
.legend-key dt { color: var(--rust); white-space: nowrap; }
.legend-key dd { margin: 0; color: #cdbda3; }
.credit { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: #9c8a72; }
code { background: #241d19; border: 1px solid #34291f; border-radius: 4px; padding: 1px 5px; font-size: 12px; }

.codes { border-collapse: collapse; margin: 6px 0 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.codes caption { text-align: left; color: #8d7a63; font-size: 12px; padding-bottom: 6px; }
.codes td { padding: 2px 12px 2px 0; color: #cdbda3; }
.codes td.n { color: #8d7a63; text-align: right; }

.foot { max-width: 1000px; margin: 30px auto 0; padding: 18px 16px 34px; border-top: 1px solid var(--line); text-align: center; color: #8d7a63; font-size: 12px; }
.foot a { color: #b58256; }
.foot p { margin: 4px 0; }

.modal {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  padding: 18px; background: rgba(6, 5, 4, .78); backdrop-filter: blur(2px);
}
.modal-card {
  width: min(760px, 100%); max-height: 88vh; overflow: auto; padding: 22px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 12px;
}
.modal-card h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: .08em; color: #fff; }
.modal-note { margin: 0 0 14px; color: #9c8a72; font-size: 13px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-close { min-width: 92px; }

.stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.stage-cell {
  font: inherit; font-size: 12px; padding: 8px 4px; border-radius: 8px; cursor: pointer; text-align: center;
  background: #1c1613; color: var(--sand-dim); border: 1px solid var(--line); line-height: 1.25;
}
.stage-cell .num { display: block; font-size: 16px; color: var(--sand); font-variant-numeric: tabular-nums; }
.stage-cell.done { border-color: rgba(127, 195, 106, .45); color: var(--ok); }
.stage-cell.done .num { color: var(--ok); }
.stage-cell.locked { opacity: .38; cursor: not-allowed; }
.stage-cell.current { border-color: var(--rust); box-shadow: 0 0 0 1px rgba(211, 118, 47, .5) inset; }

.codeform { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; }
.codeform label { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #9c8a72; }
.codeform input {
  font: inherit; font-size: 18px; letter-spacing: .3em; width: 8em; padding: 6px 10px;
  background: #120e0c; color: #ffd9a8; border: 1px solid var(--line); border-radius: 8px;
}
.codemsg { font-size: 13px; color: var(--bad); }
.codemsg.ok { color: var(--ok); }

.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tot { background: #191411; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.tot b { display: block; font-size: 21px; color: var(--sand); font-variant-numeric: tabular-nums; }
.tot span { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #8d7a63; }
.table-wrap { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 9px; }
table.stats { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.stats th, table.stats td { padding: 5px 10px; text-align: left; border-bottom: 1px solid #221c18; }
table.stats th { position: sticky; top: 0; background: #1b1613; color: #9c8a72; font-weight: 400; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
table.stats td { color: #cdbda3; }
table.stats tr.done td:first-child { color: var(--ok); }

.opts { list-style: none; margin: 0; padding: 0; }
.opts li { border-bottom: 1px solid #221c18; }
.opts label { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start; padding: 10px 2px; cursor: pointer; }
.opts input { margin-top: 4px; accent-color: var(--rust); width: 16px; height: 16px; }
.opts span { color: var(--sand); font-size: 14px; }
.opts small { grid-column: 2; color: #8d7a63; font-size: 12px; }

@media (max-width: 720px) {
  .cols { grid-template-columns: 1fr; }
  /* On a phone the board is only ~160-200px tall, so an overlaid pad hid a third of it and the
     passcode: put the pad in the flow, centred under the board. */
  .dpad { display: block; position: relative; right: auto; bottom: auto; margin: 10px auto 0; }
  .page { padding-top: 16px; }
  .lede { font-size: 13px; }
}
@media (hover: none) and (pointer: coarse) { .dpad { display: block; } }
