:root {
  color-scheme: light;
  --page-background: #fff8f1;
  --text-color: #674c50;
  --muted-color: #80676a;
  --pink: #df6489;
  --white: #fffefd;
  --card-radius: 28px;
  --focus-color: #9c3d69;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text-color);
  background: var(--page-background);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button { font: inherit; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
body.is-playing { overflow: hidden; }

.home-page {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 100vh;
  background: radial-gradient(ellipse at 5% 5%, #ffe5e8 0, transparent 35%),
    radial-gradient(ellipse at 95% 22%, #e4f2eb 0, transparent 30%);
}
.home-page::before, .home-page::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 160px;
  height: 48px;
  border-radius: 100px;
  background: #ffffffb3;
  box-shadow: 32px -24px 0 -5px #ffffffb3, 78px -10px 0 -7px #ffffffb3;
  pointer-events: none;
}
.home-page::before { top: 115px; left: max(-80px, calc(50% - 540px)); transform: rotate(-8deg); }
.home-page::after { top: 180px; right: max(-90px, calc(50% - 530px)); transform: rotate(8deg); }
.welcome { text-align: center; padding: 38px 20px 32px; }
.welcome-badge { display: inline-block; font-size: 13px; letter-spacing: 2px; color: var(--muted-color); }
.house-emblem { position: relative; width: fit-content; margin: 19px auto 4px; font-size: 68px; line-height: 1.2; }
.house-emblem span { position: absolute; right: -24px; top: 2px; color: #e7ad4d; font-size: 30px; transform: rotate(12deg); }
h1 { margin: 8px 0 10px; font-size: clamp(34px, 5vw, 48px); letter-spacing: 3px; font-weight: 800; }
h1 span { color: var(--pink); }
.welcome-subtitle { margin: 0; font-size: 18px; letter-spacing: 2px; }
.played-count { display: inline-block; margin: 20px 0 0; padding: 10px 20px; border: 1px solid #f1dcd6; border-radius: 50px; background: #ffffffb3; color: #876148; font-size: 14px; }
.game-sections { width: min(1320px, 100%); margin: 0 auto; padding: 0 36px; }
.game-section { margin-bottom: 42px; }
.section-heading { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.section-heading::after { content: ""; height: 1px; flex: 1; background: #eadcd3; }
.section-heading h2 { flex-shrink: 0; margin: 0; font-size: 22px; letter-spacing: 1px; }
.game-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 20px; }
.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-width: 0;
  min-height: 224px;
  padding: 25px 14px 20px;
  border: 2px solid #ffffffd9;
  border-radius: var(--card-radius);
  color: var(--text-color);
  background: var(--card-color, #ffe3e8);
  box-shadow: 0 6px 0 #dac6bd26, 0 10px 20px #77523e08;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.game-emoji { font-size: 68px; line-height: 1.2; margin-bottom: 16px; filter: drop-shadow(0 4px 1px #ffffff5c); }
.game-title { font-size: 20px; line-height: 1.5; font-weight: 750; overflow-wrap: anywhere; }
.game-tip { margin-top: 8px; font-size: 12px; line-height: 1.7; color: #735c60; text-wrap: pretty; }
.played-sticker { position: absolute; right: 9px; top: 8px; font-size: 24px; transform: rotate(12deg); }
button:focus-visible { outline: 3px solid var(--focus-color); outline-offset: 5px; }
.game-card:active { transform: scale(.97); }
footer { padding: 6px 20px 32px; text-align: center; font-size: 12px; line-height: 1.8; color: var(--muted-color); }
.noscript-message { padding: 20px; text-align: center; }
.game-player { position: fixed; inset: 0; z-index: 10; background: var(--white); overscroll-behavior: contain; }
.game-player iframe { display: block; width: 100%; height: 100%; border: 0; background: var(--white); }
.home-button {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  display: grid;
  place-items: center;
  /* kids-games 改动：缩小并降低未按时的不透明度，减少遮挡游戏。 */
  width: 48px;
  height: 48px;
  padding: 0;
  border: 2px solid #ffffffd9;
  border-radius: 50%;
  background: #ffd2e0d9;
  box-shadow: 0 3px 12px #674c5026;
  font-size: 26px;
  cursor: pointer;
  opacity: .55;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.home-button.is-holding, .home-button:focus-visible { opacity: 1; }
.home-progress { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; transform: rotate(-90deg); }
.home-progress circle { fill: none; stroke: #c94f7d; stroke-width: 3; stroke-dasharray: 1; stroke-dashoffset: 1; }
.home-button.is-holding .home-progress circle { animation: home-hold-progress var(--home-hold-duration) linear forwards; }
@keyframes home-hold-progress { to { stroke-dashoffset: 0; } }
.home-hint {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: calc(max(12px, env(safe-area-inset-left)) + 58px);
  max-width: calc(100% - 88px);
  margin: 0;
  padding: 10px 14px;
  border-radius: 18px;
  background: #fff0f7f2;
  color: #9c3d69;
  box-shadow: 0 3px 12px #674c5026;
  font-size: 14px;
  pointer-events: none;
}
.home-hint::before { content: ""; position: absolute; left: -6px; top: 14px; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-right: 7px solid #fff0f7f2; }
@media (hover: hover) {
  .game-card:hover { transform: translateY(-5px); box-shadow: 0 10px 0 #dac6bd26, 0 14px 24px #77523e0d; }
  .home-button:hover { background: #ffc4d8; }
}
@media (min-width: 1500px) {
  .game-sections { width: min(1560px, 100%); }
  .game-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 1100px) { .game-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 850px) { .game-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .welcome { padding: 28px 16px 30px; }
  .welcome-badge { font-size: 11px; letter-spacing: 1px; }
  .game-sections { padding: 0 16px; }
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .section-heading { gap: 10px; margin-bottom: 16px; }
  .section-heading h2 { font-size: 19px; }
  .game-card { min-height: 218px; padding: 23px 9px 17px; border-radius: 23px; }
  .game-emoji { font-size: 64px; margin-bottom: 12px; }
  .game-title { font-size: 18px; }
  .game-tip { font-size: 12px; }
  .game-section { margin-bottom: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .game-card:hover, .game-card:active { transform: none; }
}

/* kids-games 改动：音乐开关仅放首页，触控尺寸至少 44px。 */
.music-button {
  position: absolute;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid #ffffffd9;
  border-radius: 50%;
  background: #ffd2e0d9;
  box-shadow: 0 3px 12px #674c5026;
  font-size: 22px;
  cursor: pointer;
  touch-action: manipulation;
}
.home-music-button { top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); }
/* kids-games 改动：播放层的音乐开关随小房子提示短暂出现，排在小房子正下方。 */
.player-music-button {
  top: calc(max(12px, env(safe-area-inset-top)) + 56px);
  left: calc(max(12px, env(safe-area-inset-left)) + 2px);
}
.player-music-button[hidden] { display: none; }
