/* ===================================================
   刑法鎮 LawTown - 像素遊戲風格 CSS
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;700;900&family=Noto+Serif+TC:wght@700;900&display=swap');

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

body {
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: #1a1a2e;
  color: #f0e6d3;
  overflow: hidden;
  height: 100dvh;
  width: 100vw;
}

/* ===================================================
   主畫面（全螢幕）
   =================================================== */
.main-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  z-index: 1;
}

/* ── 背景圖 ── */
.title-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.title-bg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  image-rendering: pixelated;
}
.title-bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.0) 0%,
    rgba(0,0,0,0.0) 55%,
    rgba(0,0,0,0.45) 75%,
    rgba(0,0,0,0.65) 100%
  );
}

/* ── 角落徽章（版本號 / 設定） ── */
.corner-badge {
  position: absolute;
  top: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(20,15,10,0.82);
  border: 2px solid #8b6914;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: bold;
  color: #f5d87a;
  cursor: pointer;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 0 #5a4008, inset 0 1px 0 rgba(255,255,255,0.1);
  transition: filter 0.15s;
  text-decoration: none;
  font-family: inherit;
}
.corner-badge:hover { filter: brightness(1.2); }
.corner-badge--left  { left: 14px; }
.corner-badge--right { right: 14px; }
.corner-icon { font-size: 16px; }

/* ── 主標題區 ── */
.title-area {
  position: relative;
  z-index: 10;
  text-align: center;
  margin-top: 10px;
  pointer-events: none;
  user-select: none;
}

.title-emblem {
  font-size: 36px;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.7));
  margin-bottom: 2px;
  opacity: 0;
  pointer-events: none;
}

.game-title {
  font-family: "Noto Serif TC", "Noto Sans TC", serif;
  font-size: clamp(42px, 8vw, 80px);
  font-weight: 900;
  color: #f5d87a;
  letter-spacing: 0.12em;
  text-shadow:
    3px 3px 0 #5a2e00,
    -1px -1px 0 #5a2e00,
    1px -1px 0 #5a2e00,
    -1px 1px 0 #5a2e00,
    0 4px 0 #3a1c00,
    0 8px 16px rgba(0,0,0,0.6);
  line-height: 1.1;
  /* 背景圖已有標題文字，隱藏 HTML 標題避免重疊 */
  display: none;
}

.game-subtitle-bar {
  /* 背景圖已有副標題，隱藏 HTML 版本 */
  display: none;
}

/* ── 雙村標籤（背景圖已有，隱藏 HTML 版本） ── */
.village-labels {
  display: none;
}

.village-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: clamp(16px, 3vw, 26px);
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.05em;
  box-shadow: 0 3px 0 rgba(0,0,0,0.4), 0 6px 18px rgba(0,0,0,0.3);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
}

.village-label--criminal {
  background: linear-gradient(135deg, #9b2020 0%, #c0392b 50%, #9b2020 100%);
  border: 2px solid #e8c873;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%);
  padding-right: 28px;
}

.village-label--procedure {
  background: linear-gradient(135deg, #1a3a5c 0%, #2c5f8a 50%, #1a3a5c 100%);
  border: 2px solid #e8c873;
  clip-path: polygon(12px 0, 100% 0, 100% 100%, 12px 100%, 0 50%);
  padding-left: 28px;
}

.village-label-icon { font-size: 1.1em; }

/* ── 角色 ── */
.char-left, .char-right {
  position: absolute;
  bottom: 18%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.char-left  { left: 2%; }
.char-right { right: 2%; }

.char-sprite { font-size: clamp(28px, 5vw, 52px); }

.char-bubble {
  background: rgba(255,252,240,0.95);
  border: 2px solid #5a3a1a;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: clamp(10px, 1.5vw, 13px);
  color: #3a2010;
  font-weight: bold;
  text-align: center;
  line-height: 1.5;
  box-shadow: 2px 2px 0 #5a3a1a;
  position: relative;
  white-space: nowrap;
}
.char-bubble--left::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #5a3a1a;
}
.char-bubble--right::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #5a3a1a;
}

/* ── 主選單按鈕（木質招牌風格） ── */
.main-menu {
  position: absolute;
  bottom: 9%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(300px, 62vw);
}

/* 木質招牌按鈕基礎樣式 */
.menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0;
  border: none;
  cursor: pointer;
  font-family: "Noto Serif TC", "Noto Sans TC", serif;
  font-size: clamp(17px, 2.8vw, 22px);
  font-weight: 900;
  color: #f5e8c0;
  letter-spacing: 0.15em;
  transition: filter 0.15s, transform 0.12s, box-shadow 0.12s;
  position: relative;
  width: 100%;
  height: clamp(56px, 7.5vw, 68px);
  background: none;
  text-shadow:
    1px 1px 0 rgba(40,20,0,0.9),
    2px 2px 3px rgba(0,0,0,0.6);
}

/* 招牌主體（木板層） */
.menu-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  z-index: -1;
}

/* 招牌左右錠點裝飾 */
.menu-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f5d87a, #8b6914);
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  right: 12px;
  z-index: 2;
}

.menu-btn:hover  { filter: brightness(1.12); transform: translateY(-3px) scale(1.02); }
.menu-btn:active { transform: translateY(2px) scale(0.98); filter: brightness(0.9); }
.menu-btn--selected {
  filter: brightness(1.18);
  transform: translateY(-3px) scale(1.02);
  outline: none;
}
.menu-btn--selected::after {
  box-shadow: 0 0 8px 2px rgba(245,216,122,0.8), 0 1px 3px rgba(0,0,0,0.5);
}

/* 左錠點 */
.menu-btn-nail-left {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f5d87a, #8b6914);
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  z-index: 2;
  pointer-events: none;
}

/* 木板紋理線（透過偽元素模擬） */
.menu-btn-board {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  z-index: 0;
  overflow: hidden;
  /* 外層金色框線 */
  outline: 2px solid rgba(245,216,122,0.5);
  outline-offset: -3px;
}
.menu-btn-board::before {
  content: '';
  position: absolute;
  inset: 0;
  /* 橫向木紋 */
  background-image:
    repeating-linear-gradient(
      180deg,
      rgba(255,255,255,0.05) 0px,
      rgba(255,255,255,0.05) 1px,
      transparent 1px,
      transparent 10px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(0,0,0,0.04) 0px,
      rgba(0,0,0,0.04) 1px,
      transparent 1px,
      transparent 40px
    );
}
.menu-btn-board::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(180deg,
    rgba(255,255,255,0.18) 0%,
    rgba(255,255,255,0.06) 60%,
    transparent 100%
  );
  border-radius: 10px 10px 0 0;
}

.menu-btn-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 0 36px;
}

/* 開始冒險—深藍木板（參考背景圖中的深藍色招牌） */
.menu-btn--start {
  box-shadow:
    0 6px 0 #0a2238,
    0 10px 20px rgba(0,0,0,0.55);
}
.menu-btn--start .menu-btn-board {
  background: linear-gradient(180deg,
    #3578b8 0%,
    #2260a0 25%,
    #1c5290 60%,
    #164878 100%
  );
  border: 3px solid #8bb8e8;
  border-bottom: 6px solid #0a2238;
  border-radius: 10px;
}
.menu-btn--start:hover .menu-btn-board {
  border-color: #aad4ff;
}

/* 法學圖鑑—深綠木板 */
.menu-btn--library {
  box-shadow:
    0 6px 0 #0a2810,
    0 10px 20px rgba(0,0,0,0.55);
}
.menu-btn--library .menu-btn-board {
  background: linear-gradient(180deg,
    #428a48 0%,
    #306835 25%,
    #275a2c 60%,
    #1e4a22 100%
  );
  border: 3px solid #7ec882;
  border-bottom: 6px solid #0a2810;
  border-radius: 10px;
}
.menu-btn--library:hover .menu-btn-board {
  border-color: #a0e0a4;
}

/* 成就系統—深棕木板（參考背景圖中的棕色招牌） */
.menu-btn--achievement {
  box-shadow:
    0 6px 0 #2e1c04,
    0 10px 20px rgba(0,0,0,0.55);
}
.menu-btn--achievement .menu-btn-board {
  background: linear-gradient(180deg,
    #9a6e28 0%,
    #7a5418 25%,
    #684812 60%,
    #56380c 100%
  );
  border: 3px solid #d4a84a;
  border-bottom: 6px solid #2e1c04;
  border-radius: 10px;
}
.menu-btn--achievement:hover .menu-btn-board {
  border-color: #f0c870;
}

.menu-btn-icon {
  font-size: 1.25em;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
.menu-btn-text {
  flex: 1;
  text-align: center;
  font-size: inherit;
}

/* ── 底部提示 ── */
.bottom-hint {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: rgba(20,12,5,0.85);
  border-top: 2px solid #5a3a1a;
  text-align: center;
  padding: 8px;
  font-size: clamp(11px, 1.8vw, 14px);
  color: #f5d87a;
  letter-spacing: 0.1em;
}

/* ===================================================
   遊戲畫面
   =================================================== */
.game-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #1a1a2e;
  z-index: 2;
}
.game-screen.hidden { display: none; }
.main-screen.hidden { display: none; }

#game-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#game-container {
  image-rendering: pixelated;
  border: 3px solid #4e342e;
  border-radius: 4px;
  overflow: hidden;
}

.game-toolbar-overlay {
  background: rgba(20,12,5,0.9);
  border-top: 2px solid #5a3a1a;
  padding: 6px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #d4b896;
  flex-wrap: wrap;
}

.pixel-reset-btn {
  background: #3a1a1a;
  border: 1px solid #7a3a3a;
  color: #ff8a80;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  white-space: nowrap;
}
.pixel-reset-btn:hover { background: #5a2a2a; }

/* ===================================================
   鎮口標題覆蓋層（遊戲內 HTML overlay）
   =================================================== */
.title-overlay {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: flex-end; justify-content: center;
  background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0.35) 100%);
  padding-bottom: 24px;
}
.title-overlay.hidden { display: none; }
.title-dialog {
  background: #fffaf0;
  border: 4px solid #4e342e;
  border-radius: 10px;
  box-shadow: 0 6px 0 #2d1f15, 0 10px 18px rgba(0,0,0,0.3);
  padding: 16px 20px;
  width: 92%; max-width: 480px;
  text-align: center;
  color: #2b2b2b;
}
.title-dialog-label { margin: 6px 0; font-size: 13px; color: #4e342e; font-weight: bold; }
#player-name-input-2 {
  width: 80%; padding: 8px 10px; font-size: 15px;
  border: 2px solid #4e342e; border-radius: 6px; text-align: center;
  margin-bottom: 10px; background: #fff; color: #2b2b2b;
}

/* ===================================================
   Overlay / Modal（像素風格）
   =================================================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}
.overlay.hidden { display: none; }

.pixel-modal {
  background: #1e1408;
  border: 3px solid #8b6914;
  border-radius: 8px;
  padding: 20px;
  max-width: 480px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow:
    0 0 0 1px #5a4008,
    0 8px 0 #3a2a04,
    0 12px 32px rgba(0,0,0,0.6);
  color: #f0e6d3;
}
.pixel-modal--wide { max-width: 600px; }

.pixel-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid #5a4008;
}
.pixel-modal-head h3 {
  font-size: 18px;
  color: #f5d87a;
  font-weight: bold;
}
.pixel-close-btn {
  background: #3a2010;
  border: 2px solid #7a5020;
  color: #f5d87a;
  width: 30px; height: 30px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.pixel-close-btn:hover { background: #5a3010; }

.pixel-modal-label {
  font-size: 13px;
  color: #d4b896;
  font-weight: bold;
  margin: 10px 0 6px;
}
.pixel-modal-desc {
  font-size: 13px;
  color: #a08060;
  margin-bottom: 12px;
}

.pixel-input {
  width: 80%;
  display: block;
  margin: 0 auto 14px;
  padding: 10px 14px;
  font-size: 16px;
  background: #0e0a04;
  border: 2px solid #8b6914;
  border-radius: 4px;
  color: #f5d87a;
  text-align: center;
  font-family: inherit;
  outline: none;
}
.pixel-input:focus { border-color: #f5d87a; box-shadow: 0 0 0 2px rgba(245,216,122,0.3); }

/* ── 村莊選擇按鈕 ── */
.village-choice-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.village-btn {
  flex: 1;
  min-width: 140px;
  max-width: 200px;
  padding: 14px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  color: #fff;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: filter 0.15s, transform 0.1s;
  box-shadow: 0 4px 0 rgba(0,0,0,0.4);
}
.village-btn:hover  { filter: brightness(1.15); transform: translateY(-2px); }
.village-btn:active { transform: translateY(2px); box-shadow: none; }
.village-btn-icon { font-size: 22px; }
.village-btn-title { font-size: 16px; font-weight: bold; }
.village-btn small { font-size: 11px; opacity: 0.85; }
.village-btn-criminal {
  background: linear-gradient(180deg, #c0392b 0%, #8b1a1a 100%);
  border-bottom: 4px solid #5a0a0a;
}
.village-btn-procedure {
  background: linear-gradient(180deg, #2c5f8a 0%, #1a3a5c 100%);
  border-bottom: 4px solid #0a1e30;
}

/* ===================================================
   關卡選單
   =================================================== */
.level-list { display: flex; flex-direction: column; gap: 8px; }
.level-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  border: 2px solid #5a4008;
  border-radius: 6px;
  padding: 10px 14px;
  background: #120e04;
  cursor: pointer;
  font-size: 14px;
  color: #f0e6d3;
  transition: background 0.15s, border-color 0.15s;
}
.level-item:hover { background: #1e1408; border-color: #8b6914; }
.level-item small { color: #a08060; margin-top: 2px; font-size: 12px; }
.level-item.done {
  background: #0a1a0a;
  border-color: #2e7d32;
  color: #a5d6a7;
}
.level-item.done small { color: #66bb6a; }

/* ===================================================
   答題 Modal
   =================================================== */
.quiz-modal { max-width: 560px; }
.quiz-law { font-size: 12px; color: #a08060; margin-bottom: 8px; }
.quiz-story-box {
  background: #0a0804;
  border: 2px solid #5a4008;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}
.quiz-story { font-size: 14px; line-height: 1.8; color: #d4b896; }
.quiz-question { font-weight: bold; margin: 12px 0 8px; color: #f5d87a; font-size: 15px; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.quiz-option {
  padding: 11px 14px;
  border: 2px solid #5a4008;
  border-radius: 6px;
  background: #120e04;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  color: #f0e6d3;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
}
.quiz-option:hover:not(:disabled) { background: #1e1408; border-color: #f5d87a; }
.quiz-option:disabled { opacity: 0.6; cursor: default; }
#quiz-result {
  white-space: pre-wrap;
  font-family: inherit;
  padding: 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.7;
  margin-top: 10px;
}
#quiz-result.correct { background: #0a1a0a; color: #81c784; border: 2px solid #2e7d32; }
#quiz-result.wrong   { background: #1a0a0a; color: #ef9a9a; border: 2px solid #c62828; }
#quiz-result.hidden  { display: none; }

/* ===================================================
   法學圖鑑
   =================================================== */
.library-content { display: flex; flex-direction: column; gap: 8px; }
.library-empty { text-align: center; color: #a08060; padding: 24px; font-size: 14px; line-height: 2; }
.library-item {
  background: #0a0804;
  border: 2px solid #5a4008;
  border-radius: 6px;
  padding: 10px 14px;
}
.library-item-law { font-size: 11px; color: #a08060; }
.library-item-title { font-size: 14px; color: #f0e6d3; font-weight: bold; margin-top: 2px; }

/* ===================================================
   成就系統
   =================================================== */
.achievement-list { display: flex; flex-direction: column; gap: 8px; }
.achievement-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #0a0804;
  border: 2px solid #3a2a04;
  border-radius: 6px;
  padding: 10px 14px;
  opacity: 0.55;
}
.achievement-item--unlocked {
  opacity: 1;
  border-color: #8b6914;
  background: #1a1204;
}
.achievement-icon { font-size: 24px; flex-shrink: 0; }
.achievement-info { flex: 1; }
.achievement-title { font-size: 14px; font-weight: bold; color: #f5d87a; }
.achievement-desc  { font-size: 12px; color: #a08060; margin-top: 2px; }
.achievement-status { font-size: 18px; }

/* ===================================================
   設定
   =================================================== */
.settings-list { display: flex; flex-direction: column; gap: 14px; }
.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #0a0804;
  border: 2px solid #3a2a04;
  border-radius: 6px;
  font-size: 15px;
  color: #d4b896;
}
.settings-divider { border: none; border-top: 1px solid #3a2a04; }
.settings-link {
  display: block;
  text-align: center;
  color: #a08060;
  font-size: 13px;
  text-decoration: underline;
}
.pixel-danger-btn {
  background: #3a0a0a;
  border: 2px solid #7a2a2a;
  color: #ff8a80;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  transition: background 0.15s;
}
.pixel-danger-btn:hover { background: #5a1a1a; }

/* ── 像素切換開關 ── */
.pixel-toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.pixel-toggle input { opacity: 0; width: 0; height: 0; }
.pixel-toggle-slider {
  position: absolute; inset: 0;
  background: #3a2a04;
  border: 2px solid #5a4008;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}
.pixel-toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 2px; top: 2px;
  background: #a08060;
  border-radius: 2px;
  transition: transform 0.2s;
}
.pixel-toggle input:checked + .pixel-toggle-slider { background: #1a4a1a; border-color: #2e7d32; }
.pixel-toggle input:checked + .pixel-toggle-slider::before { transform: translateX(20px); background: #81c784; }

/* ===================================================
   隱私權政策頁
   =================================================== */
.policy-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px;
  line-height: 1.8;
  font-size: 14px;
  color: #f0e6d3;
}
.policy-page h3 { margin-top: 24px; color: #f5d87a; }

/* ===================================================
   響應式
   =================================================== */
@media (max-width: 768px) {
  /* 手機版遊戲畫面：填滿全螢幕，支援橫直螢幕 */
  .game-screen {
    background: #000;
  }
  #game-wrapper {
    position: fixed;
    inset: 0;
    /* 支援 iPhone 安全區域 */
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0)
             env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
    align-items: stretch;
    justify-content: stretch;
  }
  #game-container {
    border: none;
    border-radius: 0;
    width: 100% !important;
    height: 100% !important;
  }
  #game-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
  }
  /* 手機版隱藏底部工具列（操作說明和重設鈕） */
  .game-toolbar-overlay {
    display: none !important;
  }
  /* Modal 在手機上的最大高度限制 */
  .pixel-modal {
    max-height: 85dvh;
    overflow-y: auto;
  }
}

@media (max-width: 600px) {
  .village-labels { top: 22%; }
  .char-left, .char-right { display: none; }
  .main-menu { bottom: 8%; width: 85vw; }
  .menu-btn { font-size: 15px; padding: 11px 16px; }
  .game-title { font-size: 52px; }
}

@media (max-width: 400px) {
  .village-label { font-size: 14px; padding: 5px 12px; }
  .game-title { font-size: 40px; }
}

/* ===================================================
   滾動條美化
   =================================================== */
/* ===================================================
   離開村莊確認對話框按鈕
   =================================================== */
/* ===================================================
   答題後操作按鈕（下一題 / 返回小鎮）
   =================================================== */
.quiz-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.quiz-actions.hidden { display: none; }
.quiz-actions .menu-btn {
  flex: 1;
  min-width: 120px;
  font-size: 14px !important;
  padding: 10px 8px !important;
  height: 48px !important;
  white-space: nowrap;
}
.quiz-actions .menu-btn-content {
  flex-direction: row !important;
  gap: 6px !important;
}

.exit-confirm-btn {
  width: 140px !important;
  height: 52px !important;
  font-size: 15px !important;
  letter-spacing: 0.05em !important;
  white-space: nowrap !important;
  overflow: hidden !important;
}
.exit-confirm-btn .menu-btn-content {
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  gap: 6px !important;
  padding: 0 10px !important;
  white-space: nowrap !important;
}
.exit-confirm-btn .menu-btn-icon {
  font-size: 1.1em !important;
  flex-shrink: 0 !important;
}
.exit-confirm-btn .menu-btn-text {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  font-size: 14px !important;
  letter-spacing: 0.05em !important;
}

::-webkit-scrollbar { width: 6px; }

/* ===================================================
   手機直式專用樣式
   =================================================== */
@media (max-width: 768px) and (orientation: portrait) {
  /* 直式手機：遇戲畫面完全填滿螢幕 */
  html, body {
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
    position: fixed;
  }
  .game-screen {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    background: #000;
  }
  #game-wrapper {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
    display: flex;
  }
  #game-container {
    width: 100vw !important;
    height: 100dvh !important;
    border: none;
    border-radius: 0;
  }
  #game-container canvas {
    width: 100vw !important;
    height: 100dvh !important;
    display: block;
    object-fit: fill;
  }
  /* 直式手機隱藏底部工具列 */
  .game-toolbar-overlay {
    display: none !important;
  }
  /* 直式手機 Modal 高度限制 */
  .pixel-modal {
    max-height: 90dvh;
    overflow-y: auto;
    width: 92vw;
  }
}
::-webkit-scrollbar-track { background: #0a0804; }
::-webkit-scrollbar-thumb { background: #5a4008; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #8b6914; }
