/* ============================================
   爱之岛 · 3D婚礼邀请游戏 — UI样式
   ============================================ */
:root {
  --rose: #9D4B5C;
  --rose-light: #D49BA8;
  --rose-mist: #F0DADA;
  --gold: #C9A96E;
  --gold-light: #E8D5B0;
  --cream: #FFF9F3;
  --dark: #2A1B1F;
  --font-script: 'Great Vibes', 'Ma Shan Zheng', cursive;
  --font-heading: 'Playfair Display', 'Noto Serif SC', serif;
  --font-body: 'Noto Serif SC', serif;
  --font-sans: 'Noto Sans SC', sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: #1a1216;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  display: block;
}

/* ===== 开始界面 ===== */
#startScreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(212, 155, 168, 0.35), transparent 60%),
    radial-gradient(ellipse at 20% 80%, rgba(201, 169, 110, 0.25), transparent 50%),
    linear-gradient(180deg, #2A1B1F, #4A2B33);
  transition: opacity 1.2s var(--ease), visibility 1.2s;
}

#startScreen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.start-pretitle {
  font-family: var(--font-sans);
  font-size: clamp(0.7rem, 1.5vw, 0.85rem);
  letter-spacing: 0.5em;
  color: var(--gold-light);
  text-transform: uppercase;
  margin-bottom: 1rem;
  animation: fadeUp 1s var(--ease) 0.2s both;
}

.start-title {
  font-family: var(--font-script);
  font-size: clamp(3rem, 9vw, 5.5rem);
  color: var(--rose-light);
  text-shadow: 0 0 60px rgba(212, 155, 168, 0.5);
  line-height: 1.2;
  animation: fadeUp 1.2s var(--ease) 0.5s both;
}

.start-subtitle {
  font-family: var(--font-heading);
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  color: var(--gold-light);
  font-style: italic;
  margin: 1rem 0 0.6rem;
  animation: fadeUp 1.2s var(--ease) 0.8s both;
}

.start-desc {
  font-size: clamp(0.85rem, 1.8vw, 0.95rem);
  color: rgba(255, 249, 243, 0.7);
  text-align: center;
  max-width: 480px;
  line-height: 2;
  padding: 0 1.5rem;
  animation: fadeUp 1.2s var(--ease) 1s both;
}

#startBtn {
  margin-top: 2.5rem;
  padding: 1rem 3.5rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  letter-spacing: 0.3em;
  color: var(--cream);
  background: linear-gradient(135deg, var(--rose), #B85569);
  border: 1px solid rgba(232, 213, 176, 0.4);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 40px rgba(157, 75, 92, 0.5);
  transition: all 0.4s var(--ease);
  animation: fadeUp 1.2s var(--ease) 1.2s both, glowPulse 2.5s ease-in-out 2s infinite;
}

#startBtn:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 14px 50px rgba(212, 155, 168, 0.6); }

.start-hint {
  margin-top: 1.6rem;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: rgba(255, 249, 243, 0.45);
  letter-spacing: 0.15em;
  animation: fadeUp 1.2s var(--ease) 1.4s both;
}

@keyframes fadeUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes glowPulse { 0%,100% { box-shadow: 0 8px 40px rgba(157,75,92,.5); } 50% { box-shadow: 0 8px 60px rgba(212,155,168,.75); } }

/* ===== HUD ===== */
#hud {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s var(--ease);
}
#hud.visible { opacity: 1; }

.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.hud-hearts {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(42, 27, 31, 0.72);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(232, 213, 176, 0.25);
  border-radius: 999px;
  padding: 8px 18px;
  color: var(--gold-light);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
}

.hud-hearts .heart-icon { font-size: 1.1rem; animation: heartBeat 1.8s ease-in-out infinite; }
@keyframes heartBeat { 0%,100% { transform: scale(1); } 12% { transform: scale(1.25); } 24% { transform: scale(1); } }

.hud-zone {
  position: absolute;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-script);
  font-size: 1.7rem;
  color: var(--cream);
  text-shadow: 0 2px 20px rgba(0,0,0,0.6);
  transition: opacity 0.6s;
  white-space: nowrap;
}

.hud-btns { display: flex; gap: 10px; pointer-events: auto; }

.hud-btn {
  background: rgba(42, 27, 31, 0.72);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(232, 213, 176, 0.25);
  border-radius: 999px;
  padding: 8px 16px;
  color: var(--cream);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.3s;
}
.hud-btn:hover { background: rgba(157, 75, 92, 0.85); border-color: var(--rose-light); }
.hud-btn.active { background: var(--rose); border-color: var(--gold-light); }

/* 任务列表 */
#taskPanel {
  position: absolute;
  top: 64px; right: 18px;
  width: 250px;
  background: rgba(42, 27, 31, 0.82);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(232, 213, 176, 0.25);
  border-radius: 16px;
  padding: 16px;
  pointer-events: auto;
  transform-origin: top right;
  transition: all 0.4s var(--ease);
}
#taskPanel.hidden { opacity: 0; transform: scale(0.9); pointer-events: none; }

.task-panel-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--gold-light);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: rgba(255, 249, 243, 0.85);
  border-bottom: 1px dashed rgba(232, 213, 176, 0.12);
}
.task-item:last-child { border-bottom: none; }
.task-item .task-check {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.62rem;
  color: transparent;
  transition: all 0.3s;
}
.task-item.done { color: rgba(255,249,243,0.4); text-decoration: line-through; }
.task-item.done .task-check { background: var(--rose); border-color: var(--rose); color: #fff; }
.task-reward { margin-left: auto; font-size: 0.72rem; color: var(--gold); flex-shrink: 0; }

/* 互动提示 */
#interactHint {
  position: absolute;
  bottom: 24%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(42, 27, 31, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 10px 26px;
  color: var(--cream);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  opacity: 0;
  transition: all 0.3s var(--ease);
  pointer-events: auto;
  cursor: pointer;
  white-space: nowrap;
}
#interactHint.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
#interactHint .key {
  display: inline-block;
  background: var(--gold);
  color: var(--dark);
  border-radius: 6px;
  padding: 1px 8px;
  font-weight: 700;
  margin-right: 8px;
  font-size: 0.8rem;
}

/* 操作说明 */
#controlsHint {
  position: absolute;
  bottom: 14px; left: 18px;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: rgba(255, 249, 243, 0.55);
  line-height: 1.9;
  background: rgba(42, 27, 31, 0.5);
  backdrop-filter: blur(8px);
  padding: 10px 14px;
  border-radius: 12px;
  pointer-events: none;
}
#controlsHint .key {
  display: inline-block;
  background: rgba(232, 213, 176, 0.2);
  border: 1px solid rgba(232, 213, 176, 0.35);
  border-radius: 4px;
  padding: 0 6px;
  margin: 0 2px;
  font-size: 0.68rem;
  color: var(--gold-light);
}

/* ===== 对话/功能面板 ===== */
#modalOverlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(26, 18, 22, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s var(--ease);
}
#modalOverlay.visible { opacity: 1; visibility: visible; }

.modal {
  width: min(560px, 92vw);
  max-height: 84vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #FFF9F3, #F5EDE4);
  border: 1px solid var(--gold-light);
  border-radius: 22px;
  padding: 30px 32px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
  transform: scale(0.92) translateY(16px);
  transition: transform 0.45s var(--ease);
  pointer-events: auto;
}
#modalOverlay.visible .modal { transform: scale(1) translateY(0); }
.modal::-webkit-scrollbar { width: 6px; }
.modal::-webkit-scrollbar-thumb { background: var(--rose-light); border-radius: 99px; }

.modal-label {
  font-family: var(--font-script);
  font-size: 1.5rem;
  color: var(--gold);
  text-align: center;
}
.modal-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--dark);
  text-align: center;
  margin-bottom: 6px;
}
.modal-desc {
  font-size: 0.88rem;
  color: #5A4545;
  text-align: center;
  line-height: 1.9;
  margin-bottom: 18px;
}

.modal-close {
  position: sticky;
  top: 0;
  float: right;
  width: 32px; height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--rose-mist);
  color: var(--rose);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
}
.modal-close:hover { background: var(--rose); color: #fff; transform: rotate(90deg); }

/* 剧情对话样式 */
.story-dialog .story-text {
  font-size: 1rem;
  color: #3A2A2A;
  line-height: 2.1;
  text-align: center;
  padding: 8px 6px 4px;
}
.story-dialog .story-date {
  font-family: var(--font-script);
  font-size: 1.6rem;
  color: var(--rose);
  text-align: center;
  margin-bottom: 4px;
}

/* 表单 */
.form-group { margin-bottom: 13px; }
.form-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: #8A7070;
  margin-bottom: 5px;
  text-transform: uppercase;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--dark);
  background: #fff;
  border: 1px solid var(--gold-light);
  border-radius: 12px;
  outline: none;
  transition: all 0.25s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(157, 75, 92, 0.12);
}
.form-textarea { resize: vertical; min-height: 70px; }

.btn-primary {
  display: block;
  width: 100%;
  padding: 13px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  color: #fff;
  background: linear-gradient(135deg, var(--rose), #B85569);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.35s var(--ease);
  box-shadow: 0 6px 20px rgba(157, 75, 92, 0.3);
  margin-top: 6px;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(157, 75, 92, 0.42); }

/* 选座 */
.seat-stage {
  text-align: center;
  font-family: var(--font-script);
  font-size: 1.3rem;
  color: var(--rose);
  border: 2px dashed var(--gold-light);
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 12px;
}
.seat-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
  margin-bottom: 12px;
}
.seat {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--gold-light);
  background: #fff;
  cursor: pointer;
  font-size: 0.62rem;
  font-family: var(--font-sans);
  color: #8A7070;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s var(--ease);
}
.seat:hover:not(.occupied) { border-color: var(--rose); transform: scale(1.12); }
.seat.vip { border-color: var(--gold); background: rgba(201, 169, 110, 0.14); }
.seat.occupied { background: var(--rose-mist); color: #C0A5A5; cursor: not-allowed; }
.seat.selected { background: var(--rose); border-color: var(--rose); color: #fff; }
.seat-legend { display: flex; gap: 14px; font-size: 0.72rem; color: #8A7070; margin-bottom: 12px; font-family: var(--font-sans); flex-wrap: wrap; }

/* 选项卡片（司仪/场景） */
.option-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.option-card {
  padding: 14px 10px;
  text-align: center;
  background: #fff;
  border: 2px solid var(--gold-light);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.25s var(--ease);
}
.option-card:hover { border-color: var(--rose-light); transform: translateY(-2px); }
.option-card.selected { border-color: var(--rose); background: var(--rose-mist); }
.option-card .opt-icon { font-size: 1.6rem; margin-bottom: 4px; }
.option-card .opt-name { font-family: var(--font-heading); font-size: 0.95rem; color: var(--dark); }
.option-card .opt-desc { font-family: var(--font-sans); font-size: 0.7rem; color: #8A7070; margin-top: 2px; }

.scene-card { position: relative; height: 74px; border-radius: 14px; overflow: hidden; border: 3px solid transparent; cursor: pointer; transition: all 0.3s var(--ease); }
.scene-card.selected { border-color: var(--rose); transform: scale(1.02); }
.scene-card .scene-bg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--font-heading); font-size: 0.92rem; text-shadow: 0 2px 8px rgba(0,0,0,0.45); }

/* 留言 */
.bless-list { max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.bless-item { background: #fff; border-left: 3px solid var(--rose-light); border-radius: 10px; padding: 10px 14px; }
.bless-name { font-family: var(--font-heading); font-size: 0.85rem; color: var(--rose); }
.bless-text { font-size: 0.82rem; color: #5A4545; margin-top: 2px; }

/* ===== 建造模式 ===== */
#buildBar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(42, 27, 31, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(232, 213, 176, 0.3);
  border-radius: 18px;
  transition: transform 0.5s var(--ease);
  pointer-events: auto;
  max-width: 94vw;
  overflow-x: auto;
}
#buildBar.visible { transform: translateX(-50%) translateY(0); }

.build-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 62px;
  padding: 8px 6px;
  background: rgba(255, 249, 243, 0.08);
  border: 1.5px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s;
  color: var(--cream);
  font-family: var(--font-sans);
  font-size: 0.68rem;
  flex-shrink: 0;
}
.build-item:hover { background: rgba(212, 155, 168, 0.25); }
.build-item.selected { border-color: var(--gold); background: rgba(157, 75, 92, 0.55); }
.build-item .bi-icon { font-size: 1.4rem; }
.build-item.danger.selected { border-color: #ff8888; background: rgba(160, 40, 40, 0.55); }

#buildTip {
  position: absolute;
  bottom: 108px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--gold-light);
  background: rgba(42, 27, 31, 0.7);
  padding: 6px 16px;
  border-radius: 99px;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
  white-space: nowrap;
}
#buildTip.visible { opacity: 1; }

/* ===== 成就 Toast ===== */
#toast {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%) translateY(-24px);
  z-index: 90;
  background: linear-gradient(135deg, #FFF9F3, #F5EDE4);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  transition: all 0.5s var(--ease);
}
#toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
#toast .toast-icon { font-size: 1.7rem; }
#toast .toast-title { font-family: var(--font-heading); font-size: 0.95rem; color: var(--rose); }
#toast .toast-msg { font-family: var(--font-sans); font-size: 0.78rem; color: #5A4545; }

/* ===== 虚拟摇杆（移动端） ===== */
#joystick {
  position: absolute;
  bottom: 30px; left: 30px;
  width: 110px; height: 110px;
  border-radius: 50%;
  background: rgba(255, 249, 243, 0.08);
  border: 1.5px solid rgba(232, 213, 176, 0.3);
  display: none;
  pointer-events: auto;
}
#joystickKnob {
  position: absolute;
  top: 50%; left: 50%;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: rgba(212, 155, 168, 0.6);
  border: 1.5px solid var(--gold-light);
  transform: translate(-50%, -50%);
}
#mobileInteract {
  position: absolute;
  bottom: 48px; right: 30px;
  width: 68px; height: 68px;
  border-radius: 50%;
  background: rgba(157, 75, 92, 0.8);
  border: 2px solid var(--gold-light);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
}
@media (pointer: coarse) {
  #joystick { display: block; }
  #mobileInteract.available { display: flex; }
  #controlsHint { display: none; }
}

/* 屏幕渐晕 */
#vignette {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 62%, rgba(26, 18, 22, 0.42) 100%);
}
