*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Canvases ── */
#drawing-canvas {
  position: fixed; top: 0; left: 0;
  display: block; z-index: 2; cursor: crosshair;
  /* smooth shrink/restore when chat opens/closes */
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1),
              transform-origin 0s;
}
#blink-canvas {
  position: fixed; top: 0; left: 0;
  display: block; z-index: 3; pointer-events: none;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1),
              transform-origin 0s;
}

/* Landscape chat-open: scale to fill left 50%, centered vertically */
body.chat-open #drawing-canvas,
body.chat-open #blink-canvas {
  transform-origin: top left;
  /* scale(0.48) → 48vw×48vh; offset centers in 50vw×100vh available area */
  transform: translateX(1vw) translateY(26vh) scale(0.48);
}

/* Portrait chat-open: scale to fill top 35%, centered horizontally */
@media (orientation: portrait) {
  body.chat-open #drawing-canvas,
  body.chat-open #blink-canvas {
    transform-origin: top left;
    /* scale(0.34) → 34vw×34vh; offset centers in 100vw×35vh available area */
    transform: translateX(33vw) translateY(0.5vh) scale(0.34);
  }
}

/* ── Eye hint SVG — invisible but in layout so getScreenCTM() works ── */
#hint-eyes {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: var(--eyes-width, 23.9147vw);
  visibility: hidden; pointer-events: none;
}

/* ── Phase 1: color hint ── */
#color-hint {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10; pointer-events: none;
  text-align: center;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 8px rgba(0,0,0,0.25);
  font-size: 1.1rem; letter-spacing: 0.04em;
  transition: opacity 0.4s;
}

/* ── Toolbar — landscape: bottom-right column; portrait: bottom-center row ── */
#toolbar {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 25; display: none;
  flex-direction: column; align-items: center; gap: 10px;
  transition: opacity 0.3s;
}
@media (orientation: portrait) {
  #toolbar {
    right: auto; left: 50%;
    transform: translateX(-50%);
    flex-direction: row;
  }
}

/* ── Tool buttons — dark circles ── */
.tool-btn {
  position: relative;
  width: 44px; height: 44px; border-radius: 50%;
  border: none;
  background: rgba(35,35,35,0.88);
  color: rgba(255,255,255,0.90);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.tool-btn:hover  { transform: scale(1.08); }
.tool-btn.active { background: rgba(255,255,255,0.20); }

#color-btn { cursor: pointer; }
#color-input {
  position: absolute; inset: 0; opacity: 0;
  width: 100%; height: 100%;
  cursor: pointer; border-radius: 50%; border: none; padding: 0;
}

/* ── Size popup slider (160×36 pill) ── */
.size-popup {
  position: fixed; display: none; align-items: center;
  width: 160px; height: 36px;
  background: rgba(35,35,35,0.90); border-radius: 18px;
  z-index: 26; backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.35); padding: 0 12px;
}
.size-popup input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.25); outline: none; cursor: pointer;
}
.size-popup input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; cursor: grab;
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}
.size-popup input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; }
.size-popup input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  cursor: grab; border: none; box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}

/* ── Complete button ── */
#complete-btn {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%); z-index: 20;
  padding: 13px 40px; border-radius: 999px; border: none;
  background: rgba(255,255,255,0.92); color: #222;
  font-size: 1rem; font-weight: 500; cursor: pointer;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  backdrop-filter: blur(10px); display: none;
  transition: opacity 0.3s, transform 0.2s;
}
#complete-btn:hover { transform: translateX(-50%) scale(1.03); }

/* ── Chat dialog
   Landscape : slides in from right (right 50%)
   Portrait  : slides up from bottom (bottom 65%)            ── */
#chat-dialog {
  position: fixed; z-index: 30;
  display: flex; flex-direction: column;
  background: transparent; /* body gradient shows through */
  pointer-events: none;
  /* Landscape: right half */
  top: 0; right: 0; bottom: 0;
  width: 50%;
  transform: translateX(105%);
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
#chat-dialog.open {
  transform: translateX(0);
  pointer-events: all;
}
@media (orientation: portrait) {
  #chat-dialog {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%; height: 65%;
    transform: translateY(105%);
  }
  #chat-dialog.open { transform: translateY(0); }
}

/* Close button — top right of dialog */
#close-chat-btn {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--bubble-bg, rgba(255,255,255,0.18));
  color: var(--pen-color, #fff);
  font-size: 0.85rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  z-index: 1;
}
#close-chat-btn:hover { background: var(--bubble-bg-strong, rgba(255,255,255,0.28)); }

/* Messages scroll area */
#chat-messages {
  flex: 1; overflow-y: auto;
  padding: 56px 16px 12px; /* top pad clears close btn */
  display: flex; flex-direction: column; gap: 10px;
}
/* hide scrollbar but keep scroll */
#chat-messages::-webkit-scrollbar { display: none; }
#chat-messages { -ms-overflow-style: none; scrollbar-width: none; }

/* Message bubbles — glass, inherit color from bg */
.msg {
  max-width: 80%;
  padding: 10px 16px; border-radius: 20px;
  font-size: 0.95rem; line-height: 1.5; word-break: break-word;
  background: var(--bubble-bg, rgba(255,255,255,0.15));
  color: var(--pen-color, #fff);
  backdrop-filter: blur(4px);
}
.msg.ai   { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user {
  align-self: flex-end; border-bottom-right-radius: 4px;
  background: var(--bubble-bg-strong, rgba(255,255,255,0.25));
}
.msg.typing { opacity: 0.55; font-style: italic; }

/* Chat input row */
#chat-input-row {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 16px 20px;
}
#chat-input {
  flex: 1; padding: 11px 16px;
  border: 1.5px solid var(--pen-color-faint, rgba(255,255,255,0.3));
  border-radius: 24px; outline: none;
  font-size: 0.95rem;
  background: var(--bubble-bg, rgba(255,255,255,0.12));
  color: var(--pen-color, #fff);
  transition: border-color 0.2s;
}
#chat-input::placeholder { color: var(--pen-color, #fff); opacity: 0.5; }
#chat-input:focus {
  border-color: var(--pen-color-faint, rgba(255,255,255,0.5));
}
/* City reveal button — map pin icon, left of input */
#city-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--bubble-bg, rgba(255,255,255,0.14));
  color: var(--pen-color, #fff);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, opacity 0.2s;
  opacity: 0.55;
}
#city-btn:hover   { background: var(--bubble-bg-strong, rgba(255,255,255,0.25)); opacity: 1; }
#city-btn.ready   { opacity: 1; }
#city-btn:disabled { opacity: 0.2; cursor: default; }

#send-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: var(--bubble-bg-strong, rgba(255,255,255,0.25));
  color: var(--pen-color, #fff);
  font-size: 1.1rem; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
#send-btn:hover { background: var(--bubble-bg-strong, rgba(255,255,255,0.35)); }

/* ── City card — rendered as a chat bubble inside the dialog ── */
.msg.city-card {
  max-width: 88%;
  padding: 0;
  border-radius: 18px;
  /* clip children (image) to rounded corners */
  overflow: hidden;
  -webkit-mask-image: -webkit-radial-gradient(white, black); /* Safari clip fix */
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.20);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  animation: card-in 0.45s cubic-bezier(0.4,0,0.2,1) forwards;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}
/* Image wrapper constrains and clips the photo */
.city-card-img-wrap {
  width: 100%; height: 150px;
  overflow: hidden;
  /* no border-radius here — parent handles it */
  display: block;
}
.city-card-img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.city-card-body {
  padding: 12px 14px 14px;
}
.city-card-name {
  font-size: 1.08rem; font-weight: 700;
  color: var(--pen-color, #fff);
  margin-bottom: 5px; letter-spacing: 0.01em;
}
.city-card-artist {
  font-size: 0.88rem;
  color: var(--pen-color, #fff);
  opacity: 0.65;
  margin-bottom: 8px;
}
.city-card-reason {
  font-size: 0.86rem; line-height: 1.5;
  color: var(--pen-color, #fff);
  opacity: 0.82; font-style: italic;
  margin-bottom: 10px;
}
.city-card-spotify {
  display: inline-block;
  font-size: 0.82rem; font-weight: 600;
  color: #1DB954;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.city-card-spotify:hover { opacity: 0.8; }

/* ── Playlist options — 3 stacked clickable cards ── */
.playlist-options {
  display: flex; flex-direction: column; gap: 8px;
  align-self: flex-start; width: 88%;
}
.playlist-option {
  display: flex; align-items: center; gap: 10px;
  background: var(--bubble-bg, rgba(255,255,255,0.14));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 14px; overflow: hidden;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
  -webkit-mask-image: -webkit-radial-gradient(white, black);
}
.playlist-option:hover {
  background: var(--bubble-bg-strong, rgba(255,255,255,0.24));
  transform: scale(1.02);
}
.playlist-option-img {
  width: 60px; height: 60px; object-fit: cover; flex-shrink: 0;
}
.playlist-option-body {
  padding: 0 10px 0 0; min-width: 0;
}
.playlist-option-name {
  font-size: 0.88rem; font-weight: 600;
  color: var(--pen-color, #fff);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.playlist-option-meta {
  font-size: 0.75rem;
  color: var(--pen-color, #fff);
  opacity: 0.55; margin-top: 2px;
}

/* ── Star rating ── */
.star-rating {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; margin: 4px 0 4px 8px;
}
.star-label {
  font-size: 0.78rem; opacity: 0.6; color: #fff; margin-right: 4px;
}
.star {
  font-size: 1.4rem; color: #555; cursor: pointer;
  transition: color 0.15s; user-select: none;
}
.star.hover, .star.selected { color: #f5c518; }

/* ── Legacy full-screen overlay — disabled ── */
#city-reveal { display: none !important; }
