/* =============================================================
   game.css — 遊戲主畫面樣式
   ============================================================= */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
body {
  font-family: 'Noto Sans TC', 'PingFang TC', sans-serif;
  background: #1a202c;
  color: #2d3748;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #f7fafc;
  box-shadow: 0 0 40px rgba(0,0,0,0.4);
  overflow: hidden;
  position: relative;
}

/* =====================
   HUD（精簡版）
   ===================== */
.hud {
  background: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);
  color: #fff;
  padding: 6px 12px 8px;
  border-bottom: 3px solid #7ED957;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.hud-meta {
  font-size: 13px;
  font-weight: 700;
  color: #7ED957;
}

.hud-divider {
  color: #4a5568;
  margin: 0 6px;
}

.btn-icon {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
}

.btn-icon:hover { background: rgba(255,255,255,0.2); }

.status-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 6px;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.status-cell {
  background: rgba(255,255,255,0.06);
  padding: 5px 8px;
  border-radius: 8px;
}

.status-label {
  font-size: 10px;
  font-weight: 700;
  color: #cbd5e0;
  margin-bottom: 3px;
}

.status-bar {
  height: 6px;
  background: rgba(0,0,0,0.3);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 3px;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease, background 0.3s;
}

.bar-hp { background: linear-gradient(90deg, #f56565, #c53030); }
.bar-en { background: linear-gradient(90deg, #5DBB63, #3F8E47); }
.bar-hg { background: linear-gradient(90deg, #f6ad55, #c05621); }

.bar-fill.warn { animation: pulse-warn 1s infinite; }
.bar-fill.critical {
  background: linear-gradient(90deg, #c53030, #742a2a) !important;
  animation: pulse-critical 0.6s infinite;
}

@keyframes pulse-warn { 50% { opacity: 0.6; } }
@keyframes pulse-critical {
  50% { opacity: 0.3; }
}

.status-val {
  font-size: 10px;
  text-align: right;
  color: #e2e8f0;
  font-weight: 700;
}

.kpi-cell {
  background: linear-gradient(180deg, rgba(126,217,87,0.18) 0%, rgba(126,217,87,0.08) 100%);
  padding: 5px 6px;
  border-radius: 8px;
  text-align: center;
  color: #fff;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(126,217,87,0.25);
}

.kpi-icon { font-size: 15px; }
.kpi-label { font-size: 10px; color: #7ED957; font-weight: 700; }
.kpi-val { font-size: 15px; font-weight: 900; color: #fff; }

/* =====================
   場景區
   ===================== */
.scene-area {
  position: relative;
  overflow: hidden;
  min-height: 320px;
  aspect-ratio: 4/3;
  background: #1B8A35;
  flex: 1;
}

.scene-bg {
  position: absolute;
  inset: 0;
  background-color: #1B8A35;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: background-image 0.6s ease;
}

.scene-bg::before {
  /* 角色背後光暈 — 增加視覺焦點 */
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 75%;
  height: 80%;
  background: radial-gradient(ellipse at center bottom, rgba(126,217,87,0.35) 0%, transparent 60%);
  pointer-events: none;
}

.scene-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,0.30) 100%);
  pointer-events: none;
}

.scene-char {
  position: absolute;
  bottom: -2%;
  left: 50%;
  transform: translateX(-50%);
  height: 100%;
  width: auto;
  max-width: 85%;
  object-fit: contain;
  object-position: bottom;
  z-index: 2;
  filter:
    drop-shadow(0 10px 20px rgba(0,0,0,0.5))
    drop-shadow(0 0 16px rgba(126,217,87,0.35));
  animation: char-idle 2.6s ease-in-out infinite;
}

@keyframes char-idle {
  0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
  50% { transform: translateX(-50%) translateY(-6px) scale(1.015); }
}

/* =====================
   事件卡
   ===================== */
.event-area {
  background: linear-gradient(180deg, #F4FFEF 0%, #fff 100%);
  padding: 12px;
  overflow-y: auto;
  max-height: 50vh;
  min-height: 240px;
  border-top: 3px solid #7ED957;
  flex-shrink: 0;
}

.event-card {
  background: #F4FFEF;
  border-radius: 14px;
  padding: 14px;
  border: 2px solid #7ED957;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
}

.event-card.anim-in {
  opacity: 1;
  transform: translateY(0);
}

.event-tag {
  display: inline-block;
  background: #1B8A35;
  color: #7ED957;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.event-title {
  font-size: 19px;
  font-weight: 900;
  color: #1B8A35;
  margin: 4px 0 8px;
  line-height: 1.3;
}

.event-desc {
  font-size: 15px;
  color: #2d3748;
  line-height: 1.65;
  margin: 0 0 10px;
}

.event-real {
  font-size: 12px;
  color: #c05621;
  font-style: italic;
  margin: 0 0 10px;
  padding: 5px 10px;
  background: rgba(192,86,33,0.08);
  border-radius: 6px;
  line-height: 1.5;
}

/* === 劇情對話模式 === */
.dialogue-stream {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 12px;
  max-height: 360px;
  overflow-y: auto;
  padding: 4px;
}

.dialogue-line {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: dlg-pop 0.3s ease-out;
}

@keyframes dlg-pop {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

.dlg-self { flex-direction: row-reverse; }

.dlg-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  border: 2px solid #7ED957;
}

.dlg-self .dlg-avatar {
  border-color: #3F8E47;
  background: linear-gradient(135deg, #3F8E47 0%, #1B8A35 100%);
  color: #7ED957;
}

.dlg-bubble {
  max-width: 78%;
  background: #fff;
  border-radius: 16px;
  padding: 10px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border: 1px solid #e2e8f0;
  position: relative;
}

.dlg-self .dlg-bubble {
  background: linear-gradient(135deg, #F4FFEF 0%, #E8FAE0 100%);
  border-color: #7ED957;
}

.dlg-name {
  font-size: 12px;
  font-weight: 700;
  color: #4a5568;
  margin-bottom: 3px;
}

.dlg-self .dlg-name { color: #1B8A35; text-align: right; }

.dlg-text {
  font-size: 16px;
  color: #1B8A35;
  line-height: 1.7;
  font-weight: 500;
}

.next-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(180deg, #5DBB63, #3F8E47);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 3px 0 #1B8A35;
  margin-top: 8px;
  letter-spacing: 0.05em;
}

.next-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #1B8A35; }

.next-btn-final {
  background: linear-gradient(180deg, #7ED957, #5DBB63);
  color: #1B8A35;
  box-shadow: 0 3px 0 #3F8E47;
  font-weight: 900;
}

.choice-prompt {
  background: linear-gradient(135deg, #E8FAE0 0%, #D4F5C8 100%);
  padding: 12px 16px;
  border-radius: 12px;
  border-left: 5px solid #5DBB63;
  font-weight: 700;
  color: #1B8A35 !important;
  font-size: 15px !important;
  line-height: 1.6 !important;
}

.event-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.choice-btn {
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.15s;
  font-family: inherit;
  min-height: 60px;
}

.choice-btn:hover {
  border-color: #7ED957;
  background: #F4FFEF;
  transform: translateX(3px);
}

.choice-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.choice-label {
  font-size: 17px;
  font-weight: 700;
  color: #1B8A35;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
}

.choice-delta {
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
  text-align: right;
  white-space: nowrap;
}

.choice-delta > span {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(126,217,87,0.10);
  font-weight: 800;
}

.delta-pos { color: #2A6534 !important; background: rgba(126,217,87,0.22) !important; }
.delta-neg { color: #c53030 !important; background: rgba(229,62,62,0.12) !important; }

/* =====================
   Toast 提示
   ===================== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(26,32,44,0.95);
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  border: 2px solid #7ED957;
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s;
  max-width: 90%;
  text-align: center;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-label {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.toast-delta {
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* =====================
   臨界警示
   ===================== */
.critical-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,32,44,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fade-in 0.3s;
}

@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }

.critical-box {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 320px;
  text-align: center;
  border: 3px solid #e53e3e;
}

.critical-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.critical-msg {
  font-size: 15px;
  color: #1B8A35;
  font-weight: 700;
  margin: 0 0 16px;
  line-height: 1.6;
}

.critical-btn {
  background: #e53e3e;
  color: #fff;
  border: none;
  padding: 10px 28px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

/* =====================
   選單抽屜
   ===================== */
.menu-drawer {
  position: fixed;
  top: 0; right: 0;
  width: 240px;
  height: 100vh;
  background: #fff;
  box-shadow: -8px 0 24px rgba(0,0,0,0.3);
  padding: 50px 20px 20px;
  z-index: 3000;
}

.menu-drawer h3 {
  color: #1B8A35;
  margin: 0 0 16px;
}

.menu-drawer ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.menu-drawer li a {
  display: block;
  padding: 12px 0;
  color: #2d3748;
  text-decoration: none;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 700;
}

.menu-drawer li a:hover { color: #7ED957; }

.drawer-close {
  position: absolute;
  top: 12px; right: 12px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #a0aec0;
}

/* RWD */
@media (max-width: 380px) {
  .scene-char { width: 150px; }
  .event-title { font-size: 14px; }
  .event-desc { font-size: 12px; }
}
