/* Dexter's Canvas — clinical dark chrome, blood-red accents, white canvas. */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: #0d0d0f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #d9d4cc;
  user-select: none; -webkit-user-select: none;
}

#stage { position: fixed; inset: 0; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { pointer-events: none; }

#hud { position: fixed; inset: 0; pointer-events: none; }
/* chrome panels swallow taps entirely — a missed button must never paint */
#topbar, #tray { pointer-events: auto; }

/* ---------- top bar ---------- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  background: linear-gradient(180deg, rgba(10,10,12,0.88), rgba(10,10,12,0.55) 70%, transparent);
}
#brand { display: flex; flex-direction: column; line-height: 1.05; }
#brand-name {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700; letter-spacing: 0.14em; font-size: 17px;
  color: #b81f1f;
  text-shadow: 0 1px 6px rgba(160, 18, 18, 0.45);
}
#brand-sub {
  font-size: 9px; letter-spacing: 0.34em; text-transform: uppercase;
  color: #7d786f; margin-top: 2px;
}
#actions { display: flex; gap: 6px; }
#actions button {
  width: 40px; height: 40px; border-radius: 9px;
  background: rgba(28, 28, 32, 0.85); border: 1px solid #2c2c31;
  color: #b9b3a9; cursor: pointer;
  display: grid; place-items: center;
  transition: color .15s, border-color .15s, background .15s;
}
#actions button svg { width: 21px; height: 21px; }
#actions button:hover { color: #eee; border-color: #4a4a50; }
#actions button.active {
  color: #ff5544; border-color: #a01212;
  background: rgba(90, 12, 12, 0.5);
  box-shadow: 0 0 12px rgba(160, 18, 18, 0.35);
}

/* ---------- bottom tray: the tool roll ---------- */
#tray {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(10,10,12,0.92), rgba(10,10,12,0.6) 75%, transparent);
  display: flex; flex-direction: column; gap: 7px; align-items: center;
}
#tools {
  display: flex; gap: 5px; max-width: 100%;
  overflow-x: auto; scrollbar-width: none; padding: 4px 2px;
}
#tools::-webkit-scrollbar { display: none; }
.tool {
  min-width: 58px; padding: 7px 6px 6px; border-radius: 10px;
  background: rgba(24, 24, 28, 0.9); border: 1px solid #2c2c31;
  color: #a29b90; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: color .15s, border-color .15s, transform .1s, background .15s;
}
.tool svg { width: 22px; height: 22px; }
.tool span { font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.tool:hover { color: #ddd; }
.tool.active {
  color: #ff5544; border-color: #a01212;
  background: linear-gradient(180deg, rgba(70, 10, 10, 0.65), rgba(40, 8, 8, 0.65));
  box-shadow: 0 0 14px rgba(160, 18, 18, 0.35), inset 0 0 8px rgba(160,18,18,0.15);
  transform: translateY(-2px);
}
#knobs { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; max-width: 100%; }
#knobs label {
  display: flex; align-items: center; gap: 7px;
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: #8b857b;
}
#knobs input[type=range] {
  width: 110px; accent-color: #a01212; cursor: pointer;
}
#knobs select {
  background: rgba(24,24,28,0.9); color: #c9c3b9; border: 1px solid #2c2c31;
  border-radius: 8px; padding: 6px 8px; font-size: 12px; cursor: pointer;
}

/* ---------- narrow screens ---------- */
@media (max-width: 480px) {
  #topbar { padding-left: 10px; padding-right: 10px; }
  #brand-name { font-size: 13px; letter-spacing: 0.08em; white-space: nowrap; }
  #brand-sub { display: none; }
  #actions { gap: 4px; }
  #actions button { width: 34px; height: 34px; border-radius: 8px; }
  #actions button svg { width: 18px; height: 18px; }
  .tool { min-width: 52px; padding: 6px 5px 5px; }
  .tool svg { width: 20px; height: 20px; }
  .tool span { font-size: 8.5px; }
  #knobs { gap: 8px; }
  #knobs input[type=range] { width: 78px; }
  #knobs select { padding: 5px 6px; font-size: 11px; }
}

/* ---------- toast & hint ---------- */
#toast, #hint {
  position: absolute; left: 50%; transform: translateX(-50%);
  background: rgba(16, 16, 18, 0.92); border: 1px solid #3a3a40;
  color: #d9d4cc; font-size: 13px; letter-spacing: 0.03em;
  padding: 9px 16px; border-radius: 10px;
  opacity: 0; transition: opacity .25s; pointer-events: none;
  max-width: 86vw; text-align: center;
}
#toast { top: calc(64px + env(safe-area-inset-top)); }
#hint { bottom: calc(118px + env(safe-area-inset-bottom)); font-size: 12px; color: #a89f93; }
#toast.show, #hint.show { opacity: 1; }

/* ---------- slide box ---------- */
#slidebox {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(5, 5, 6, 0.72); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
#slidebox-panel {
  width: min(560px, 94vw); max-height: 86vh;
  display: flex; flex-direction: column;
  background: linear-gradient(160deg, #201612, #17100d 60%, #120c0a);
  border: 1px solid #3a2a20; border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,220,180,0.06);
  overflow: hidden;
}
#slidebox-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  font-family: Georgia, serif; letter-spacing: 0.22em; font-size: 14px;
  color: #c9a15e; border-bottom: 1px solid #33251c;
}
#slidebox-head button {
  background: none; border: none; color: #8b7a64; font-size: 16px; cursor: pointer;
}
#slidebox-grid {
  padding: 14px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px;
}
#slidebox-empty { grid-column: 1/-1; color: #8b7a64; font-size: 13px; text-align: center; padding: 22px 0; }
.slide img { width: 100%; display: block; border-radius: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.5); }
.slide-acts { display: flex; gap: 10px; justify-content: center; padding-top: 5px; }
.slide-acts button {
  background: none; border: none; cursor: pointer; text-decoration: none;
  font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: #8b7a64;
}
.slide-acts .slide-save:hover { color: #d9c9a8; }
.slide-acts .slide-del:hover { color: #c0392b; }
#slidebox-foot { padding: 12px 16px; border-top: 1px solid #33251c; text-align: center; }
#slidebox-foot button {
  background: rgba(90, 12, 12, 0.45); border: 1px solid #6e1414; color: #e0d5c5;
  border-radius: 9px; padding: 9px 18px; font-size: 12.5px; letter-spacing: 0.06em; cursor: pointer;
}
#slidebox-foot button:hover { background: rgba(120, 16, 16, 0.55); }

/* ---------- intro card ---------- */
#intro {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 5, 6, 0.8); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#intro-card {
  width: min(460px, 92vw); text-align: center;
  background: linear-gradient(170deg, #151517, #0e0e10);
  border: 1px solid #2c2c31; border-radius: 16px;
  padding: 30px 28px 26px;
  box-shadow: 0 18px 70px rgba(0,0,0,0.75), 0 0 40px rgba(160,18,18,0.08);
}
#intro-card h1 {
  font-family: Georgia, serif; letter-spacing: 0.16em; font-size: 22px;
  color: #b81f1f; margin: 10px 0 14px;
  text-shadow: 0 1px 8px rgba(160, 18, 18, 0.4);
}
#intro-card p { color: #a89f93; font-size: 13.5px; line-height: 1.65; margin-bottom: 12px; }
#intro-card p.fine { color: #6e675e; font-size: 11.5px; }
#intro-card button {
  margin-top: 8px; padding: 11px 26px; border-radius: 10px; cursor: pointer;
  background: linear-gradient(180deg, #8c1010, #5e0b0b);
  border: 1px solid #a01212; color: #f2e6dc;
  font-family: Georgia, serif; font-size: 15px; letter-spacing: 0.05em;
  box-shadow: 0 4px 18px rgba(160, 18, 18, 0.35);
}
#intro-card button:hover { filter: brightness(1.15); }

/* ---------- fatal ---------- */
#fatal {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px;
}
#fatal h1 {
  font-family: Georgia, serif; letter-spacing: 0.14em; color: #b81f1f;
}
#fatal p { max-width: 420px; color: #8b857b; line-height: 1.5; }
