/* ============================================================
   26字母和音节趣味小游戏 - 手机横屏版
   ============================================================ */

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Comic Sans MS", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(160deg, #4facfe 0%, #00f2fe 100%);
}

body {
  position: relative;
}

/* ---------- 横屏提示 ---------- */
#rotate-tip {
  display: none;
}

/* 竖屏时提示旋转手机 */
@media (orientation: portrait) {
  #rotate-tip {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: linear-gradient(160deg, #4facfe 0%, #00f2fe 100%);
    color: #fff;
    text-align: center;
    padding: 30px;
  }
  #rotate-tip .phone {
    width: 90px;
    height: 150px;
    border: 6px solid #fff;
    border-radius: 18px;
    position: relative;
    animation: spin 1.6s ease-in-out infinite;
  }
  #rotate-tip .phone::after {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 5px;
    background: #fff;
    border-radius: 3px;
  }
  #rotate-tip p {
    font-size: 20px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  }
  @keyframes spin {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
    100% { transform: rotate(90deg); }
  }
}

/* ---------- 通用屏幕 ---------- */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  padding: 10px;
}

.screen.active {
  display: flex;
}

/* ---------- 顶部栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 14px;
  padding: 6px 12px;
  margin-bottom: 8px;
  backdrop-filter: blur(4px);
}

.topbar .btn-back {
  font-size: 26px;
  background: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  line-height: 38px;
  text-align: center;
  color: #333;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  flex: none;
}

.topbar .title {
  flex: 1;
  text-align: center;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .hud {
  display: flex;
  gap: 6px;
  align-items: center;
}

.hud-item {
  background: #fff;
  color: #333;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 14px;
  font-weight: bold;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.hud-item.star {
  background: #ffe14d;
  color: #8a5a00;
}

.hud-item.time {
  background: #ff7a59;
  color: #fff;
}

/* ---------- 主区域 ---------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 0;
  position: relative;
}

/* ---------- 首页 ---------- */
#home .brand {
  text-align: center;
  margin: 6px 0 2px;
}

#home .brand h1 {
  font-size: 20px;
  color: #fff;
  text-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
  letter-spacing: 2px;
}

#home .brand p {
  color: rgba(255, 255, 255, 0.95);
  font-size: 14px;
  margin-top: 4px;
}

.game-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 640px;
  flex: 1;
  min-height: 0;
}

.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 16px;
  color: #fff;
  cursor: pointer;
  border: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
  text-align: center;
  padding: 6px;
}

.game-card:active {
  transform: scale(0.94);
}

.game-card .g-icon {
  font-size: 34px;
}

.game-card .g-name {
  font-size: 16px;
  font-weight: bold;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.game-card .g-desc {
  font-size: 11px;
  opacity: 0.95;
}

.gc1 { background: linear-gradient(135deg, #ff9a56, #ff5e62); }
.gc2 { background: linear-gradient(135deg, #43e97b, #38b6ff); }
.gc3 { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }
.gc4 { background: linear-gradient(135deg, #f6d365, #fda085); }

.footbar {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.footbar .btn {
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  border: none;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ---------- 通用按钮 ---------- */
.btn {
  cursor: pointer;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  transition: transform 0.12s;
}

.btn:active {
  transform: scale(0.93);
}

.btn.big {
  font-size: 18px;
  font-weight: bold;
  padding: 10px 26px;
  color: #fff;
  background: linear-gradient(135deg, #ff9a56, #ff5e62);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
}

.btn.green {
  background: linear-gradient(135deg, #43e97b, #38b6ff);
}

.btn.gray {
  background: rgba(255, 255, 255, 0.85);
  color: #555;
  font-size: 14px;
  padding: 8px 18px;
}

/* ---------- 游戏1：字母闪电 ---------- */
.flash-area {
  position: relative;
  width: 100%;
  max-width: 560px;
  height: 40%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flash-card {
  width: 180px;
  height: 180px;
  background: #fff;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 110px;
  font-weight: bold;
  color: #2b6cb0;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
}

.flash-card.pop {
  animation: pop 0.35s ease-out;
}

.flash-card.upper { color: #e53e3e; }

@keyframes pop {
  0% { transform: scale(0.2); opacity: 0; }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.hidden-letter {
  color: #888;
  font-size: 18px;
  font-weight: bold;
}

/* 底部选项 */
.options-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 560px;
  margin-top: 10px;
}

.opt-btn {
  height: 74px;
  border-radius: 14px;
  background: #fff;
  color: #2b6cb0;
  font-size: 38px;
  font-weight: bold;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.12s, background 0.2s;
}

.opt-btn:active { transform: scale(0.92); }

.opt-btn.correct {
  background: #68d391;
  color: #fff;
  border-color: #2f855a;
  animation: shake-glow 0.5s;
}

.opt-btn.wrong {
  background: #fc8181;
  color: #fff;
  border-color: #c53030;
  animation: shake 0.4s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

@keyframes shake-glow {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.15); }
}

/* 音效提示条 */
.say-hint {
  background: rgba(255, 255, 255, 0.35);
  color: #fff;
  border-radius: 20px;
  padding: 6px 18px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  border: none;
}

#g1-replay {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 2;
}

/* ---------- 游戏2：拼图拼音节 ---------- */
.target-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.target-label {
  color: rgba(255, 255, 255, 0.95);
  font-size: 14px;
  font-weight: bold;
}

.target-syllable {
  display: flex;
  gap: 10px;
}

.slot {
  width: 74px;
  height: 84px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.3);
  border: 3px dashed rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: bold;
  color: #fff;
}

.slot.filled {
  background: #fff;
  color: #e53e3e;
  border-style: solid;
  border-color: #fff;
  animation: pop 0.3s ease-out;
}

.target-sound {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  color: #2b6cb0;
  font-size: 20px;
  border: none;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

.alphabet-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 620px;
}

.a-tile {
  height: 52px;
  border-radius: 12px;
  background: #fff;
  color: #2b6cb0;
  font-size: 26px;
  font-weight: bold;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s;
}

.a-tile:active { transform: scale(0.9); }

.a-tile.used {
  opacity: 0.35;
  pointer-events: none;
}

.a-tile.answer {
  background: #68d391;
  color: #fff;
  animation: shake-glow 0.4s;
}

/* ---------- 游戏3：听音捉迷藏 ---------- */
.listen-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 620px;
}

.listen-speaker {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f6d365, #fda085);
  color: #fff;
  font-size: 30px;
  border: none;
  cursor: pointer;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-sound 1.2s ease-in-out infinite;
  position: absolute;
  top: 8px;
  right: 40px;
  z-index: 2;
}

@keyframes pulse-sound {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.listen-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 620px;
}

.listen-tile {
  height: 84px;
  border-radius: 14px;
  background: #fff;
  color: #2b6cb0;
  font-size: 40px;
  font-weight: bold;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 3px solid transparent;
}

.listen-tile.correct {
  background: #68d391;
  color: #fff;
  border-color: #2f855a;
  animation: shake-glow 0.5s;
}

.listen-tile.wrong {
  background: #fc8181;
  color: #fff;
  border-color: #c53030;
  animation: shake 0.4s;
}

/* ---------- 游戏4：音节接龙 ---------- */
.chain-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chain-prev {
  background: #fff;
  color: #333;
  font-size: 34px;
  font-weight: bold;
  border-radius: 14px;
  padding: 6px 18px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

.chain-arrow {
  color: #fff;
  font-size: 26px;
  font-weight: bold;
}

.chain-req {
  background: #ffe14d;
  color: #8a5a00;
  border-radius: 30px;
  padding: 6px 20px;
  font-size: 18px;
  font-weight: bold;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

.chain-build {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.chain-letter {
  width: 70px;
  height: 70px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: bold;
  background: #fff;
  color: #e53e3e;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

.chain-letter.first {
  background: #ffe14d;
  color: #8a5a00;
}

.chain-answer-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.chain-seq {
  background: #fff;
  color: #2b6cb0;
  border-radius: 10px;
  font-size: 13px;
  padding: 5px 9px;
  font-weight: bold;
}

/* 游戏4：音节接龙 左右布局（左1/3 main，右2/3 字母区） */
#game4 {
  flex-direction: row;
  flex-wrap: wrap;
}

#game4 .topbar {
  flex: 0 0 100%;
  height: 52px;
  padding: 6px 12px;
  margin-bottom: 4px;
}

#game4 .main {
  flex: 1 1 33.333%;
  min-width: 0;
  overflow-y: auto;
  padding-right: 8px;
}

#game4 #g4-tiles {
  flex: 1 1 66.666%;
  min-width: 0;
  max-width: none;
}

#game4 .chain-info,
#game4 .chain-answer-row {
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------- 结果弹层 ---------- */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.overlay.active {
  display: flex;
}

.result-box {
  background: #fff;
  border-radius: 22px;
  padding: 24px 32px;
  text-align: center;
  max-width: 90%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: pop 0.4s ease-out;
}

.result-box .r-title {
  font-size: 26px;
  font-weight: bold;
  color: #e53e3e;
  margin-bottom: 8px;
}

.result-box .r-score {
  font-size: 18px;
  color: #555;
  margin-bottom: 6px;
}

.result-box .r-msg {
  font-size: 14px;
  color: #888;
  margin-bottom: 16px;
}

.result-box .r-stars {
  font-size: 34px;
  margin-bottom: 12px;
  letter-spacing: 4px;
}

.result-box .r-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- 弹窗/Toast ---------- */
.toast {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  border-radius: 30px;
  padding: 10px 22px;
  font-size: 16px;
  font-weight: bold;
  z-index: 60;
  display: none;
  text-align: center;
  white-space: nowrap;
}

/* ---------- 帮助弹窗 ---------- */
.help-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 70;
}

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

.help-box {
  background: #fff;
  border-radius: 20px;
  padding: 20px 24px;
  max-width: 90%;
  max-height: 90%;
  overflow-y: auto;
  text-align: left;
  line-height: 1.8;
  font-size: 15px;
  color: #444;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.help-box h3 {
  color: #e53e3e;
  text-align: center;
  margin-bottom: 8px;
  font-size: 20px;
}

.help-box .help-actions {
  text-align: center;
  margin-top: 14px;
}

/* 游戏1：模式选择 */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.mode-btn {
  background: linear-gradient(135deg, #ff9a56, #ff5e62);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 12px 10px;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: inherit;
}

.mode-btn:active {
  transform: scale(0.93);
}

.mode-btn .m-title {
  font-size: 17px;
  font-weight: bold;
}

.mode-btn .m-desc {
  font-size: 11px;
  opacity: 0.95;
}
