/* Godot 3.5 Web Game Host Stylesheet */
:root {
  --bg-color: #FAF5ED;
  --panel-bg: #FFFFFF;
  --text-main: #2C2C2C;
  --text-muted: #7A7A7A;
  --border-color: #2C2C2C;
  --primary-color: #D4A373;
  --accent-color: #E76F51;
  --safe-margin: 32px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Zen Maru Gothic", sans-serif;
  color: var(--text-main);
  touch-action: none;
}

/* 遊戲全屏外層容器 (包含 Safe Area 防側滑 32px 內縮保護) */
.game-viewport-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-left: max(var(--safe-margin), env(safe-area-inset-left, 0px));
  padding-right: max(var(--safe-margin), env(safe-area-inset-right, 0px));
  padding-top: env(safe-area-inset-top, 12px);
  padding-bottom: env(safe-area-inset-bottom, 12px);
}

/* 頂部輕量導航條 */
.game-top-bar {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 10px));
  left: max(16px, env(safe-area-inset-left, 16px));
  right: max(16px, env(safe-area-inset-right, 16px));
  height: 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
  pointer-events: none;
}

.top-bar-btn {
  pointer-events: auto;
  background: var(--panel-bg);
  border: 2px solid var(--border-color);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 2px 2px 0 var(--border-color);
  transition: transform 0.1s, box-shadow 0.1s;
  cursor: pointer;
}

.top-bar-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--border-color);
}

/* Godot WebGL Canvas 渲染區域 (720x1280 比例) */
#canvas-container {
  width: 100%;
  height: 100%;
  max-width: 480px;
  max-height: 854px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  background-color: #FAF5ED;
}

/* 兩階段手勢進入卡片 (Two-Stage Splash Gate) */
.splash-gate-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(250, 245, 237, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.splash-gate-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-card {
  width: 100%;
  max-width: 360px;
  background: #FFFFFF;
  border: 3px solid var(--border-color);
  border-radius: 20px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 6px 6px 0 var(--border-color);
}

.splash-mascot {
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
}

.splash-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--text-main);
  margin-bottom: 8px;
}

.splash-desc {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.splash-start-btn {
  width: 100%;
  height: 52px;
  background: #FFD8A8;
  border: 2.5px solid var(--border-color);
  border-radius: 14px;
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
  box-shadow: 3px 3px 0 var(--border-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s, box-shadow 0.1s;
}

.splash-start-btn:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--border-color);
}

.splash-audio-note {
  margin-top: 14px;
  font-size: 11px;
  color: #999;
}

/* 存檔管理對話框 */
.save-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.save-dialog-overlay.active {
  display: flex;
}

.save-dialog-box {
  width: 100%;
  max-width: 360px;
  background: #FFF;
  border: 3px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 4px 4px 0 var(--border-color);
}

.save-textarea {
  width: 100%;
  height: 90px;
  margin: 12px 0;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  font-family: monospace;
  resize: none;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ===== 烘焙流程與步驟迷你遊戲 (Mini-games & Settlement) ===== */
.mini-game-full-overlay {
  position: fixed;
  inset: 0;
  background: rgba(250, 245, 237, 0.96);
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  overflow-y: auto;
  animation: m-fade-in 0.2s ease-out;
}

@keyframes m-fade-in {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes m-fade-in-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.mini-game-container {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 3px solid #2C2C2C;
  border-radius: 20px;
  padding: 24px 20px;
  box-shadow: 6px 6px 0 #2C2C2C;
  background: #FFFDF8;
  position: relative;
}

.step-progress-badge {
  display: inline-block;
  background: #FFD8A8;
  border: 1.5px solid #2C2C2C;
  border-radius: 12px;
  padding: 3px 12px;
  font-size: 11px;
  font-weight: 800;
  color: #2C2C2C;
  margin-bottom: 10px;
}

.mini-game-header {
  text-align: center;
  margin-bottom: 18px;
  width: 100%;
}

.mini-game-header h3 {
  font-size: 20px;
  font-weight: 900;
  color: #2C2C2C;
  margin: 0 0 6px;
}

.mini-game-header p {
  font-size: 13px;
  color: #7A7A7A;
  font-weight: 700;
  margin: 0;
}

#m-game-content {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-bottom: 20px;
  position: relative;
}

#m-game-action {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.m-game-counter {
  font-size: 22px;
  font-weight: 900;
  color: #2C2C2C;
  margin-top: 14px;
  font-family: monospace;
}

.recipe-detail-ingredients {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 0;
  margin: 12px 0 16px;
}

.recipe-detail-ingredients li {
  background: #FAF5ED;
  border: 2px solid #2C2C2C;
  border-radius: 10px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 800;
  color: #2C2C2C;
  box-shadow: 2px 2px 0 #2C2C2C;
  animation: m-fade-in-up 0.3s ease forwards;
}

.recipe-detail-action-btn {
  width: 100%;
  height: 48px;
  background: #FFD8A8;
  border: 2.5px solid #2C2C2C;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  color: #2C2C2C;
  box-shadow: 3px 3px 0 #2C2C2C;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s, box-shadow 0.1s;
}

.recipe-detail-action-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #2C2C2C;
}

.recipe-detail-action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* 1. 秤量量杯樣式 */
.m-game-weigh-cup {
  width: 80px;
  height: 140px;
  border: 3.5px solid #2C2C2C;
  border-radius: 8px;
  position: relative;
  background: #FFF;
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse;
}

.m-weigh-fill {
  width: 100%;
  height: 0%;
  background: #F5EBE0;
  border-top: 2px dashed #2C2C2C;
  transition: height 0.05s linear;
}

.m-weigh-target-line {
  position: absolute;
  bottom: 75%;
  left: 0;
  width: 100%;
  height: 6px;
  background: #81B29A;
  border-top: 1.5px solid #2C2C2C;
  border-bottom: 1.5px solid #2C2C2C;
  pointer-events: none;
  z-index: 10;
}

.m-weigh-target-label {
  position: absolute;
  bottom: 76%;
  right: 4px;
  font-size: 9px;
  font-weight: bold;
  color: #2E7D32;
  z-index: 12;
  pointer-events: none;
}

/* 2. 攪拌碗樣式 */
.m-game-bowl {
  width: 200px;
  height: 120px;
  border: 3.5px solid #2C2C2C;
  border-radius: 0 0 100px 100px;
  position: relative;
  background: #FEF3E8;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: none;
  touch-action: none;
  cursor: pointer;
}

.m-mix-stick {
  width: 12px;
  height: 110px;
  background: #D4A373;
  border: 2px solid #2C2C2C;
  border-radius: 6px;
  transform-origin: top center;
  transform: rotate(0deg);
  position: absolute;
  top: 10px;
  transition: transform 0.1s ease;
  pointer-events: none;
}

/* 3. 揉麵/發酵盒樣式 */
.m-game-dough-box {
  width: 100%;
  height: 150px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  border: 3px dashed #2C2C2C;
  border-radius: 16px;
  background: #FEF3E8;
  overflow: hidden;
}

.m-knead-dough {
  font-size: 64px;
  line-height: 1;
  transition: transform 0.1s ease;
  user-select: none;
}

.is-pressed {
  background: #FFB380 !important;
  transform: translateY(2px);
  box-shadow: 1px 1px 0 #2C2C2C !important;
}

/* 4. 發酵圈圈 */
.m-ferment-target-ring {
  position: absolute;
  width: 120px;
  height: 120px;
  border: 4px dashed #81B29A;
  border-radius: 50%;
  opacity: 0.7;
  pointer-events: none;
}

.m-ferment-dough {
  font-size: 44px;
  line-height: 1;
  transition: transform 0.1s ease;
  user-select: none;
}

/* 5. 塑形拖曳區 */
.m-shape-area {
  width: 280px;
  height: 150px;
  border: 3px dashed #2C2C2C;
  border-radius: 16px;
  position: relative;
  background: #FEF3E8;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  touch-action: none;
  cursor: grab;
}

.m-shape-target {
  width: 220px;
  height: 70px;
  border: 2.5px dashed rgba(44, 44, 44, 0.35);
  border-radius: 35px;
  position: absolute;
  pointer-events: none;
  display: flex;
  justify-content: center;
  align-items: center;
  color: rgba(44, 44, 44, 0.4);
  font-size: 11px;
  font-weight: bold;
}

.m-shape-dough {
  width: 100px;
  height: 70px;
  background: #F4E8D1;
  border: 3px solid #2C2C2C;
  border-radius: 35px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 32px;
  pointer-events: none;
  transition: width 0.1s, border-radius 0.1s;
}

/* 6. 火候溫度計與滑桿 */
.m-heat-dial-box {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 10px 0;
}

.m-heat-slider-container {
  width: 100%;
  max-width: 280px;
  position: relative;
  height: 36px;
  display: flex;
  align-items: center;
}

.m-heat-green-zone {
  position: absolute;
  left: 40%;
  width: 20%;
  height: 18px;
  background: #81B29A;
  border: 1.5px solid #2C2C2C;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0.85;
  z-index: 1;
}

.m-heat-slider {
  width: 100%;
  height: 10px;
  border: 2.5px solid #2C2C2C;
  border-radius: 999px;
  background: #E8E5DF;
  outline: none;
  position: relative;
  z-index: 2;
  -webkit-appearance: none;
  appearance: none;
}

.m-heat-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border: 2.5px solid #2C2C2C;
  border-radius: 50%;
  background: #E07A5F;
  cursor: pointer;
  box-shadow: 0 2px 0 #2C2C2C;
  transition: transform 0.1s;
}

.m-hud-xp-bar {
  width: 100%;
  max-width: 260px;
  height: 14px;
  background: #E8E5DF;
  border: 2px solid #2C2C2C;
  border-radius: 7px;
  overflow: hidden;
}

/* 7. 出爐評分結算彈窗 */
.settlement-card {
  width: 100%;
  max-width: 380px;
  background: #FFFDF8;
  border: 3px solid #2C2C2C;
  border-radius: 20px;
  padding: 24px 20px;
  box-shadow: 6px 6px 0 #2C2C2C;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.settlement-icon {
  font-size: 54px;
  margin: 4px 0;
  transition: filter 0.2s ease;
}

.settlement-stars {
  font-size: 30px;
  letter-spacing: 6px;
  color: #FFA94D;
  height: 36px;
}

.settlement-details {
  width: 100%;
  border: 2px solid #2C2C2C;
  border-radius: 12px;
  background: #FFFFFF;
  padding: 12px;
  font-size: 13px;
  color: #2C2C2C;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settlement-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settlement-levelup {
  width: 100%;
  background: #FFE89C;
  border: 2px solid #2C2C2C;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 13px;
  color: #2C2C2C;
  text-align: center;
}

