/* THE GALLERY OF THE CLOSE — UI chrome. Brand vars from the Bogen sales-machine page. */
:root {
  --navy: #1a3e5c;
  --cyan: #00a8e1;
  --white: #ffffff;
  --light: #f4f4f4;
  --gray: #333;
  --brass: #b08d3c;
  --brass-bright: #e8c56a;
  --cream: #efe9dc;
  --ink: #14202b;
  --velvet: #6d1a2b;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: #0b0e12; }
body { font-family: 'Montserrat', Helvetica, Arial, sans-serif; color: var(--white); }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hidden { display: none !important; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 35%, #1d2a38 0%, #0b0e12 75%);
  padding: 24px; overflow-y: auto;
}

.title-card { max-width: 560px; text-align: center; }
.title-kicker {
  font-size: 12px; letter-spacing: 4px; text-transform: uppercase;
  color: var(--cyan); font-weight: 700; margin-bottom: 18px;
}
.title-main {
  font-family: 'Playfair Display', Georgia, serif; font-weight: 700;
  font-size: clamp(40px, 9vw, 68px); line-height: 1.05; color: var(--cream);
  margin-bottom: 14px;
}
.title-sub {
  font-family: 'Playfair Display', Georgia, serif; font-style: italic;
  font-size: clamp(17px, 3.5vw, 21px); color: #b9c4cf; margin-bottom: 18px; line-height: 1.5;
}
.title-sub .brass { color: var(--brass-bright); font-style: normal; }
.title-body { font-size: 14px; line-height: 1.65; color: #93a1ae; margin: 0 auto 26px; max-width: 440px; }

#nameForm { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#playerName {
  font-family: inherit; font-size: 16px; padding: 13px 16px; border-radius: 8px;
  border: 1px solid #3c4c5c; background: #10161d; color: var(--white);
  width: min(240px, 60vw); outline: none;
}
#playerName:focus { border-color: var(--cyan); }

.btn-primary {
  font-family: inherit; font-weight: 700; font-size: 15px; letter-spacing: 0.5px;
  color: var(--white); background: var(--cyan); border: none; border-radius: 8px;
  padding: 13px 26px; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0, 168, 225, 0.35); }
.btn-ghost {
  font-family: inherit; font-size: 13px; font-weight: 600; color: #b9c4cf;
  background: transparent; border: 1px solid #3c4c5c; border-radius: 8px;
  padding: 10px 18px; cursor: pointer; margin-top: 14px;
}
.btn-ghost:hover { border-color: var(--cyan); color: var(--white); }

.best-times { margin-top: 26px; font-size: 12px; color: #6d7d8c; line-height: 1.8; }
.best-times strong { color: var(--brass-bright); font-weight: 700; }
.best-times .bt-title { letter-spacing: 3px; text-transform: uppercase; font-size: 10px; margin-bottom: 4px; }

/* ---------- loading ---------- */
.load-card { text-align: center; width: min(360px, 80vw); }
.load-title { font-family: 'Playfair Display', Georgia, serif; font-size: 22px; color: var(--cream); margin-bottom: 20px; }
.load-track { height: 4px; background: #202b36; border-radius: 2px; overflow: hidden; }
.load-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--brass), var(--brass-bright)); transition: width 0.25s; }
.load-hint { margin-top: 14px; font-size: 12px; color: #6d7d8c; font-style: italic; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }

.hud-clock {
  display: flex; flex-direction: column; align-items: center;
  background: linear-gradient(180deg, #2a2318, #171208);
  border: 1px solid var(--brass); border-radius: 10px;
  padding: 6px 14px; box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}
.clock-face {
  font-weight: 800; font-size: 24px; color: var(--brass-bright);
  font-variant-numeric: tabular-nums; line-height: 1;
  text-shadow: 0 0 12px rgba(232, 197, 106, 0.35);
}
.hud-clock.low .clock-face { color: #e06552; text-shadow: 0 0 12px rgba(224, 101, 82, 0.5); }
.hud-clock.burn { animation: clockBurn 0.6s; }
@keyframes clockBurn {
  0%, 100% { transform: none; }
  20% { transform: translateX(-3px); } 40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); } 80% { transform: translateX(2px); }
}
.clock-label { font-size: 8px; letter-spacing: 2.5px; color: var(--brass); font-weight: 700; margin-top: 2px; }

.hud-keys { display: flex; gap: 5px; }
.key-slot {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid #3c4c5c; background: rgba(10, 14, 18, 0.55);
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  filter: grayscale(1) brightness(0.45); transition: filter 0.4s, border-color 0.4s;
}
.key-slot.earned { filter: none; border-color: var(--brass-bright); box-shadow: 0 0 10px rgba(232, 197, 106, 0.4); }
.key-slot.shine { animation: keyShine 1.2s; }
@keyframes keyShine {
  0% { transform: scale(1); } 30% { transform: scale(1.7) rotate(-12deg); }
  60% { transform: scale(1.25) rotate(6deg); } 100% { transform: scale(1); }
}

.hud-buttons { display: flex; gap: 8px; }
@media (max-width: 460px) {
  .key-slot { width: 20px; height: 20px; font-size: 10px; }
  .hud-keys { gap: 3px; }
  .hud-btn { width: 32px; height: 32px; font-size: 13px; }
  .clock-face { font-size: 19px; }
  .hud-clock { padding: 5px 10px; }
}
.hud-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid #3c4c5c;
  background: rgba(10, 14, 18, 0.55); color: var(--white); font-size: 16px; cursor: pointer;
}
.hud-btn:hover { border-color: var(--cyan); }

#toast {
  position: fixed; top: 74px; left: 50%; transform: translateX(-50%);
  z-index: 35; background: rgba(20, 32, 43, 0.92); border: 1px solid var(--brass);
  color: var(--cream); font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: 8px; max-width: 86vw; text-align: center;
}
#tapHint {
  position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  z-index: 25; color: #b9c4cf; font-size: 12px; letter-spacing: 0.4px;
  background: rgba(10, 14, 18, 0.6); padding: 8px 16px; border-radius: 20px;
  pointer-events: none;
}

/* ---------- placard / puzzle sheet ---------- */
#placard {
  position: fixed; z-index: 50;
  left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center;
  pointer-events: none;
}
.placard-inner {
  pointer-events: auto; position: relative;
  width: 100%; max-height: 72vh; overflow-y: auto;
  background: var(--cream); color: var(--ink);
  border-radius: 16px 16px 0 0; padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
  animation: sheetUp 0.35s ease-out;
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 900px) {
  #placard { left: auto; right: 28px; bottom: 28px; top: 90px; align-items: flex-end; }
  .placard-inner { width: 430px; max-height: 100%; border-radius: 14px; }
}
.placard-close {
  position: absolute; top: 10px; right: 12px; width: 34px; height: 34px;
  border: none; border-radius: 50%; background: rgba(20, 32, 43, 0.08);
  color: var(--ink); font-size: 20px; cursor: pointer; line-height: 1;
}
.placard-kicker { font-size: 10px; letter-spacing: 3px; text-transform: uppercase; color: var(--brass); font-weight: 700; margin-bottom: 6px; }
.placard-title { font-family: 'Playfair Display', Georgia, serif; font-size: 24px; font-weight: 700; color: var(--navy); line-height: 1.15; }
.placard-artist { font-family: 'Playfair Display', Georgia, serif; font-style: italic; font-size: 14px; color: #5a6a76; margin: 4px 0 14px; }
.placard-lesson { font-size: 14px; line-height: 1.65; color: var(--gray); margin-bottom: 8px; }
.placard-lesson strong { color: var(--navy); }
.placard-credit { font-size: 10px; color: #97a3ad; margin-top: 14px; line-height: 1.5; }
.placard-divider { border: none; border-top: 1px solid rgba(26, 62, 92, 0.15); margin: 16px 0; }

.puzzle-q { font-size: 15px; font-weight: 700; color: var(--navy); line-height: 1.5; margin-bottom: 14px; }
.puzzle-note { font-size: 12px; color: #5a6a76; line-height: 1.5; margin-bottom: 12px; }

.opt {
  display: block; width: 100%; text-align: left; font-family: inherit;
  font-size: 14px; line-height: 1.5; color: var(--ink);
  background: var(--white); border: 2px solid rgba(26, 62, 92, 0.18);
  border-radius: 10px; padding: 13px 14px; margin-bottom: 10px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.opt:hover { border-color: var(--cyan); }
.opt.sel { border-color: var(--navy); background: #eaf6fc; }
.opt.right { border-color: #2e9e5b; background: #e7f6ec; }
.opt.wrong { border-color: #cc4b3d; background: #fbe9e6; }
.opt:disabled { cursor: default; opacity: 0.85; }

.check-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.btn-check {
  font-family: inherit; font-weight: 700; font-size: 14px; color: var(--white);
  background: var(--navy); border: none; border-radius: 8px; padding: 12px 24px; cursor: pointer;
}
.btn-check:hover { background: #234e73; }
.btn-check:disabled { background: #9fb0be; cursor: default; }
.days-chip {
  font-size: 12px; font-weight: 700; color: var(--brass); margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.feedback { font-size: 13px; line-height: 1.55; margin-top: 12px; padding: 12px 14px; border-radius: 8px; }
.feedback.good { background: #e7f6ec; color: #1d5c38; }
.feedback.bad { background: #fbe9e6; color: #7c2c22; }
.feedback.hint { background: #fdf6e3; color: #6d5518; }

/* bucket sort */
.bucket-item {
  display: block; width: 100%; text-align: left; font-family: inherit; font-size: 13px;
  background: var(--white); border: 2px solid rgba(26, 62, 92, 0.18); border-radius: 8px;
  padding: 11px 12px; margin-bottom: 8px; cursor: pointer; color: var(--ink); line-height: 1.4;
}
.bucket-item.sel { border-color: var(--navy); background: #eaf6fc; }
.bucket-item .tag { float: right; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px; margin-left: 8px; }
.tag.c0 { background: #e2ecf3; color: var(--navy); }
.tag.c1 { background: #fdf0d4; color: #8a6a1d; }
.tag.c2 { background: #f8dcd7; color: #a03327; }
.bucket-btns { display: flex; gap: 8px; margin: 4px 0 12px; position: sticky; top: 0; background: var(--cream); padding: 6px 0; z-index: 2; }
.bucket-btn {
  flex: 1; font-family: inherit; font-size: 11px; font-weight: 700; padding: 10px 4px;
  border-radius: 8px; border: 2px solid rgba(26, 62, 92, 0.2); background: var(--white); cursor: pointer; color: var(--ink);
}
.bucket-btn.b0.on { background: #e2ecf3; border-color: var(--navy); }
.bucket-btn.b1.on { background: #fdf0d4; border-color: #c79a2a; }
.bucket-btn.b2.on { background: #f8dcd7; border-color: #cc4b3d; }

/* sequence */
.seq-item { position: relative; }
.seq-item .num {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 50%; background: var(--navy); color: var(--white);
  font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}

/* matching */
.match-cols { display: flex; gap: 10px; }
.match-col { flex: 1; min-width: 0; }
.match-col h4 { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: #5a6a76; margin-bottom: 8px; }
.match-item {
  display: block; width: 100%; text-align: left; font-family: inherit; font-size: 12px;
  background: var(--white); border: 2px solid rgba(26, 62, 92, 0.18); border-radius: 8px;
  padding: 10px; margin-bottom: 8px; cursor: pointer; color: var(--ink); line-height: 1.35;
}
.match-item.sel { border-color: var(--cyan); background: #eaf6fc; }
.match-item.paired { opacity: 0.55; }
.match-item .pair-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* proportion slider */
.prop-visual { text-align: center; margin: 10px 0 4px; font-size: 34px; line-height: 1.2; }
.prop-readout { text-align: center; font-weight: 800; font-size: 22px; color: var(--navy); font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.prop-sub { text-align: center; font-size: 11px; color: #5a6a76; margin-bottom: 10px; }
input[type="range"].prop-slider { width: 100%; accent-color: var(--cyan); height: 34px; }

/* ---------- inspect HUD ---------- */
#inspectHud {
  position: fixed; z-index: 45; left: 0; right: 0;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none; padding: 0 20px;
}
#inspectHud p {
  pointer-events: none; font-size: 13px; color: var(--cream); text-align: center;
  background: rgba(10, 14, 18, 0.65); padding: 10px 18px; border-radius: 20px; line-height: 1.4;
}
#inspectHud button { pointer-events: auto; }

/* ---------- win ---------- */
.cert-wrap { text-align: center; max-width: 520px; width: 100%; }
.commission-label { font-size: 11px; letter-spacing: 4px; color: var(--brass); font-weight: 700; }
.commission {
  font-weight: 800; font-size: clamp(38px, 8vw, 56px); color: var(--brass-bright);
  font-variant-numeric: tabular-nums; text-shadow: 0 0 30px rgba(232, 197, 106, 0.45);
  margin: 4px 0 22px;
}
.certificate {
  background: var(--cream); color: var(--ink); border: 3px double var(--brass);
  border-radius: 6px; padding: 30px 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.cert-kicker { font-size: 10px; letter-spacing: 4px; text-transform: uppercase; color: var(--brass); font-weight: 700; margin-bottom: 12px; }
.cert-name { font-family: 'Playfair Display', Georgia, serif; font-size: clamp(28px, 6vw, 40px); color: var(--navy); margin-bottom: 10px; }
.cert-body { font-size: 14px; line-height: 1.6; color: var(--gray); }
.cert-body strong { color: var(--navy); font-size: 17px; }
.cert-line { font-size: 12px; color: #5a6a76; margin-top: 10px; }
.cert-sig { font-family: 'Playfair Display', Georgia, serif; font-style: italic; font-size: 15px; color: var(--navy); margin-top: 18px; }
.cert-wrap .btn-primary { margin-top: 24px; }

/* ---------- fail ---------- */
#failScreen { background: #050607; }
.fail-wrap { text-align: center; max-width: 440px; }
.fail-frame {
  width: min(300px, 70vw); aspect-ratio: 4 / 5; margin: 0 auto 18px;
  border: 14px solid #2b2416; border-radius: 3px;
  background: #0d0f11; box-shadow: 0 0 80px rgba(232, 197, 106, 0.12), inset 0 0 40px #000;
  position: relative;
}
.fail-canvas { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 30%, #1a1d20 0%, #0a0c0e 70%); }
.fail-plaque { font-size: 13px; letter-spacing: 3px; color: var(--brass); font-weight: 700; line-height: 2; }
.fail-plaque span { font-size: 11px; color: #7d6a3d; font-style: italic; letter-spacing: 1px; }
.fail-note { font-size: 13px; color: #93a1ae; line-height: 1.6; margin: 16px 0 22px; }
