* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Noto Sans HK', 'Microsoft JhengHei', sans-serif;
  background: #121214;
  color: #e2e8f0;
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

#screen-start, #screen-family, #screen-game, #screen-event, #screen-end {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.active { display: flex !important; }

/* 通用按鈕 */
.btn-action {
  background: #e94560;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.8rem 2rem;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all .15s;
  font-weight: bold;
}
.btn-action:hover { background: #c73652; transform: scale(1.02); }

/* ── START & FAMILY ── */
.title-area { text-align: center; max-width: 600px; margin-bottom: 2rem; }
.title-area h1 { font-size: 2.4rem; color: #e94560; margin-bottom: 1rem; }
.title-area p { color: #94a3b8; line-height: 1.6; }

.family-box {
  background: #1e1e24;
  border: 2px solid #3f3f46;
  border-radius: 12px;
  padding: 2rem;
  max-width: 500px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}
.family-identity { font-size: 3rem; margin-bottom: 0.5rem; }
.family-title { font-size: 1.6rem; color: #f5a623; margin-bottom: 1rem; font-weight: bold; }
.must-list { background: #2d2d35; padding: 1rem; border-radius: 8px; text-align: left; margin: 1rem 0; font-size: 0.95rem;}
.must-list li { margin: 0.4rem 0; color: #cbd5e1; }

/* ── GAME LAYOUT ── */
#screen-game { flex-direction: row; padding: 0; background: #151518; }

#sidebar {
  width: 240px;
  background: #1e1e24;
  border-right: 1px solid #2d2d35;
  display: flex;
  flex-direction: column;
  padding: 15px 10px;
  gap: 12px;
  overflow-y: auto;
  flex-shrink: 0;
}
#sidebar h3 { font-size: .85rem; color: #64748b; text-align: center; text-transform: uppercase; letter-spacing: 1px; }

.item-chip {
  background: #27272a;
  border: 1px solid #3f3f46;
  border-radius: 8px;
  padding: 10px;
  cursor: grab;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .15s;
}
.item-chip .emoji { font-size: 1.6rem; }
.item-chip .details { flex: 1; }
.item-chip .name { font-size: 0.9rem; font-weight: bold; color: #f1f5f9; }
.item-chip .need { font-size: 0.75rem; color: #f5a623; margin-top: 2px; }
.item-chip .size-tag { font-size: 0.7rem; color: #94a3b8; background: #18181b; padding: 1px 4px; border-radius: 4px; float: right; }
.item-chip.used { opacity: .2; cursor: default; border-color: #27272a; }
.item-chip:not(.used):hover { background: #323238; border-color: #e94560; }

#main-stage { flex: 1; display: flex; flex-direction: column; height: 100%; position: relative; }

#qol-panel {
  background: #1e1e24;
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  border-bottom: 1px solid #2d2d35;
  align-items: center;
}
.qol-metric { font-size: 0.85rem; color: #cbd5e1; display: flex; align-items: center; gap: 6px; }
.qol-stars { color: #f5a623; letter-spacing: 1px; }
#space-hud { margin-left: auto; font-weight: bold; color: #ff6b6b; background: rgba(233,69,96,0.1); padding: 4px 10px; border-radius: 6px; font-size: 0.9rem; }

#canvas-wrap { flex: 1; position: relative; background: #0f0f11; overflow: hidden; }
#room-canvas {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: #f4ebe1;
  border: 4px dashed #64748b;
  box-shadow: 0 0 30px rgba(0,0,0,0.6);
}
#preview-canvas {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
}
#door-indicator {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem; color: #e94560; font-weight: bold;
  background: #121214; padding: 2px 8px; border-radius: 10px; border: 1px solid #e94560;
}
#game-action-layer {
  position: absolute;
  bottom: 20px; right: 20px;
}

.placed-item {
  position: absolute;
  cursor: move;
  font-size: 1.8rem;
  text-align: center;
  border: 2px solid #e94560;
  background: rgba(233,69,96,0.05);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.placed-item.compulsory { border-color: #f5a623; background: rgba(245,166,35,0.05); }
.placed-item .remove-btn {
  position: absolute; top: -8px; right: -8px;
  width: 18px; height: 18px; background: #e94560; color: #fff;
  font-size: 10px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: 1px solid #fff; font-weight: bold; display: none;
}
.placed-item:hover .remove-btn { display: flex; }

/* ── EVENT ── */
#screen-event { background: rgba(10,10,12,0.96); z-index: 100; }
.event-modal {
  background: #1e1e24;
  border: 2px solid #e94560;
  border-radius: 16px;
  padding: 2.5rem;
  max-width: 550px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
}
.event-header { display: flex; align-items: center; gap: 15px; margin-bottom: 1.5rem; }
.event-header .icon { font-size: 3rem; }
.event-header h2 { font-size: 1.4rem; color: #e94560; }
.event-desc { color: #cbd5e1; line-height: 1.6; margin-bottom: 2rem; font-size: 1rem; }

.choice-container { display: flex; flex-direction: column; gap: 12px; }
.choice-btn {
  background: #27272a;
  border: 1px solid #3f3f46;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
  line-height: 1.4;
}
.choice-btn:hover { background: #3f3f46; border-color: #f5a623; }

.reflection-box { display: none; margin-top: 1.5rem; border-top: 1px solid #3f3f46; padding-top: 1.5rem; text-align: center;}
.reflection-box p { font-style: italic; color: #a1a1aa; margin-bottom: 1rem; font-size: 0.95rem; }

/* ── END SCREEN ── */
#screen-end { background: #09090b; overflow-y: auto; justify-content: flex-start; padding-top: 3rem; }
.end-container { max-width: 650px; width: 100%; }
.end-container h2 { font-size: 2rem; color: #e94560; text-align: center; margin-bottom: 1rem; }
.no-win-msg { background: #1e1e24; border-left: 4px solid #e94560; padding: 1.2rem; margin: 1.5rem 0; color: #cbd5e1; line-height: 1.6; }

.comparison-section { background: #18181b; border: 1px solid #27272a; border-radius: 10px; padding: 1.5rem; margin-top: 1.5rem; }
.comparison-section h3 { color: #f5a623; font-size: 1.1rem; margin-bottom: 1rem; }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.compare-list h4 { font-size: 0.9rem; color: #a1a1aa; margin-bottom: 0.5rem; }
.compare-list ul { list-style: none; }
.compare-list li { margin: 0.4rem 0; font-size: 0.95rem; color: #f1f5f9; display: flex; align-items: center; gap: 6px; }

.data-box-end { background: #1e1e24; border-radius: 10px; padding: 1.2rem; margin-top: 1.5rem; }
.data-box-end h4 { color: #94a3b8; font-size: 0.9rem; margin-bottom: 0.8rem; }
.data-grid-end { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; text-align: center; }
.data-item { background: #151518; padding: 10px; border-radius: 6px; }
.data-item .val { font-size: 1.2rem; font-weight: bold; color: #e94560; }
.data-item .lbl { font-size: 0.7rem; color: #71717a; margin-top: 2px; }

/* Leaderboard */
.data-section {
  background: #1e1e24;
  border-radius: 10px;
  padding: 1.2rem;
  margin-top: 1.5rem;
}
.data-section h3 { color: #e94560; margin-bottom: 1rem; font-size: 1.1rem; }
#leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: #151518;
  border-radius: 6px;
  font-size: 0.9rem;
}
.lb-row .lb-rank {
  font-weight: bold;
  color: #f5a623;
  min-width: 24px;
}
.lb-row .lb-name {
  flex: 1;
  color: #cbd5e1;
}
.lb-row .lb-score {
  font-weight: bold;
  color: #e94560;
  font-size: 0.85rem;
}
.lb-loading {
  color: #71717a;
  font-size: 0.85rem;
  text-align: center;
  padding: 12px;
}

#drag-ghost { position: fixed; pointer-events: none; font-size: 2.2rem; z-index: 9999; transform: translate(-50%, -50%); display: none; }
