* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  color: #18212f;
  background:
    linear-gradient(135deg, rgba(255, 213, 128, 0.18), transparent 34%),
    linear-gradient(220deg, rgba(38, 166, 154, 0.18), transparent 38%),
    #f5f7fb;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 3vh 3vw;
}

/* =========================================================
   电脑版 (16:9)
   ========================================================= */
.game {
  width: 94vw;
  max-width: 94vw;
  aspect-ratio: 16 / 9;
  max-height: 94vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1.5vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5vw;
}

h1 {
  margin: 0;
  font-size: clamp(20px, 4vw, 48px);
  line-height: 1.08;
  letter-spacing: 0;
}

.stats {
  min-width: 10vw;
  padding: 1vh 1.2vw;
  border: 1px solid #d8dee9;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  text-align: center;
  font-weight: 700;
  white-space: nowrap;
  display: flex;
  gap: 1.2vw;
  font-size: clamp(14px, 2vw, 22px);
}

.photo-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.photo-frame {
  width: 70%;
  aspect-ratio: 16 / 9;
  max-height: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: #101820;
  box-shadow: 0 18px 48px rgba(25, 36, 54, 0.16);
  position: relative;
}

.photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 3vh;
  color: #edf2f7;
  text-align: center;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.16), transparent 45%),
    linear-gradient(35deg, #253447, #151b24 62%, #0d1117);
}

.placeholder strong {
  display: block;
  margin-bottom: 1vh;
  font-size: clamp(18px, 3.5vw, 36px);
}

.placeholder span {
  display: block;
  color: #b9c3d0;
  line-height: 1.6;
  font-size: clamp(13px, 2vw, 20px);
}

/* ========== 结束页面 ========== */
.ending-scene {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 15;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  background-color: transparent;
  color: #ffffff;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 2.5vw;
  padding: 3.5vh 4vw;
}

.ending-scene[hidden] {
  display: none;
}

/* ---- 左侧主内容区 ---- */
.ending-left {
  position: relative;
  z-index: 2;
  flex: 1 1 60%;
  display: flex;
  flex-direction: column;
  gap: 2vh;
  min-width: 0;
  padding-left: 0;
}

/* 左侧上方文字区 */
.ending-text-area {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-top: -2vh;
}

.ending-text-area h2 {
  margin: 0;
  font-size: clamp(48px, 10vw, 120px);
  line-height: 1.05;
  letter-spacing: 0;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.75);
  -webkit-text-stroke: 0.5px #000000;
  text-stroke: 0.5px #000000;
}

.ending-text-area .ending-welcome {
  margin: 0.6vh 0 0;
  font-size: clamp(32px, 5.6vw, 64px);
  font-weight: 900;
  line-height: 1.15;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.75);
  -webkit-text-stroke: 0.5px #000000;
  text-stroke: 0.5px #000000;
}

.ending-text-area .ending-note {
  margin: 0.8vh 0 0 0;
  font-size: clamp(22px, 2.8vw, 32px);
  font-weight: 800;
  line-height: 1.4;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.75);
  -webkit-text-stroke: 0.5px #000000;
  text-stroke: 0.5px #000000;
}

.ending-red {
  color: #ff2c2c;
}

.ending-link {
  display: inline-block;
  margin-top: 1.2vh;
  color: #1a3a6b;
  font-size: clamp(16px, 2vw, 24px);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  transition: color 160ms ease;
}

.ending-link:hover {
  color: #2a5a9b;
}

.ending-group {
  margin: 0.6vh 0 0 0;
  font-size: clamp(14px, 1.8vw, 22px);
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* 左侧下方图片区 */
.ending-left-images {
  flex: 0 0 auto;
  display: flex;
  gap: 1.2vw;
  align-items: flex-end;
}

.ending-left-images .ending-img-item {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #101820;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.38);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
  border: 2px solid rgba(255, 255, 255, 0.32);
}

.ending-left-images .ending-img-item:hover {
  transform: translateY(-3px);
  border-color: #ffffff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.ending-left-images .ending-img-item img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

/* ---- 右侧竖向图片区 ---- */
.ending-right {
  position: relative;
  z-index: 2;
  flex: 0 1 28%;
  display: flex;
  flex-direction: column;
  gap: 1vh;
  justify-content: space-between;
}

.ending-right .ending-img-item {
  flex: 1 1 0;
  min-height: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #101820;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.38);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
  border: 2px solid rgba(255, 255, 255, 0.32);
}

.ending-right .ending-img-item:hover {
  transform: scale(1.04);
  border-color: #ffffff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.ending-right .ending-img-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---- 右下角图标 ---- */
.ending-icon {
  position: fixed;
  right: 2vw;
  bottom: 2vh;
  z-index: 18;
  width: clamp(40px, 5vw, 80px);
  height: auto;
  border-radius: 10px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.48);
  cursor: pointer;
  transition: transform 160ms ease;
}

.ending-icon:hover {
  transform: scale(1.08);
}

.ending-icon[hidden] {
  display: none;
}

/* ---- 旧样式保留兼容 ---- */
.ending-copy { display: none; }
.ending-decor { display: none; }

/* ========== 游戏结束状态 ========== */
.game.is-ended .actions { display: none; }

.omen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 2vh;
  text-align: center;
  font-size: clamp(36px, 10vw, 120px);
  font-weight: 900;
  letter-spacing: 0;
  text-shadow: 0 5px 20px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.omen.good { color: #22c55e; }
.omen.doubt { color: #e11d48; }
.omen[hidden] { display: none; }

.panel { 
  display: grid; 
  gap: 1vh; 
}

.prompt {
  margin: 0;
  min-height: 1.5vh;
  text-align: center;
  color: #4a5568;
  font-weight: 700;
  font-size: clamp(14px, 2vw, 22px);
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.2vw;
}

button {
  min-height: 5vh;
  border: 0;
  border-radius: 8px;
  font-size: clamp(16px, 2.5vw, 30px);
  font-weight: 800;
  color: #ffffff;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

button:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

button:active { transform: translateY(0); }

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.35);
  opacity: 0.72;
}

.yes { background: #197a55; }
.no { background: #b83232; }

.feedback {
  min-height: 2vh;
  margin: 0;
  text-align: center;
  color: #4a5568;
  font-weight: 700;
  font-size: clamp(14px, 2vw, 20px);
}

.feedback.correct { color: #197a55; }
.feedback.wrong { color: #b83232; }

.restart {
  width: 20%;
  min-width: 120px;
  min-height: 4vh;
  margin: 0 auto;
  padding: 0 1.5vw;
  background: #26364a;
  font-size: clamp(14px, 1.6vw, 20px);
}

.restart[hidden] { display: none; }

.blackout {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: #000000;
  color: #dc2626;
  font-size: clamp(36px, 10vw, 130px);
  font-weight: 900;
  letter-spacing: 0;
  text-align: center;
}

.blackout[hidden] { display: none; }

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 3vh;
  background: rgba(0, 0, 0, 0.86);
}

.image-viewer[hidden] { display: none; }

.image-viewer img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border: 3px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.6);
}

.image-viewer-close {
  position: absolute;
  top: 2vh;
  right: 2vw;
  width: 4vw;
  min-height: 4vw;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #ffffff;
  font-size: clamp(20px, 3vw, 38px);
  line-height: 1;
}

/* =========================================================
   手机版 (竖屏, 宽高比 9:20)
   检测条件：宽度 ≤ 768px 且 竖屏
   ========================================================= */
@media (max-width: 768px) and (orientation: portrait) {
  body {
    padding: 1.5vh 1.5vw;
    align-items: flex-start;
    padding-top: 0;
  }

  .game {
    width: 96vw;
    aspect-ratio: 9 / 20;
    max-width: 96vw;
    max-height: 98vh;
    gap: 1vh;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5vh;
  }

  h1 {
    font-size: clamp(18px, 5vw, 28px);
  }

  .stats {
    width: 100%;
    justify-content: space-between;
    text-align: left;
    min-width: 0;
    padding: 0.6vh 1.5vw;
    font-size: clamp(12px, 3vw, 16px);
    gap: 2vw;
  }

  .photo-frame {
    width: 80%;
    aspect-ratio: 4 / 3;
  }

  .placeholder strong {
    font-size: clamp(16px, 4vw, 24px);
    margin-bottom: 0.5vh;
  }

  .placeholder span {
    font-size: clamp(12px, 2.5vw, 16px);
  }

  .actions {
    gap: 2vw;
  }

  button {
    min-height: 4.5vh;
    font-size: clamp(14px, 3.5vw, 22px);
  }

  .prompt {
    font-size: clamp(12px, 3vw, 16px);
    min-height: 1vh;
  }

  .feedback {
    font-size: clamp(12px, 3vw, 16px);
    min-height: 1.5vh;
  }

  .restart {
    width: 50%;
    min-width: 0;
    min-height: 3.5vh;
    font-size: clamp(12px, 3vw, 16px);
  }

  .ending-scene {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100vw;
    height: 100vh;
    aspect-ratio: auto;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    flex-direction: column;
    gap: 1.2vh;
    padding: 2vh 3vw;
  }

  .ending-left {
    flex: 0 0 auto;
    gap: 1vh;
  }

  .ending-text-area {
    flex: 0 0 auto;
  }

  .ending-text-area h2 {
    font-size: clamp(24px, 8vw, 42px);
    text-shadow: 0 5px 20px rgba(0, 0, 0, 0.85);
  }

  .ending-text-area .ending-welcome {
    margin: 0.3vh 0 0;
    font-size: clamp(18px, 5.5vw, 28px);
    text-shadow: 0 5px 20px rgba(0, 0, 0, 0.85);
  }

  .ending-text-area .ending-note {
    margin: 0.4vh 0 0;
    font-size: clamp(14px, 4.2vw, 20px);
    text-shadow: 0 5px 20px rgba(0, 0, 0, 0.85);
  }

  .ending-link {
    font-size: clamp(16px, 3.8vw, 22px);
    margin-top: 0.6vh;
  }

  .ending-group {
    font-size: clamp(16px, 4.2vw, 22px);
    margin: 0.3vh 0 0 0;
  }

  .ending-note-click {
    font-size: clamp(12px, 3vw, 18px);
    margin: 0.8vh 0 0 0;
    text-shadow: 0 3px 12px rgba(0, 0, 0, 0.8);
  }

  .ending-left-images {
    gap: 1.5vw;
    flex-wrap: wrap;
  }

  .ending-left-images .ending-img-item {
    flex: 0 0 auto;
    width: 16vw;
  }

  .ending-right {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 1.5vw;
    overflow-x: auto;
  }

  .ending-right .ending-img-item {
    flex: 0 0 auto;
    width: 16vw;
    min-height: auto;
    aspect-ratio: 4 / 3;
  }

  .ending-icon {
    right: 3vw;
    bottom: 1.5vh;
    width: clamp(32px, 8vw, 56px);
  }

  .omen {
    font-size: clamp(24px, 8vw, 60px);
    padding: 1vh;
  }
}