* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #fdfdfc;
  --panel: #f4f3f0;
  --line: #e4e2dd;
  --txt: #1c1b19;
  --dim: #9a978f;
  --blue: #3562d6;
}

html, body { height: 100%; }
body {
  font: 13px/1.45 -apple-system, system-ui, sans-serif;
  color: var(--txt);
  background: var(--bg);
  overflow: hidden;
}
body.lab { overflow: auto; }

/* ---------- the stage never moves: always centered ---------- */

main {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: safe center;
}
#stage { display: flex; justify-content: center; }
#cv { display: block; touch-action: none; }
#cv.fit {
  width: min(94vw, 82vh, 680px);
  max-width: 94vw;
  height: auto;
}
#cv.full {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

/* ---------- lab chrome: fixed layers over the stage ---------- */

header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(253, 253, 252, .94);
  backdrop-filter: blur(6px);
}
header h1 { font-size: 15px; font-weight: 600; }
#meta { color: var(--dim); font-size: 12px; }
#tabs { margin-left: auto; display: flex; gap: 6px; }
#tabs button {
  font: inherit; font-size: 12px;
  padding: 5px 14px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 5px;
  cursor: pointer;
  color: var(--dim);
}
#tabs button.on { background: #1c1b19; color: #fff; border-color: #1c1b19; }

#controls {
  position: fixed;
  left: 0; top: 46px; bottom: 0;
  width: 230px;
  z-index: 25;
  padding: 14px;
  overflow-y: auto;
  background: rgba(253, 253, 252, .96);
  border-right: 1px solid var(--line);
}
#controls label {
  display: block;
  color: var(--dim);
  font-size: 11px;
  margin: 12px 0 4px;
}
#controls select, #controls input[type=number] {
  width: 100%;
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}
#controls input[type=range] { width: 100%; accent-color: var(--blue); }
.btnrow { display: flex; gap: 6px; margin-top: 8px; }
.btnrow button, #controls > button {
  flex: 1;
  font: inherit; font-size: 12px;
  padding: 7px 0;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 5px;
  cursor: pointer;
}
#controls > button { width: 100%; margin-top: 8px; display: block; }
#controls button:hover { background: #ecebe7; }
#exportBtn { background: #1c1b19 !important; color: #fff; border-color: #1c1b19 !important; }

#readout {
  position: fixed;
  right: 0; top: 46px;
  z-index: 25;
  width: 300px;
  max-height: calc(100dvh - 46px);
  overflow-y: auto;
  padding: 20px 18px;
  font-size: 12px;
  background: rgba(253, 253, 252, .9);
}
#readout .row { display: flex; margin: 3px 0; }
#readout .k { width: 96px; flex: none; color: var(--dim); }
#readout .v { color: var(--txt); }
#readout .gap { height: 12px; }
.p-epic { color: #7b4bd6; }
.p-rare { color: #3562d6; }
.p-uncommon { color: #3d7a3d; }
.p-common { color: #9a978f; }

#rarityPanel { width: 100%; max-width: 720px; padding-top: 60px; }
#rarityPanel h2 { font-size: 13px; margin: 18px 0 10px; }
.bar { display: flex; align-items: center; gap: 10px; margin: 5px 0; }
.bar .lbl { width: 90px; color: var(--dim); font-size: 12px; text-align: right; }
.bar .fill { height: 14px; background: #1c1b19; border-radius: 3px; min-width: 2px; }
.bar .n { color: var(--dim); font-size: 11px; }
.rareseed {
  display: inline-block;
  margin: 3px 6px 3px 0;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}
.rareseed:hover { border-color: var(--blue); color: var(--blue); }

/* ---------- floating widgets ---------- */

#slots {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: 12px;
  display: flex;
  gap: 6px;
  z-index: 40;
}
body.lab #slots { top: 56px; right: 312px; }
.slot {
  width: 34px; height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(253, 253, 252, .88);
  color: var(--dim);
  font: 15px/1 -apple-system, system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.slot canvas { width: 100%; height: 100%; display: block; }
.slot .del {
  position: absolute;
  top: 0; right: 0;
  width: 13px; height: 13px;
  font-size: 9px; line-height: 13px;
  text-align: center;
  background: #1c1b19;
  color: #fff;
  border-radius: 0 7px 0 7px;
  display: none;
}
/* hover-only affordances: on touch, iOS turns any state-changing :hover
   into a first-tap-hovers / second-tap-clicks trap */
@media (hover: hover) {
  .slot:hover { border-color: var(--dim); }
  .slot:hover .del { display: block; }
}

#hint {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: .04em;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
}
#hint button.off { opacity: .4; }
#hint button {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: #1c1b19;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
}
#hint button svg {
  width: 21px; height: 21px;
  display: block;
  margin: auto;
}

#labToggle {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom));
  left: 14px;
  z-index: 40;
  font: inherit; font-size: 12px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(253, 253, 252, .88);
  color: var(--dim);
  cursor: pointer;
}
#labToggle:hover { color: var(--txt); border-color: var(--dim); }
