* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: #0b0f19;
  font-family: 'Microsoft JhengHei', 'PingFang TC', 'Noto Sans TC', sans-serif;
  margin: 0;
  padding: 0;
}

/* 16:9 Game Viewport Container */
#game-viewport {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1920px;
  height: 1080px;
  transform-origin: center center;
  transform: translate(-50%, -50%) scale(1);
  overflow: hidden;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.9);
  background-color: #000;
}

.scene {
  position: absolute;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  background-size: cover;
  background-position: center;
  display: none;
  z-index: 10;
}

.scene.active {
  display: block;
}

/* Common UI Elements */
.btn-press {
  cursor: pointer;
  transition: transform 0.1s, filter 0.1s;
}

.btn-press:hover {
  filter: brightness(1.1);
  transform: scale(1.04);
}

.btn-press:active {
  transform: scale(0.96);
  filter: brightness(0.9);
}

/* Global Top Control Bar */
.top-controls {
  position: absolute;
  top: 30px;
  right: 40px;
  display: flex;
  gap: 20px;
  z-index: 100;
}

.icon-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 4px solid #ffaa00;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  cursor: pointer;
  transition: transform 0.1s;
}

.icon-btn:hover {
  transform: scale(1.1);
}

.back-btn {
  position: absolute;
  top: 30px;
  left: 40px;
  background: #ffaa00;
  color: #fff;
  border: 3px solid #fff;
  border-radius: 35px;
  padding: 10px 30px;
  font-size: 28px;
  font-weight: bold;
  box-shadow: 0 5px 15px rgba(0,0,0,0.4);
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Home Scene - Single crisp 1920x1080 background */
#scene-home {
  background-image: url('../assets/images/index_day_bg.png');
  background-size: 100% 100%;
}

.home-buttons {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 40px;
  align-items: center;
  z-index: 50;
}

.home-start-btn {
  width: 285px;
  height: 97px;
  background-image: url('../assets/images/index_start_btn.png');
  background-size: contain;
  background-repeat: no-repeat;
  cursor: pointer;
}

.home-help-btn {
  width: 107px;
  height: 106px;
  background-image: url('../assets/images/index_help_btn.png');
  background-size: contain;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* Stage Selection Scene */
#scene-stage {
  background-image: url('../assets/images/stage_bg.png');
}

.stage-header {
  position: absolute;
  top: 30px;
  left: 0;
  width: 100%;
  text-align: center;
  pointer-events: none;
}

.stage-title {
  display: inline-block;
  background: linear-gradient(180deg, #fffae6 0%, #ffd066 100%);
  color: #5c2d00;
  font-size: 46px;
  font-weight: 900;
  padding: 12px 60px;
  border-radius: 40px;
  border: 5px solid #fff;
  box-shadow: 0 8px 25px rgba(0,0,0,0.5);
}

.stage-grid-container {
  position: absolute;
  top: 140px;
  left: 50%;
  transform: translateX(-50%);
  width: 1700px;
  height: 780px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-gap: 25px 20px;
  justify-items: center;
  align-items: center;
}

.stage-card {
  position: relative;
  width: 130px;
  height: 130px;
  background: radial-gradient(circle, #fff9e6 40%, #ffcf70 100%);
  border: 4px solid #fff;
  border-radius: 30px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.stage-card:hover {
  transform: scale(1.1) translateY(-6px);
  box-shadow: 0 14px 28px rgba(255, 170, 0, 0.5);
  border-color: #ffe066;
}

.stage-char {
  font-size: 56px;
  font-weight: 900;
  color: #4a2700;
  text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

.stage-card-stars {
  margin-top: 4px;
  display: flex;
  gap: 3px;
}

.stage-star-icon {
  width: 22px;
  height: 22px;
  background-size: contain;
  background-repeat: no-repeat;
}

.stage-star-icon.on {
  background-image: url('../assets/images/stage_star_on.png');
}

.stage-star-icon.off {
  background-image: url('../assets/images/stage_star_off.png');
}

.stage-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 40px;
  margin-bottom: 20px;
}

.page-btn {
  background: #ff9900;
  color: #fff;
  border: 3px solid #fff;
  border-radius: 25px;
  padding: 8px 30px;
  font-size: 26px;
  font-weight: bold;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  cursor: pointer;
}

.page-indicator {
  color: #fff;
  font-size: 30px;
  font-weight: bold;
  text-shadow: 2px 2px 5px rgba(0,0,0,0.8);
}

/* Practice Mode Scene */
#scene-practice {
  background-image: url('../assets/images/game1_bg.png');
}

.practice-header {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 50px;
  background: rgba(0, 0, 0, 0.6);
  padding: 10px 45px;
  border-radius: 35px;
  border: 3px solid #ffcc00;
  box-shadow: 0 5px 20px rgba(0,0,0,0.5);
  z-index: 50;
}

.header-info-item {
  color: #fff;
  font-size: 30px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-highlight {
  color: #ffe600;
  font-size: 34px;
}

/* 3 Monster Stations */
.monsters-container {
  position: absolute;
  top: 130px;
  left: 50%;
  transform: translateX(-50%);
  width: 1700px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.monster-station {
  position: relative;
  width: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Speech Bubble */
.monster-bubble {
  position: relative;
  width: 460px;
  min-height: 180px;
  background-image: url('../assets/images/thinking_large.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  padding: 30px 40px 50px 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
  animation: floatBubble 3s ease-in-out infinite;
}

@keyframes floatBubble {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}

.bubble-text {
  color: #4a2700;
  font-size: 27px;
  font-weight: 800;
  line-height: 1.4;
  word-break: break-word;
}

/* Monster Body & Animations */
.monster-avatar-box {
  position: relative;
  width: 320px;
  height: 300px;
  margin-top: 10px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.monster-halo {
  position: absolute;
  bottom: 0;
  width: 350px;
  height: 100px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center bottom;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.monster-station.drag-over .monster-halo {
  opacity: 1;
  transform: scale(1.15);
  filter: drop-shadow(0 0 15px #ffff00);
}

.monster-img {
  position: relative;
  max-width: 300px;
  max-height: 290px;
  object-fit: contain;
  z-index: 5;
  transition: transform 0.15s;
}

.monster-station.drag-over .monster-img {
  transform: scale(1.08);
}

.monster-eating {
  animation: monsterChew 0.25s infinite alternate;
}

@keyframes monsterChew {
  from { transform: scale(1); }
  to { transform: scale(1.12) translateY(-10px); }
}

/* 6 Food Plates */
.foods-container {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  width: 1650px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.food-slot {
  position: relative;
  width: 244px;
  height: 211px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.food-plate {
  position: relative;
  width: 244px;
  height: 211px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  transition: transform 0.15s;
}

.food-plate:hover {
  transform: scale(1.05);
}

.food-plate.dragging {
  cursor: grabbing;
  z-index: 1000 !important;
  pointer-events: none;
  transform: scale(1.2);
  filter: drop-shadow(0 15px 25px rgba(0,0,0,0.6));
}

.food-text {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #3b1d00;
  font-size: 38px;
  font-weight: 900;
  text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.9), -2px -2px 4px rgba(255, 255, 255, 0.9);
  pointer-events: none;
  white-space: nowrap;
}

/* Feedback FX (Checkmark / Cross) */
.feedback-fx {
  position: absolute;
  width: 180px;
  height: 180px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: 1500;
  pointer-events: none;
  animation: popFeedback 0.6s ease-out forwards;
}

.feedback-fx.correct {
  background-image: url('../assets/images/game2_correct.png');
}

.feedback-fx.wrong {
  background-image: url('../assets/images/game2_wrong.png');
}

@keyframes popFeedback {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  50% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.1); opacity: 0; }
}

/* Result Scene */
#scene-result {
  background-image: url('../assets/images/result_bg.png');
}

.result-board {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 1460px;
  height: 900px;
  background-image: url('../assets/images/result_pop_bg.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  padding: 50px 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.result-stars-row {
  margin-top: 10px;
  display: flex;
  gap: 30px;
  align-items: center;
}

.result-star {
  width: 100px;
  height: 100px;
  background-size: contain;
  background-repeat: no-repeat;
  background-image: url('../assets/images/result_star_off.png');
  transition: transform 0.4s;
}

.result-star.active {
  background-image: url('../assets/images/result_star_on.png');
  animation: starBounce 0.6s ease-out forwards;
}

@keyframes starBounce {
  0% { transform: scale(0.2) rotate(-45deg); opacity: 0; }
  60% { transform: scale(1.3) rotate(15deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}

.result-time-banner {
  margin-top: 15px;
  width: 500px;
  height: 80px;
  background-image: url('../assets/images/result_time_bg.png');
  background-size: 100% 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 34px;
  font-weight: 900;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.result-table-container {
  margin-top: 25px;
  width: 100%;
  flex: 1;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 25px;
  border: 4px solid #ffaa00;
  overflow-y: auto;
  padding: 20px;
}

.result-sense-row {
  display: flex;
  border-bottom: 2px dashed #e0aa60;
  padding: 15px 10px;
  align-items: center;
}

.result-sense-row:last-child {
  border-bottom: none;
}

.result-sense-desc {
  width: 380px;
  font-size: 26px;
  font-weight: bold;
  color: #5c2d00;
  padding-right: 20px;
  border-right: 3px solid #ffd080;
}

.result-words-list {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  padding-left: 20px;
}

.result-word-badge {
  padding: 8px 24px;
  border-radius: 20px;
  font-size: 28px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  transition: transform 0.1s, box-shadow 0.1s;
  background: #ffffff;
  color: #2e7d32;
  border: 3px solid #81c784;
}

.result-word-badge:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 15px rgba(0,0,0,0.25);
}

.result-word-badge.error-word {
  color: #d32f2f !important;
  border-color: #e57373 !important;
  background-color: #ffebee !important;
}

.result-hint {
  text-align: center;
  color: #6d4c41;
  font-size: 22px;
  font-weight: bold;
  margin-top: 10px;
}

.result-buttons {
  margin-top: 20px;
  display: flex;
  gap: 50px;
}

.result-action-btn {
  background: linear-gradient(180deg, #ffbb33 0%, #ff8800 100%);
  color: #fff;
  border: 4px solid #fff;
  border-radius: 35px;
  padding: 12px 45px;
  font-size: 30px;
  font-weight: 900;
  box-shadow: 0 6px 15px rgba(0,0,0,0.3);
  cursor: pointer;
}

/* Modals */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-overlay.active {
  display: flex;
}

/* Stage Pop Modal */
.stage-pop-card {
  position: relative;
  width: 1000px;
  height: 650px;
  background-image: url('../assets/images/stage_pop_bg.png');
  background-size: 100% 100%;
  padding: 60px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.stage-pop-title {
  color: #ffffff;
  font-size: 58px;
  font-weight: 900;
  margin-top: 20px;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.8), 0 0 25px rgba(255, 200, 0, 0.7);
  letter-spacing: 2px;
}

.stage-pop-desc {
  color: #ffffff;
  font-size: 30px;
  font-weight: bold;
  text-align: center;
  line-height: 1.7;
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.85);
  background: rgba(0, 25, 70, 0.45);
  padding: 15px 35px;
  border-radius: 20px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.stage-pop-desc b {
  color: #ffe600;
  font-size: 34px;
}

.stage-pop-buttons {
  display: flex;
  gap: 40px;
  margin-bottom: 20px;
}

.stage-pop-btn {
  width: 250px;
  height: 85px;
  background-size: contain;
  background-repeat: no-repeat;
  cursor: pointer;
}

.stage-pop-btn.start {
  background-image: url('../assets/images/stage_start_btn.png');
}

.stage-pop-btn.challenge {
  background-image: url('../assets/images/stage_challenge_on_btn.png');
}

.modal-close-btn {
  position: absolute;
  top: 30px;
  right: 40px;
  width: 60px;
  height: 60px;
  background: #ff4444;
  color: #fff;
  border-radius: 50%;
  border: 4px solid #fff;
  font-size: 36px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Sentence Modal */
.sentence-card {
  position: relative;
  width: 900px;
  background: #fffdf5;
  border: 6px solid #ffaa00;
  border-radius: 35px;
  padding: 50px 60px;
  box-shadow: 0 15px 40px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.sentence-word-header {
  display: flex;
  align-items: baseline;
  gap: 20px;
  border-bottom: 4px solid #ffe082;
  padding-bottom: 15px;
}

.sentence-word-name {
  font-size: 56px;
  font-weight: 900;
  color: #e65100;
}

.sentence-target-char {
  font-size: 32px;
  color: #795548;
  font-weight: bold;
}

.sentence-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sentence-field-label {
  font-size: 24px;
  font-weight: bold;
  color: #ff8f00;
}

.sentence-field-value {
  font-size: 32px;
  font-weight: bold;
  color: #37474f;
  line-height: 1.5;
  background: #fff8e1;
  padding: 15px 25px;
  border-radius: 20px;
  border: 2px solid #ffecb3;
}

.sentence-field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-tts {
  background: linear-gradient(180deg, #ffcc00 0%, #ff9900 100%);
  color: #5c2d00;
  border: 2px solid #fff;
  border-radius: 20px;
  padding: 4px 16px;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,0.2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.1s, filter 0.1s;
}

.btn-tts:hover {
  transform: scale(1.08);
  filter: brightness(1.1);
}

.btn-tts:active {
  transform: scale(0.95);
}

.bubble-tts-hint {
  font-size: 16px;
  color: #ff8800;
  margin-top: 4px;
  opacity: 0.8;
}

/* Help Modal Carousel */
.help-card {
  position: relative;
  width: 1400px;
  height: 850px;
  background: #fff;
  border-radius: 30px;
  border: 8px solid #ffaa00;
  box-shadow: 0 15px 40px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.help-slide-img {
  max-width: 95%;
  max-height: 80%;
  object-fit: contain;
}

.help-controls {
  position: absolute;
  bottom: 30px;
  display: flex;
  align-items: center;
  gap: 40px;
}

/* Challenge Mode Scene */
#scene-challenge {
  background-image: url('../assets/images/game2_bg.png');
}

.challenge-monster-box {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.challenge-bubble {
  width: 480px;
  min-height: 140px;
  background-image: url('../assets/images/thinking_large.png');
  background-size: 100% 100%;
  padding: 25px 40px 40px 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #4a2700;
  font-size: 30px;
  font-weight: 900;
}

.challenge-monster-img {
  width: 320px;
  height: 250px;
  object-fit: contain;
}

.challenge-words-zone {
  position: absolute;
  top: 150px;
  left: 50%;
  transform: translateX(-50%);
  width: 1600px;
  height: 480px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-gap: 30px;
  align-items: center;
  justify-items: center;
}

.challenge-word-card {
  width: 320px;
  height: 120px;
  background: linear-gradient(180deg, #ffffff 0%, #fffae6 100%);
  border: 5px solid #ffaa00;
  border-radius: 35px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  font-weight: 900;
  color: #3b1d00;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.challenge-word-card:hover {
  transform: scale(1.08) translateY(-4px);
  box-shadow: 0 12px 25px rgba(255, 170, 0, 0.5);
  border-color: #ff8800;
}
