/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #dff2fb;
  color: #1a2d40;
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  /* Prevent iOS bounce/overscroll inside iframe */
  -webkit-overflow-scrolling: touch;
  touch-action: none;
}

/* ── Selection Screen ────────────────────────────────── */
#selection-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background: radial-gradient(ellipse at 50% 30%, #c2e9f8 0%, #dff2fb 70%);
}

header { text-align: center; margin-bottom: 2.5rem; }

h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  background: linear-gradient(135deg, #0066cc, #7873f5, #00b0d8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.tagline {
  margin-top: 0.5rem;
  font-size: 1.1rem;
  color: #4a6e84;
}

/* ── Visual Grid ─────────────────────────────────────── */
#visual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
  max-width: 900px;
  width: 100%;
}

.visual-card {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 16 / 10;
  background: #ffffff;
  border: 1px solid #b8d8ed;
  box-shadow: 0 2px 10px rgba(0, 80, 160, 0.08);
  transition: transform 0.25s, box-shadow 0.25s;
}
.visual-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 30px rgba(0, 100, 200, 0.18);
}

.visual-card canvas.preview {
  width: 100%;
  height: 100%;
  display: block;
}

.visual-card .label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.6rem 1rem;
  background: linear-gradient(transparent, rgba(255, 255, 255, 0.92));
  font-weight: 600;
  font-size: 0.95rem;
  color: #1a2d40;
  pointer-events: none;
}

.visual-card .badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(120, 115, 245, 0.75);
  color: #fff;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  pointer-events: none;
}

/* ── Visual Viewport ─────────────────────────────────── */
#visual-viewport {
  position: fixed;
  inset: 0;
  z-index: 100;
  touch-action: none;
}
#visual-viewport.hidden { display: none; }

#visual-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #1080b0;
  cursor: pointer;
  touch-action: none;
}

/* ── HUD ─────────────────────────────────────────────── */
#hud {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: rgba(235, 248, 255, 0.88);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  border: 1px solid rgba(0, 100, 180, 0.2);
  z-index: 200;
  transition: opacity 0.4s;
}
#hud.fade { opacity: 0; pointer-events: none; }

#hud button {
  background: rgba(0, 80, 160, 0.07);
  border: 1px solid rgba(0, 80, 160, 0.2);
  color: #1a2d40;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}
#hud button:hover { background: rgba(0, 80, 160, 0.15); }
#hud button.active {
  background: rgba(120, 115, 245, 0.25);
  border-color: #7873f5;
  color: #4440c0;
}

/* ── Mobile: bigger tap targets, always-visible HUD ─── */
@media (hover: none) and (pointer: coarse) {
  #hud {
    bottom: 0.75rem;
    padding: 0.6rem 1.2rem;
    gap: 0.5rem;
  }
  #hud button {
    padding: 0.7rem 1.2rem;
    font-size: 1rem;
    min-height: 44px;
    min-width: 44px;
  }
  /* Never auto-hide on touch devices */
  #hud.fade {
    opacity: 1;
    pointer-events: auto;
  }
}
