/* Bricky — lightbox look: pure white, flat even light, saturated brick colors,
   #FFC500 yellow header band, bold black text. */
:root {
  --yellow: #FFC500;
  --red: #C91A09;
  --blue: #0055BF;
  --orange: #FE8A18;
  --green: #237841;
  --ink: #111111;
  --muted: #5a5a5a;
  --line: #e4e4e4;
  --card: #ffffff;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background: #ffffff; color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

/* Splash greeting */
#splash {
  position: fixed; inset: 0; z-index: 100; background: #ffffff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  transition: opacity 0.3s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
#splash-fig svg { width: 130px; height: auto; display: block; }
.splash-name { font-size: 34px; font-weight: 800; letter-spacing: 0.5px; }
.splash-bubble {
  background: var(--yellow); border: 3px solid #111; border-radius: 16px;
  padding: 2px 14px; font-weight: 800; font-size: 22px;
  animation: pop 0.35s ease;
}
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.wave-arm { transform-origin: 78px 62px; animation: wave 0.55s ease-in-out 2; }
@keyframes wave { 0%,100% { transform: rotate(0deg); } 50% { transform: rotate(-24deg); } }

/* Top bar */
#topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  background: var(--yellow); padding: 10px 14px;
  border-bottom: 3px solid #111;
}
#hamburger {
  background: #fff; border: 3px solid #111; border-radius: 10px;
  width: 44px; height: 44px; font-size: 20px; line-height: 1;
}
.topbar-icon { width: 34px; height: 34px; border-radius: 8px; }
#page-title { font-size: 22px; font-weight: 800; }

/* Drawer */
#drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 49;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
#drawer-backdrop.open { opacity: 1; pointer-events: auto; }
#drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 270px; z-index: 50;
  background: #fff; border-right: 3px solid #111;
  transform: translateX(-105%); transition: transform 0.22s ease;
  display: flex; flex-direction: column; padding: 14px; gap: 8px;
}
#drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 800; margin-bottom: 12px; }
.drawer-icon { width: 40px; height: 40px; border-radius: 9px; }
#drawer button {
  text-align: left; background: #fff; border: 2px solid var(--line); border-radius: 12px;
  padding: 13px 14px; font-weight: 700; font-size: 17px;
}
#drawer button.active { background: var(--yellow); border-color: #111; }
#drawer .drawer-bottom { margin-top: auto; }

/* Pages */
#app { max-width: 860px; margin: 0 auto; padding: 18px 16px 30px; }
.page { display: none; }
.page.active { display: block; }
h2 { font-size: 24px; margin: 6px 0 10px; }
h3 { font-size: 18px; margin: 18px 0 8px; }
p.lede { color: var(--muted); font-size: 16px; line-height: 1.45; }
.card {
  border: 2px solid var(--line); border-radius: 16px; padding: 16px; margin: 12px 0; background: var(--card);
}
.card.hl { border-color: #111; box-shadow: 0 2px 0 #111; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
input[type="text"], input[type="password"], input[type="search"], select {
  border: 2px solid #111; border-radius: 12px; padding: 12px 14px; font-size: 16px; background: #fff; min-width: 0;
}
input.grow, select.grow { flex: 1; }
.btn {
  background: var(--yellow); border: 3px solid #111; border-radius: 12px;
  padding: 11px 18px; font-weight: 800; font-size: 16px;
}
.btn.primary { background: var(--red); color: #fff; width: 100%; padding: 14px; font-size: 18px; }
.btn.blue { background: var(--blue); color: #fff; border-color: #111; }
.btn.ghost { background: #fff; border: 2px solid var(--line); font-weight: 700; }
.btn.small { padding: 7px 12px; font-size: 14px; border-width: 2px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.msg { border-radius: 12px; padding: 12px 14px; margin: 10px 0; font-size: 15px; line-height: 1.45; }
.msg.info { background: #FFF6D8; border: 2px solid var(--yellow); }
.msg.error { background: #FDECEA; border: 2px solid var(--red); }
.msg.ok { background: #EAF6EC; border: 2px solid var(--green); }

/* Piece rows */
.piece-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line);
}
.swatch {
  width: 34px; height: 34px; border-radius: 8px; border: 2px solid rgba(0,0,0,0.25); flex: none;
  position: relative;
}
.swatch::after {
  content: ""; position: absolute; top: 5px; left: 50%; transform: translateX(-50%);
  width: 12px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.35);
  box-shadow: inset 0 -2px 2px rgba(0,0,0,0.15);
}
.piece-meta { flex: 1; min-width: 0; }
.piece-name { font-weight: 800; font-size: 15px; }
.piece-sub { color: var(--muted); font-size: 13px; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button {
  width: 30px; height: 30px; border-radius: 9px; border: 2px solid #111; background: #fff; font-weight: 800;
}
.qty b { min-width: 26px; text-align: center; }
.badge {
  display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 800;
  background: #eee; border: 1.5px solid #bbb;
}
.badge.have { background: #EAF6EC; border-color: var(--green); color: var(--green); }
.badge.miss { background: #FDECEA; border-color: var(--red); color: var(--red); }
.badge.preview { background: #FFF6D8; border-color: #B8860B; color: #7A5B00; }

/* Toggle switch */
.switch { position: relative; width: 56px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: #ccc; border: 2px solid #111; border-radius: 999px; transition: 0.15s;
}
.switch .track::before {
  content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 2px solid #111; top: 2px; left: 3px; transition: 0.15s;
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::before { transform: translateX(24px); }

/* Instruction book */
.book { border: 3px solid #111; border-radius: 18px; overflow: hidden; background: #fff; }
.book-page { padding: 14px; }
.book-page img { width: 100%; height: auto; display: block; border-radius: 10px; border: 1px solid var(--line); }
.book-nav { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 2px solid var(--line); }
.book-nav input[type="range"] { flex: 1; }
.book-title { font-size: 22px; font-weight: 800; margin: 4px 0; }

/* Modal */
#modal-root:empty { display: none; }
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 860px; max-height: 92vh; overflow: auto;
  border-radius: 20px 20px 0 0; padding: 14px 16px 24px;
}
@media (min-width: 700px) { .modal-back { align-items: center; } .modal { border-radius: 20px; } }

.set-item, .lib-item {
  display: flex; gap: 12px; align-items: center; border: 2px solid var(--line);
  border-radius: 14px; padding: 12px; margin: 8px 0; background: #fff; width: 100%; text-align: left;
}
.set-item img { width: 54px; height: 54px; border-radius: 10px; }
.set-item .t { font-weight: 800; font-size: 16px; }
.set-item .s { color: var(--muted); font-size: 13px; }

#footer {
  border-top: 2px solid var(--line); color: var(--muted); font-size: 12.5px;
  text-align: center; padding: 16px 20px 26px; line-height: 1.5; max-width: 860px; margin: 0 auto;
}
.kbd-note { font-size: 13px; color: var(--muted); }
canvas.render { width: 100%; height: auto; display: block; border: 1px solid var(--line); border-radius: 10px; }
