/*
 * style.css — 全站樣式
 *
 * 走童趣、明亮、大按鈕的風格，適合國小孩子在電腦或平板上點。
 * 配色以暖色 + 天藍為主，避免太刺眼。
 */

/* ── 基本重置與全站底色 ── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  /* 天空漸層背景，營造活潑感 */
  background: linear-gradient(160deg, #aee9ff 0%, #fff7e0 100%);
  color: #37474f;
  min-height: 100vh;
  padding: 20px;
  -webkit-font-smoothing: antialiased;
}

/* ── 標題區 ── */
.app-header {
  text-align: center;
  margin-bottom: 20px;
}

.app-header h1 {
  font-size: 2.4rem;
  color: #ff7043;
  text-shadow: 2px 2px 0 #fff;
}

.app-subtitle {
  font-size: 1.1rem;
  color: #5d7079;
  margin-top: 6px;
}

/* ── 模式切換列 ── */
.mode-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.mode-btn {
  font-size: 1rem;
  padding: 10px 18px;
  border: 3px solid #90caf9;
  background: #fff;
  color: #1976d2;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.15s;
}

.mode-btn:hover {
  transform: translateY(-2px);
}

.mode-btn-active {
  background: #1976d2;
  color: #fff;
  border-color: #1976d2;
}

/* ── 關卡卡片格狀排列 ── */
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  max-width: 900px;
  margin: 0 auto;
}

.level-card {
  position: relative;
  background: #fff;
  border: none;
  border-radius: 20px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 6px 0 #ffd180, 0 8px 16px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.level-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 0 #ffb74d, 0 12px 20px rgba(0, 0, 0, 0.16);
}

.level-card:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #ffd180, 0 4px 8px rgba(0, 0, 0, 0.12);
}

/* 未開放的卡片：變灰、降低存在感 */
.level-card-locked {
  filter: grayscale(0.7);
  opacity: 0.75;
  box-shadow: 0 6px 0 #cfd8dc, 0 8px 16px rgba(0, 0, 0, 0.1);
}

.level-card-locked:hover {
  box-shadow: 0 8px 0 #b0bec5, 0 10px 18px rgba(0, 0, 0, 0.12);
}

.level-icon {
  font-size: 3rem;
  line-height: 1;
}

.level-no {
  font-size: 0.85rem;
  color: #ff7043;
  font-weight: bold;
  margin-top: 8px;
}

.level-title {
  font-size: 1.3rem;
  font-weight: bold;
  color: #37474f;
  margin-top: 4px;
}

.level-desc {
  font-size: 0.9rem;
  color: #78909c;
  margin-top: 8px;
  min-height: 2.4em;
}

/* 「即將推出」標籤 */
.level-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #b0bec5;
  color: #fff;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 10px;
}

/* ── 頁腳 ── */
.app-footer {
  margin-top: 1.5rem;
  padding: 0.6rem 0;
  border-top: 1px solid #cfe9f8;  /* 天藍色分隔線，呼應背景漸層 */
  text-align: center;
}

.footer-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.footer-copyright {
  font-size: 0.78rem;
  color: #aab7be;
  line-height: 1.6;
}

.footer-copyright a {
  color: #1976d2;           /* 沿用全站的藍色按鈕色 */
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.footer-copyright a:hover {
  color: #ff7043;           /* hover 換橘色，呼應標題主色 */
  text-decoration: underline;
}

.footer-divider {
  display: inline-block;
  margin: 0 0.5rem;
  color: #b0bec5;
}

/* ── 通用按鈕 ── */
.btn {
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 18px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.1s, filter 0.1s;
}

.btn:hover {
  filter: brightness(1.05);
}

.btn:active {
  transform: translateY(2px);
}

.btn-primary {
  background: #42a5f5;
  color: #fff;
  box-shadow: 0 4px 0 #1e88e5;
}

.btn-secondary {
  background: #eceff1;
  color: #455a64;
  box-shadow: 0 4px 0 #cfd8dc;
}

.btn-warning {
  background: #ffb74d;
  color: #fff;
  box-shadow: 0 4px 0 #fb8c00;
}

/* ===== 水杯遊戲 ===== */
.wc-wrap {
  max-width: 640px;
  margin: 0 auto;
  background: #fff;
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.wc-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.wc-progress {
  font-weight: bold;
  color: #1976d2;
  font-size: 1.05rem;
}

.wc-timer {
  color: #e53935;
  font-weight: bold;
}

.wc-question {
  text-align: center;
  font-size: 1.5rem;
  margin-top: 8px;
}

.wc-target {
  color: #e53935;
  font-weight: bold;
  font-size: 1.8rem;
}

.wc-hint {
  text-align: center;
  color: #78909c;
  font-size: 1rem;
  margin-top: 4px;
}

/* 舞台：水杯 + 角色並排 */
.wc-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 10px 0;
}

.wc-canvas {
  /* Canvas 本身尺寸由 JS 設定，這裡只給點視覺 */
}

.wc-character {
  align-self: flex-end;
}

.wc-current {
  text-align: center;
  font-size: 1.2rem;
  font-weight: bold;
  color: #1976d2;
}

.wc-message {
  text-align: center;
  min-height: 1.8em;
  font-size: 1.1rem;
  margin: 8px 0;
  color: #607d8b;
}

/* 答對：綠色開心 */
.wc-message-good {
  color: #43a047;
  font-weight: bold;
}

/* 溢出：橘色提醒（不用紅色大叉，降低挫敗感）*/
.wc-message-warn {
  color: #fb8c00;
  font-weight: bold;
}

/* 選項區 + 控制列的共同容器：column 排列，整體置中 */
.wc-button-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 12px 0;
}

/* 水滴按鈕區：不再自行置中，由父容器負責 */
.wc-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.wc-drop {
  font-size: 1.2rem;
  min-width: 64px;
  padding: 12px 16px;
}

/* 已點過的水滴按鈕：變灰、游標禁止，直到倒掉重來才恢復 */
.wc-drop-used {
  background: #cfd8dc !important;
  color: #90a4ae !important;
  box-shadow: 0 4px 0 #b0bec5 !important;
  cursor: not-allowed !important;
  opacity: 0.65;
}

.wc-drop-used:hover {
  filter: none !important;
  transform: none !important;
}

.wc-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%; /* 與 .wc-options 等寬，讓兩顆按鈕對齊選項左右邊界 */
  margin-top: 6px;
}

/* ===== 天秤遊戲 ===== */
.sc-wrap {
  max-width: 680px;
  margin: 0 auto;
  background: #fff;
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.sc-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.sc-progress {
  font-weight: bold;
  color: #5c6bc0;
  font-size: 1.05rem;
}

.sc-question {
  text-align: center;
  font-size: 1.5rem;
  margin-top: 8px;
}

.sc-target {
  color: #e64a19;
  font-weight: bold;
  font-size: 1.8rem;
}

.sc-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 0;
}

.sc-canvas {
  max-width: 100%;
}

.sc-character {
  align-self: flex-end;
}

.sc-current {
  text-align: center;
  font-size: 1.1rem;
  font-weight: bold;
  color: #5c6bc0;
  min-height: 1.5em;
}

.sc-message {
  text-align: center;
  min-height: 1.8em;
  font-size: 1.1rem;
  margin: 8px 0;
  color: #607d8b;
}

.sc-message-good {
  color: #43a047;
  font-weight: bold;
}

.sc-message-warn {
  color: #fb8c00;
  font-weight: bold;
}

/* 積木按鈕 + 控制列共同容器 */
.sc-button-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 10px 0;
}

/* 積木選項列 */
.sc-blocks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.sc-block-btn {
  font-size: 1.2rem;
  min-width: 72px;
  padding: 12px 16px;
}

/* 已放上秤盤的積木按鈕：深色邊框 + 輕微凹陷感 */
.sc-block-selected {
  background: #1565c0 !important;
  box-shadow: 0 2px 0 #0d47a1 !important;
  transform: translateY(2px);
}

/* 控制列：清空（左） | 確定（正中） | 下一題（右）
   用 1fr auto 1fr 三欄 Grid，讓確定永遠置中，
   不受左右按鈕有無顯示的影響。 */
.sc-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  margin-top: 8px;
}

.sc-controls > :first-child {
  justify-self: start;
}

.sc-controls > :last-child {
  justify-self: end;
}

/* ===== 披薩遊戲 ===== */
.pz-wrap {
  max-width: 680px;
  margin: 0 auto;
  background: #fff;
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.pz-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.pz-progress {
  font-weight: bold;
  color: #d84315;
  font-size: 1.05rem;
}

.pz-question {
  text-align: center;
  font-size: 1.5rem;
  margin-top: 8px;
}

.pz-target {
  color: #d84315;
  font-weight: bold;
  font-size: 1.8rem;
}

.pz-hint {
  text-align: center;
  color: #78909c;
  font-size: 1rem;
  min-height: 1.5em;
  margin-top: 4px;
}

.pz-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 10px 0;
}

.pz-canvas {
  width: min(320px, 100%);
  max-width: 320px;
  height: auto;
  cursor: pointer;
  touch-action: manipulation;
}

.pz-character {
  align-self: flex-end;
}

.pz-action-row {
  text-align: center;
  min-height: 48px;
  margin-top: 2px;
}

.pz-confirm {
  min-width: 120px;
  font-size: 1.15rem;
}

.pz-message {
  text-align: center;
  min-height: 1.8em;
  font-size: 1.1rem;
  margin: 8px 0;
  color: #607d8b;
}

.pz-message-good {
  color: #43a047;
  font-weight: bold;
}

.pz-message-warn {
  color: #fb8c00;
  font-weight: bold;
}

.pz-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: 6px;
}

@media (max-width: 560px) {
  .pz-stage {
    flex-direction: column;
  }

  .pz-character {
    display: none;
  }
}

/* ===== 積木橋遊戲 ===== */
.br-wrap {
  max-width: 640px;
  margin: 0 auto;
  background: #fff;
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.br-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.br-progress {
  font-weight: bold;
  color: #2e7d32;
  font-size: 1.05rem;
}

.br-question {
  text-align: center;
  font-size: 1.5rem;
  margin-top: 8px;
}

.br-target {
  color: #e65100;
  font-weight: bold;
  font-size: 1.8rem;
}

.br-canvas {
  display: block;
  margin: 8px auto;
  max-width: 100%;
}

.br-current {
  text-align: center;
  font-size: 1.1rem;
  font-weight: bold;
  color: #2e7d32;
  min-height: 1.5em;
}

.br-message {
  text-align: center;
  min-height: 1.8em;
  font-size: 1.1rem;
  margin: 8px 0;
  color: #607d8b;
}

.br-message-good { color: #43a047; font-weight: bold; }
.br-message-warn { color: #fb8c00; font-weight: bold; }

.br-button-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 10px 0;
}

.br-blocks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.br-block-btn {
  font-size: 1.2rem;
  min-width: 72px;
  padding: 12px 16px;
}

/* 控制列：清空（左）| 確定（中）| 下一題（右） */
.br-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  margin-top: 8px;
}

.br-controls > :first-child { justify-self: start; }
.br-controls > :last-child  { justify-self: end; }

/* ===== 結算畫面 ===== */
.result-panel {
  max-width: 480px;
  margin: 40px auto;
  background: #fff;
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.result-stars {
  font-size: 3rem;
  color: #ffc107;
  letter-spacing: 8px;
}

.result-headline {
  font-size: 1.4rem;
  font-weight: bold;
  color: #ff7043;
  margin: 16px 0;
}

.result-score {
  font-size: 1.2rem;
  color: #455a64;
  margin-bottom: 24px;
}

.result-buttons {
  display: flex;
  justify-content: center;
  gap: 14px;
}

/* ===== 披薩對戰模式 ===== */
.pvs-wrap {
  max-width: 1200px;
  margin: 0 auto;
  background: #fff;
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.pvs-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.pvs-progress {
  font-weight: bold;
  color: #d84315;
  font-size: 1.05rem;
}

.pvs-question {
  text-align: center;
  font-size: 1.5rem;
  margin-top: 8px;
}

.pvs-hint {
  text-align: center;
  color: #78909c;
  font-size: 1rem;
  min-height: 1.5em;
  margin: 4px 0 10px;
}

/* 倒數計時圓 */
.pvs-timer {
  width: 72px;
  height: 72px;
  line-height: 72px;
  border-radius: 50%;
  text-align: center;
  font-size: 2.2rem;
  font-weight: bold;
  color: #1976d2;
  background: #e3f2fd;
  margin: 6px auto 2px;
  transition: color 0.3s, background 0.3s;
}

/* 剩 5 秒以下：紅色 + 跳動動畫 */
.pvs-timer-urgent {
  color: #e53935;
  background: #ffebee;
  animation: pvs-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pvs-pulse {
  from { transform: scale(1.0); }
  to   { transform: scale(1.12); }
}

/* 對戰舞台：兩個玩家面板左右並排 */
.pvs-arena {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  margin: 8px 0;
}

/* 中間分隔線 */
.pvs-divider {
  width: 4px;
  background: linear-gradient(to bottom, #ffb74d, #ff7043, #ffb74d);
  border-radius: 4px;
  align-self: stretch;
  margin: 0 10px;
  flex-shrink: 0;
}

/* 玩家面板：flex 縱向排列 */
.pvs-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  border-radius: 16px;
  background: #fafafa;
  transition: background 0.3s, outline 0.3s;
  min-width: 0;
}

/* 答對：綠色邊框 + 淡綠背景 */
.pvs-panel-correct {
  background: #f1f8e9;
  outline: 3px solid #66bb6a;
}

/* 答錯：橙色邊框 + 淡橙背景 */
.pvs-panel-wrong {
  background: #fff3e0;
  outline: 2px solid #ffb74d;
}

/* 已提交等待對方：紫藍邊框 + 淡藍背景 */
.pvs-panel-waiting {
  background: #e8eaf6;
  outline: 3px solid #7986cb;
}

/* 玩家名稱（置中，不顯示分數）*/
.pvs-player-name {
  font-size: 1.1rem;
  font-weight: bold;
  color: #37474f;
  text-align: center;
  width: 100%;
  padding: 4px 0 8px;
}

/* 披薩 + 角色容器 */
.pvs-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.pvs-canvas {
  width: min(220px, 100%);
  max-width: 220px;
  height: auto;
  cursor: pointer;
  touch-action: manipulation;
}

.pvs-character {
  align-self: flex-end;
}

/* 按鈕列：確定、清掉重塗、我放棄 */
.pvs-controls {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: nowrap;
  justify-content: center;
}

.pvs-confirm {
  min-width: 72px;
}

.pvs-message {
  text-align: center;
  min-height: 2.4em;
  font-size: 0.92rem;
  margin: 10px 4px 0;
  color: #607d8b;
  word-break: break-all;
}

.pvs-message-good { color: #43a047; font-weight: bold; }
.pvs-message-warn { color: #fb8c00; font-weight: bold; }
.pvs-message-wait { color: #7986cb; font-weight: bold; }

/* 共用「下一題」按鈕（置中，兩人都完成後才出現）*/
.pvs-next {
  display: block;
  margin: 14px auto 0;
  font-size: 1.15rem;
  padding: 12px 36px;
}

/* 對戰結算畫面 */
.pvs-result {
  max-width: 580px;
  margin: 40px auto;
  background: #fff;
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.pvs-result-title {
  font-size: 1.8rem;
  font-weight: bold;
  color: #ff7043;
  margin-bottom: 24px;
}

.pvs-result-scores {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.pvs-result-player {
  background: #f5f5f5;
  border-radius: 16px;
  padding: 16px 28px;
  min-width: 120px;
}

.pvs-result-winner {
  background: #f1f8e9;
  outline: 3px solid #66bb6a;
}

.pvs-result-name {
  font-size: 1rem;
  color: #78909c;
  margin-bottom: 8px;
}

.pvs-result-stars {
  font-size: 1.6rem;
  letter-spacing: 3px;
  margin: 8px 0 4px;
}

.pvs-result-score-big {
  font-size: 1.6rem;
  font-weight: bold;
  color: #37474f;
}

.pvs-result-winner .pvs-result-score-big {
  color: #43a047;
}

.pvs-result-vs {
  font-size: 1.6rem;
  font-weight: bold;
  color: #b0bec5;
}

.pvs-result-btns {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* 手機：上下改為垂直排列 */
@media (max-width: 620px) {
  .pvs-arena {
    flex-direction: column;
    align-items: center;
  }

  .pvs-divider {
    width: 100%;
    height: 4px;
    margin: 8px 0;
  }

  .pvs-panel {
    width: 100%;
  }
}
