:root {
  --bg: #e9e9e9;
  --panel-bg: rgba(20, 20, 20, 0.9);
  --panel-fg: #f2f2f2;
  --panel-muted: #b8b8b8;
  --accent: #ff3b30;
  --border: rgba(255, 255, 255, 0.15);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  font-family: var(--sans);
}

#bannerHost{
  position: fixed;
  left: 0;
  top: 0;
  width: 315px;
  height: 466px;
  overflow: hidden;
  background: #E9E9E9;
}

/* Scene scaling */
#sceneWrap {
  position: absolute;
  inset: 0;
}

/* the internal scene stays 630×932, we scale it in JS */
.scene{
  position: absolute;
  left: 0;
  top: 0;
  width: 630px;
  height: 932px;
  transform-origin: 0 0;
}

.layer {
  position: absolute;
  inset: 0;
}

img.pixel {
  image-rendering: auto;
  display: block;
}

.overlay {
  position: absolute;
  inset: 0;
  width: 630px;
  height: 932px;
  pointer-events: none;
  z-index: 1000;
}

.frame-swap-img{
  position: absolute;
  left: 0;
  top: 0;
  width: 630px;
  height: 932px;
  pointer-events: none;
  user-select: none;
  z-index: 1100; /* above overlay (1000) */
}

.frame-swap-img.clickable{
  cursor: pointer;
}

.sand-area-outline {
  position: absolute;
  pointer-events: none;
  z-index: 900;
  box-sizing: border-box;
}

.sand-piece-wrap {
  position: absolute;
  overflow: hidden; /* crop reveal/shrink */
  will-change: transform, width, height, top, left, opacity;
}

.sand-piece-img {
  position: absolute;
  left: 0;
  top: 0;
  width: 189px; /* match sand area width */
  height: auto;
  user-select: none;
  pointer-events: none;
}

/* Particle canvas layer */
#particleCanvas {
  position: absolute;
  inset: 0;
  z-index: 100; /* behind sand PNGs, behind overlay */
  pointer-events: none;
}

#debugPanel {
  position: fixed;
  top: 12px;
  left: 327px; /* 315px (banner width) + 12px (margin) */
  width: 360px;
  height: calc(100vh - 24px);

  background: var(--panel-bg);
  color: var(--panel-fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  padding: 10px;
  box-sizing: border-box;

  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dp-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.dp-sub {
  font-size: 11px;
  color: var(--panel-muted);
  font-family: var(--mono);
}

.dp-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.dp-row > * {
  flex: 1;
}

.dp-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--panel-fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
}

.dp-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.dp-btn.primary {
  border-color: rgba(255, 59, 48, 0.45);
  background: rgba(255, 59, 48, 0.18);
}

.dp-btn.primary:hover {
  background: rgba(255, 59, 48, 0.25);
}

.dp-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.dp-tab {
  text-align: center;
  padding: 7px 6px;
  font-size: 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  user-select: none;
}

.dp-tab.active {
  border-color: rgba(255, 59, 48, 0.55);
  background: rgba(255, 59, 48, 0.22);
}

.dp-content {
  margin-top: 10px;
  flex: 1;
  overflow: auto;
  padding-right: 6px;
}

.dp-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
}

.dp-label {
  font-size: 11px;
  color: var(--panel-muted);
  margin-bottom: 6px;
}

.dp-field {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dp-field.single {
  grid-template-columns: 1fr;
}

.dp-input {
  width: 100%;
  padding: 7px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--panel-fg);
  font-size: 12px;
  font-family: var(--mono);
  box-sizing: border-box;
}

.dp-small {
  font-size: 11px;
  color: var(--panel-muted);
  margin-top: 6px;
  line-height: 1.35;
}

.dp-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.dp-toggle input {
  transform: translateY(1px);
}

.dp-slider {
  width: 100%;
}
