/* ============================================================
   賓客端 + 主持人端樣式（手機優先）
   ============================================================ */

:root {
  --bg: #fdf8f4;
  --surface: #ffffff;
  --line: #ece2d9;
  --text: #3a322c;
  --muted: #8d8077;
  --primary: #c08457;
  --primary-dark: #a06a41;
  --on-primary: #ffffff;
  --accent: #d9a679;
  --danger: #c0574f;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(90, 70, 55, 0.08);
}

* { box-sizing: border-box; }

/* hidden 屬性要贏過任何 display 宣告，否則 .loading 的 display:flex 會蓋掉它 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: 76px; }

/* ── 頁首 ───────────────────────────────────────────── */

.hero {
  padding: 28px 20px 22px;
  text-align: center;
  background: linear-gradient(160deg, #fff6ee 0%, #f7e9dc 100%);
  border-bottom: 1px solid var(--line);
}
.hero h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 2px;
}
.hero .amp { color: var(--primary); margin: 0 8px; }
.hero p { margin: 2px 0; font-size: 13px; color: var(--muted); }
.hero .tagline { margin-top: 10px; font-size: 14px; color: var(--primary-dark); }

/* ── 版面 ───────────────────────────────────────────── */

main { padding: 16px; max-width: 640px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title .count { font-size: 12px; color: var(--muted); font-weight: 400; }

/* ── 表單 ───────────────────────────────────────────── */

textarea, input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 16px; /* 16px 以下 iOS 會自動放大畫面 */
  font-family: inherit;
  color: var(--text);
  background: #fffdfb;
  resize: vertical;
}
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.field-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

button {
  font-family: inherit;
  font-size: 15px;
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--primary-dark); border: 1px solid var(--line); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid #eed7d4; padding: 6px 12px; font-size: 13px; }
.btn-block { display: block; width: 100%; }

/* ── 留言 ───────────────────────────────────────────── */

.wish-list { display: flex; flex-direction: column; gap: 10px; }
.wish {
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.wish .who { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.wish .text { font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.wish .when { font-size: 11px; color: var(--muted); margin-top: 4px; }

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #f2e5d8;
  flex: 0 0 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  overflow: hidden;
  color: var(--primary-dark);
  font-weight: 600;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── 照片 ───────────────────────────────────────────── */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.photo-grid img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  background: #f2e5d8;
}
.upload-zone {
  /* label 預設是 display:inline，裡面又有 display:block 的子元素，
     會讓行內盒碎裂成好幾段（虛線框斷開、文字往左溢出）。必須是 block。 */
  display: block;
  border: 1.5px dashed var(--accent);
  border-radius: var(--radius);
  padding: 26px 16px;
  text-align: center;
  color: var(--primary-dark);
  background: #fffaf5;
  cursor: pointer;
}
.upload-zone .big { font-size: 28px; display: block; margin-bottom: 6px; }
.upload-zone small { display: block; color: var(--muted); margin-top: 6px; font-size: 12px; }
input[type="file"] { display: none; }

/* ── 遊戲 ───────────────────────────────────────────── */

.q-progress { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.q-text { font-size: 17px; font-weight: 600; line-height: 1.5; margin: 0 0 16px; }
.opt-list { display: flex; flex-direction: column; gap: 10px; }
.opt {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
  color: var(--text);
  width: 100%;
}
.opt:hover { border-color: var(--accent); }
.opt.correct { background: #eef7ed; border-color: #8cc490; color: #2f6b35; }
.opt.wrong { background: #fdeeec; border-color: #e0a9a3; color: #9c3f38; }
.opt:disabled { cursor: default; }

.result { text-align: center; padding: 10px 0; }
.result .emoji { font-size: 46px; display: block; margin-bottom: 10px; }
.result h2 { margin: 0 0 8px; font-size: 20px; }
.result p { color: var(--muted); font-size: 14px; margin: 0 0 18px; line-height: 1.6; }

/* ── 底部分頁 ───────────────────────────────────────── */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.tabbar button {
  flex: 1;
  background: none;
  border: none;
  border-radius: 0;
  padding: 10px 4px 12px;
  color: var(--muted);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.tabbar button .ico { font-size: 19px; }
.tabbar button.active { color: var(--primary-dark); font-weight: 600; }

/* ── 雜項 ───────────────────────────────────────────── */

.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 10px; line-height: 1.7; }

.toast {
  position: fixed;
  left: 50%; bottom: 92px;
  transform: translateX(-50%) translateY(10px);
  background: #3a322c;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 40;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: .94; transform: translateX(-50%) translateY(0); }

.banner {
  margin: 12px 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff6e5;
  border: 1px solid #f0dcb4;
  color: #7a5b1e;
  font-size: 13px;
  line-height: 1.7;
}
.banner code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }

.loading {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 12px;
  color: var(--muted); font-size: 14px;
  z-index: 50;
}
.spinner {
  width: 26px; height: 26px;
  border: 2.5px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 主持人控制台 ───────────────────────────────────── */

.admin-wrap { max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; }
.admin-wrap h1 { font-size: 19px; margin: 0 0 4px; }
.admin-wrap .sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }

.mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.mode-grid button {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 14px 10px;
  font-size: 14px;
}
.mode-grid button.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

.stat-row { display: flex; gap: 10px; }
.stat {
  flex: 1;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 6px;
}
.stat b { display: block; font-size: 22px; color: var(--primary-dark); }
.stat span { font-size: 11px; color: var(--muted); }

.mod-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.mod-row:last-child { border-bottom: none; }
.mod-row .grow { flex: 1; min-width: 0; }
.mod-row .grow .t { word-break: break-word; }
.mod-row .grow .n { color: var(--muted); font-size: 11px; }

.winner-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f7eee4; border-radius: 999px;
  padding: 5px 10px 5px 6px; font-size: 12px; margin: 0 6px 6px 0;
}


/* ============================================================
   小遊戲
   ============================================================ */

/* ── 遊戲選單 ───────────────────────────────────────── */

.game-menu-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.game-menu-sub { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.ticket-badge {
  flex: 0 0 auto; text-align: center;
  background: #fdf1e4; border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 12px;
}
.ticket-badge b { display: block; font-size: 20px; color: var(--primary-dark); line-height: 1.1; }
.ticket-badge span { font-size: 10px; color: var(--muted); }

.game-list { display: flex; flex-direction: column; gap: 8px; }
.game-item {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px; width: 100%;
}
.game-item:hover { border-color: var(--accent); }
.game-item.done { background: #f6faf5; border-color: #cfe4cf; }
.game-emoji { font-size: 24px; flex: 0 0 auto; }
.game-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.game-name { font-size: 15px; font-weight: 600; color: var(--text); }
.game-desc { font-size: 12px; color: var(--muted); }
.game-state { flex: 0 0 auto; font-size: 12px; color: var(--primary-dark); }
.game-item.done .game-state { color: #4f8b55; }
.game-foot { text-align: center; font-size: 12px; color: var(--muted); margin: 14px 0 0; }

.game-topbar {
  display: flex; align-items: center; gap: 10px;
  margin: -4px 0 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 600;
}
.game-back {
  background: none; border: none; padding: 4px 6px;
  color: var(--primary-dark); font-size: 13px; font-weight: 400;
}

/* ── 吉祥話填空 ─────────────────────────────────────── */

.idiom-line {
  text-align: center; font-size: 34px; letter-spacing: 4px;
  margin: 18px 0 24px; color: var(--text);
}
.idiom-blank {
  display: inline-block; min-width: 46px;
  border-bottom: 3px solid var(--accent);
  color: var(--muted);
}
.idiom-blank.ok { color: #2f6b35; border-color: #8cc490; }
.idiom-blank.ng { color: #9c3f38; border-color: #e0a9a3; }

.opt-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.opt-char { text-align: center; font-size: 22px; padding: 14px 0; }

/* ── 翻牌配對 ───────────────────────────────────────── */

.card-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.flip-card {
  position: relative; aspect-ratio: 3 / 4; padding: 0;
  border-radius: 12px; border: 1px solid var(--line);
  background: linear-gradient(150deg, #f7e2cf, #eccdb0);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; overflow: hidden;
}
.flip-card .face-front { display: none; }
.flip-card.open, .flip-card.done { background: var(--surface); }
.flip-card.open .face-back, .flip-card.done .face-back { display: none; }
.flip-card.open .face-front, .flip-card.done .face-front { display: block; animation: pop-in .2s ease both; }
.flip-card.done { border-color: #8cc490; background: #f0f7ef; }
@keyframes pop-in { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── 計時列（狂點愛心與接捧花共用） ─────────────────── */

.tap-head { display: flex; align-items: baseline; gap: 6px; margin: 4px 0 8px; }
.tap-count { font-size: 32px; font-weight: 600; color: var(--primary-dark); line-height: 1; }
.tap-goal { font-size: 14px; color: var(--muted); flex: 1; }
.tap-clock { font-size: 14px; color: var(--muted); }

.timebar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.timebar i { display: block; height: 100%; background: var(--primary); transition: width .1s linear; }

/* ── 狂點愛心 ───────────────────────────────────────── */

.tap-pad {
  width: 100%; padding: 40px 0;
  border-radius: var(--radius);
  background: linear-gradient(160deg, #fff1f2, #ffe3e6);
  border: 1px solid #f3d3d6;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
.tap-pad:active { transform: scale(.98); }
.tap-heart { font-size: 62px; line-height: 1; }
.tap-hint { font-size: 13px; color: #a4626a; }

.fly-layer { position: relative; height: 0; }
.fly-heart {
  position: fixed; pointer-events: none; font-size: 22px;
  animation: fly-up .9s ease-out both;
}
@keyframes fly-up {
  from { transform: translate(-50%, 0) scale(1); opacity: 1; }
  to   { transform: translate(-50%, -90px) scale(1.5); opacity: 0; }
}

/* ── 接捧花 ─────────────────────────────────────────── */

.catch-area {
  position: relative; overflow: hidden;
  height: 58vh; max-height: 420px; min-height: 280px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f4f8fb 0%, #eaf1f6 100%);
  border: 1px solid var(--line);
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
.catch-basket {
  position: absolute; bottom: 8px; left: 50%;
  transform: translateX(-50%);
  font-size: 40px; line-height: 1;
  transition: transform .05s linear;
  pointer-events: none;
}
.catch-basket.hit-good { transform: translateX(-50%) scale(1.25); }
.catch-basket.hit-bad { transform: translateX(-50%) rotate(-12deg); }
.falling { position: absolute; font-size: 28px; pointer-events: none; }
.catch-start {
  position: absolute; inset: 0; margin: auto;
  width: 160px; height: 44px; border-radius: 999px;
  background: var(--primary); color: var(--on-primary);
}
