/* ===== RESET & BASE ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: 'Segoe UI', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  -webkit-user-select: none; user-select: none;
}
.hidden { display: none !important; }

/* ===== TITLE SCREEN ===== */
#title-screen {
  width: 100%; height: 100%;
  background: linear-gradient(135deg, #ffe4f3 0%, #e0c3fc 40%, #c2f0fc 100%);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
#title-screen::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(255,182,193,0.4) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(173,216,230,0.4) 0%, transparent 50%);
}
.title-container {
  text-align: center; z-index: 1;
  animation: fadeInUp 0.8s ease-out;
}
.title-stars { margin-bottom: 12px; }
.star {
  font-size: 28px; color: #ffd700;
  display: inline-block; margin: 0 8px;
  animation: twinkle 1.5s ease-in-out infinite;
}
.star:nth-child(2) { animation-delay: 0.3s; font-size: 36px; }
.star:nth-child(3) { animation-delay: 0.6s; }
.game-title {
  font-size: 48px; font-weight: 900;
  color: #ff69b4;
  text-shadow: 3px 3px 0 #fff, -1px -1px 0 #ffb6c1;
  line-height: 1.2; margin-bottom: 12px;
  letter-spacing: 2px;
}
.title-accent {
  background: linear-gradient(90deg, #ff69b4, #ff9a56, #ffd700);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.title-sub {
  font-size: 16px; color: #8b6dae;
  margin-bottom: 28px; font-weight: 500;
}
.kawaii-btn {
  background: linear-gradient(135deg, #ff85a2 0%, #ff5c8a 100%);
  color: #fff; border: none; border-radius: 50px;
  padding: 16px 48px; font-size: 22px; font-weight: 700;
  cursor: pointer; letter-spacing: 2px;
  box-shadow: 0 6px 20px rgba(255,92,138,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative; overflow: hidden;
}
.kawaii-btn::after {
  content: ''; position: absolute;
  top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2.5s infinite;
}
.kawaii-btn:hover { transform: scale(1.08); box-shadow: 0 8px 28px rgba(255,92,138,0.5); }
.kawaii-btn:active { transform: scale(0.96); }
.kawaii-btn.small { padding: 10px 28px; font-size: 16px; }
.title-mascot {
  margin-top: 24px; font-size: 64px;
  animation: bounce 2s ease-in-out infinite;
}
.title-mascot::after { content: '\1F431'; }

/* ===== GAME SCREEN ===== */
#game-screen {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  background: #f5f0ff;
}

/* Top Bar */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px;
  background: linear-gradient(135deg, #fff0f5, #f0e6ff);
  border-bottom: 2px solid #f0d0e8;
  min-height: 48px; flex-shrink: 0;
}
.room-name {
  font-size: 18px; font-weight: 700; color: #d63384;
  cursor: default;
}
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px;
  border: 2px solid #e8c8e0; border-radius: 12px;
  background: #fff; font-size: 20px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, background 0.15s;
}
.icon-btn:hover { background: #fff0f5; transform: scale(1.12); }
.icon-btn:active { transform: scale(0.92); }

/* Room */
.room-container {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 12px; overflow: hidden;
  min-height: 0;
}
.room {
  position: relative;
  width: 100%; max-width: 700px;
  aspect-ratio: 4/3;
  max-height: 100%;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), inset 0 0 60px rgba(255,255,255,0.2);
}
.room-wall {
  position: absolute; inset: 0; bottom: 35%;
  background: #ffe4f0;
  transition: background 0.4s;
}
.room-floor {
  position: absolute; left: 0; right: 0; bottom: 0; height: 35%;
  background: #f5d5c8;
  transition: background 0.4s;
}
.room-floor::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: rgba(0,0,0,0.08);
}
.room-window {
  position: absolute; top: 8%; right: 10%;
  width: 18%; aspect-ratio: 3/4;
  z-index: 1;
}
.window-frame {
  width: 100%; height: 100%;
  border: 4px solid #deb887;
  border-radius: 8px 8px 4px 4px;
  overflow: hidden;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.1);
}
.window-sky {
  width: 100%; height: 100%;
  background: linear-gradient(180deg, #87ceeb 0%, #b0e0e6 60%, #98fb98 100%);
}
.window-frame::after {
  content: '';
  position: absolute; top: 0; left: 50%;
  width: 3px; height: 100%;
  background: #deb887; transform: translateX(-50%);
}

/* Placed Items */
.placed-item {
  position: absolute;
  cursor: grab;
  transition: filter 0.15s;
  z-index: 10;
}
.placed-item:hover { filter: brightness(1.1) drop-shadow(0 2px 8px rgba(255,105,180,0.4)); }
.placed-item.dragging {
  cursor: grabbing; opacity: 0.85;
  filter: drop-shadow(0 4px 12px rgba(255,105,180,0.5));
  z-index: 100;
}
.placed-item .delete-x {
  position: absolute; top: -8px; right: -8px;
  width: 22px; height: 22px;
  background: #ff6b8a; color: #fff;
  border: 2px solid #fff; border-radius: 50%;
  font-size: 12px; font-weight: 700;
  display: none; align-items: center; justify-content: center;
  cursor: pointer; z-index: 200;
  line-height: 1;
}
.placed-item:hover .delete-x { display: flex; }

/* Grid overlay (Variant A) */
.room.grid-mode::after {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,182,193,0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,182,193,0.15) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none; z-index: 5;
}

/* Snap indicator (Variant A) */
.snap-indicator {
  position: absolute;
  border: 2px dashed rgba(255,105,180,0.4);
  border-radius: 4px;
  pointer-events: none; z-index: 9;
  background: rgba(255,182,193,0.1);
}

/* Catalog Panel */
.catalog-panel {
  flex-shrink: 0;
  background: #fff;
  border-top: 3px solid #f0d0e8;
  padding: 0;
}
.category-tabs {
  display: flex; gap: 0;
  background: #fef0f5;
  border-bottom: 2px solid #f5e0ed;
}
.cat-tab {
  flex: 1; padding: 10px 4px;
  border: none; background: transparent;
  font-size: 14px; font-weight: 600; color: #c77dba;
  cursor: pointer; transition: all 0.2s;
  white-space: nowrap;
}
.cat-tab.active {
  background: #fff;
  color: #d63384;
  border-bottom: 3px solid #ff69b4;
}
.cat-tab:hover:not(.active) { background: rgba(255,255,255,0.6); }
.catalog-items {
  display: flex; gap: 12px;
  padding: 12px 16px;
  overflow-x: auto;
  min-height: 90px;
  align-items: center;
  scrollbar-width: thin;
}
.catalog-items::-webkit-scrollbar { height: 4px; }
.catalog-items::-webkit-scrollbar-thumb { background: #f0c0d8; border-radius: 4px; }
.catalog-item {
  flex-shrink: 0;
  width: 70px; height: 70px;
  background: #fff5f8;
  border: 2px solid #f0d0e8;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  cursor: grab;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  position: relative;
}
.catalog-item:hover {
  transform: scale(1.12);
  border-color: #ff69b4;
  box-shadow: 0 4px 16px rgba(255,105,180,0.25);
}
.catalog-item:active { transform: scale(0.95); cursor: grabbing; }
.catalog-item .item-label {
  position: absolute; bottom: -2px; left: 0; right: 0;
  font-size: 9px; color: #c77dba; font-weight: 600;
  text-align: center; background: rgba(255,255,255,0.9);
  border-radius: 0 0 10px 10px; padding: 1px 0;
}

/* Color Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: #fff; border-radius: 20px;
  padding: 24px; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  animation: popIn 0.25s ease-out;
}
.modal-content h3 {
  font-size: 20px; color: #d63384; margin-bottom: 16px;
}
.color-grid {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 10px; margin-bottom: 16px;
}
.color-swatch {
  width: 44px; height: 44px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}
.color-swatch:hover { transform: scale(1.2); border-color: #ff69b4; }
.color-swatch.selected { border-color: #ff69b4; transform: scale(1.15); }

/* Mascot Helper */
.mascot-helper {
  position: fixed; bottom: 160px; right: 12px;
  display: flex; flex-direction: column; align-items: center;
  z-index: 50; pointer-events: none;
}
.mascot-bubble {
  background: #fff; border-radius: 16px;
  padding: 8px 14px; font-size: 13px;
  color: #8b5e83; font-weight: 500;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  margin-bottom: 6px; position: relative;
  max-width: 180px; text-align: center;
  animation: fadeInUp 0.5s ease-out;
}
.mascot-bubble::after {
  content: '';
  position: absolute; bottom: -6px; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #fff;
}
.mascot-character { font-size: 40px; animation: bounce 3s ease-in-out infinite; }

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes twinkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}
@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 200%; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes placeItem {
  0% { transform: scale(0.5); opacity: 0.5; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.placed-item.just-placed { animation: placeItem 0.3s ease-out; }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .game-title { font-size: 36px; }
  .room { max-width: 100%; }
  .catalog-item { width: 60px; height: 60px; font-size: 28px; }
  .cat-tab { font-size: 12px; padding: 8px 2px; }
  .mascot-helper { bottom: 140px; right: 8px; }
  .mascot-bubble { font-size: 11px; max-width: 140px; }
  .mascot-character { font-size: 32px; }
}

/* Screenshot flash */
.flash {
  position: fixed; inset: 0;
  background: #fff; z-index: 9999;
  animation: flash 0.4s ease-out forwards;
}
@keyframes flash {
  0% { opacity: 0.8; }
  100% { opacity: 0; }
}
