:root {
  --bg-top: #f3d06f;
  --bg-bottom: #f08a5d;
  --bg-glow: rgba(255, 255, 255, 0.4);
  --page-cloud-opacity-back: 0.22;
  --page-cloud-opacity-front: 0.32;
  --page-rain-opacity: 0;
  --frame: #3d2b35;
  --paper: #fff4d6;
  --button: #ffde59;
  --button-shadow: #d56f3a;
  --text: #302024;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.4), transparent 28%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 18px;
  transition: background 1.6s ease, color 1.2s ease;
  position: relative;
  overflow-x: hidden;
}

.page-weather {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.page-clouds,
.page-rain {
  position: absolute;
  inset: 0;
}

.page-clouds-back,
.page-clouds-front,
.page-rain {
  transition: opacity 1.6s ease;
}

.page-clouds::before,
.page-clouds::after {
  content: "";
  position: absolute;
  inset: 0;
  background-repeat: repeat-x;
}

.page-clouds-back::before,
.page-clouds-back::after {
  opacity: var(--page-cloud-opacity-back);
}

.page-clouds-front::before,
.page-clouds-front::after {
  opacity: var(--page-cloud-opacity-front);
}

.page-clouds-back::before {
  top: 44px;
  height: 180px;
  background-size: 420px 180px;
  background-image:
    radial-gradient(circle at 24px 24px, rgba(255, 255, 255, 0.9) 0 18px, transparent 19px),
    radial-gradient(circle at 68px 18px, rgba(255, 255, 255, 0.86) 0 24px, transparent 25px),
    radial-gradient(circle at 116px 28px, rgba(255, 255, 255, 0.82) 0 20px, transparent 21px),
    linear-gradient(rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.84)),
    linear-gradient(rgba(223, 235, 247, 0.46), rgba(223, 235, 247, 0.46));
  background-position:
    26px 30px,
    26px 30px,
    26px 30px,
    40px 52px,
    44px 64px;
  background-size:
    152px 78px,
    152px 78px,
    152px 78px,
    120px 18px,
    108px 12px;
  animation: drift-clouds-back 46s linear infinite;
}

.page-clouds-back::after {
  top: 186px;
  height: 140px;
  background-size: 360px 140px;
  background-image:
    radial-gradient(circle at 18px 16px, rgba(255, 255, 255, 0.78) 0 14px, transparent 15px),
    radial-gradient(circle at 52px 12px, rgba(255, 255, 255, 0.74) 0 18px, transparent 19px),
    radial-gradient(circle at 92px 20px, rgba(255, 255, 255, 0.7) 0 15px, transparent 16px),
    linear-gradient(rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.68)),
    linear-gradient(rgba(216, 228, 241, 0.38), rgba(216, 228, 241, 0.38));
  background-position:
    14px 20px,
    14px 20px,
    14px 20px,
    24px 34px,
    28px 44px;
  background-size:
    120px 54px,
    120px 54px,
    120px 54px,
    92px 14px,
    84px 10px;
  animation: drift-clouds-mid 62s linear infinite;
}

.page-clouds-front::before {
  top: 92px;
  height: 210px;
  background-size: 520px 210px;
  background-image:
    radial-gradient(circle at 30px 28px, rgba(255, 255, 255, 0.96) 0 22px, transparent 23px),
    radial-gradient(circle at 84px 18px, rgba(255, 255, 255, 0.94) 0 30px, transparent 31px),
    radial-gradient(circle at 144px 30px, rgba(255, 255, 255, 0.88) 0 24px, transparent 25px),
    radial-gradient(circle at 182px 40px, rgba(255, 255, 255, 0.84) 0 18px, transparent 19px),
    linear-gradient(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.9)),
    linear-gradient(rgba(226, 238, 249, 0.44), rgba(226, 238, 249, 0.44));
  background-position:
    34px 42px,
    34px 42px,
    34px 42px,
    34px 42px,
    52px 72px,
    58px 88px;
  background-size:
    220px 104px,
    220px 104px,
    220px 104px,
    220px 104px,
    166px 22px,
    148px 14px;
  animation: drift-clouds-front 32s linear infinite;
}

.page-clouds-front::after {
  top: 250px;
  height: 110px;
  background-size: 440px 110px;
  background-image:
    radial-gradient(circle at 24px 16px, rgba(255, 255, 255, 0.78) 0 16px, transparent 17px),
    radial-gradient(circle at 62px 12px, rgba(255, 255, 255, 0.72) 0 20px, transparent 21px),
    radial-gradient(circle at 104px 20px, rgba(255, 255, 255, 0.66) 0 14px, transparent 15px),
    linear-gradient(rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.7));
  background-position:
    22px 14px,
    22px 14px,
    22px 14px,
    34px 28px;
  background-size:
    132px 52px,
    132px 52px,
    132px 52px,
    102px 12px;
  animation: drift-clouds-front 28s linear infinite reverse;
}

.page-rain {
  opacity: var(--page-rain-opacity);
  background-image:
    repeating-linear-gradient(
      102deg,
      rgba(126, 171, 219, 0) 0 18px,
      rgba(126, 171, 219, 0.52) 18px 20px,
      rgba(186, 214, 244, 0.62) 20px 22px,
      rgba(126, 171, 219, 0) 22px 42px
    );
  background-size: 160px 160px;
  animation: fall-rain 0.9s linear infinite;
}

.shell {
  width: min(1720px, 100%);
  display: grid;
  grid-template-columns: minmax(280px, 3fr) minmax(0, 9fr);
  gap: 18px;
  align-items: start;
  position: relative;
  z-index: 1;
}

.hero {
  padding: 18px 22px;
  border: 4px solid var(--frame);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 244, 214, 0.96)),
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.14),
      rgba(255, 255, 255, 0.14) 12px,
      transparent 12px,
      transparent 24px
    );
  box-shadow: 0 14px 0 rgba(61, 43, 53, 0.24);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(32px, 5vw, 48px);
  line-height: 1;
}

.summary,
.hint {
  margin: 0;
  line-height: 1.55;
}

.summary {
  font-size: 18px;
}

.story-hook {
  margin: 10px 0 0;
  font-size: 15px;
  line-height: 1.7;
  color: rgba(48, 32, 36, 0.86);
}

.hero-copy {
  min-width: 0;
}

.hero-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.speed-controls {
  width: 100%;
  padding: 10px 14px;
  border: 3px solid rgba(61, 43, 53, 0.42);
  border-radius: 16px;
  background: rgba(255, 248, 224, 0.82);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.speed-label {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 700;
}

.speed-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.speed-button {
  min-width: 78px;
  padding: 8px 14px;
  border-radius: 12px;
  border-width: 2px;
  box-shadow: 0 4px 0 rgba(213, 111, 58, 0.55);
  font-size: 14px;
}

.speed-button.is-active {
  background: #ffb76b;
  box-shadow: 0 3px 0 rgba(161, 84, 37, 0.7);
}

.guide {
  min-width: 0;
  width: 100%;
  padding: 12px 16px;
  border: 3px solid rgba(61, 43, 53, 0.55);
  border-radius: 16px;
  background: rgba(255, 249, 229, 0.78);
}

.guide-title {
  margin: 0 0 8px;
  font-weight: 700;
}

.future-slot {
  width: 100%;
  padding: 12px 16px;
  border: 3px dashed rgba(61, 43, 53, 0.34);
  border-radius: 16px;
  background: rgba(255, 243, 218, 0.56);
}

.future-copy {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(48, 32, 36, 0.84);
}

.guide .hint {
  font-size: 15px;
  line-height: 1.6;
}

button {
  border: 3px solid var(--frame);
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--button);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--button-shadow);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

button:hover {
  transform: translateY(1px);
  box-shadow: 0 4px 0 var(--button-shadow);
}

button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--button-shadow);
}

button:disabled {
  cursor: default;
  opacity: 0.72;
  transform: none;
  box-shadow: 0 3px 0 rgba(61, 43, 53, 0.18);
}

.stage {
  display: flex;
  justify-content: center;
  width: 100%;
  min-width: 0;
}

canvas {
  width: 100%;
  max-width: 1420px;
  height: auto;
  display: block;
  border: 6px solid var(--frame);
  border-radius: 20px;
  background: #88c9ff;
  box-shadow: 0 18px 0 rgba(61, 43, 53, 0.24);
  image-rendering: pixelated;
  position: relative;
  z-index: 1;
}

@media (max-width: 1500px) {
  body {
    padding: 12px;
  }

  .shell {
    width: 100%;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .hero {
    padding: 12px 14px;
    gap: 10px;
  }

  .hero-copy,
  .guide,
  .future-slot {
    display: none;
  }

  .hero-controls {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
  }

  .actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .actions button {
    min-width: 140px;
    padding: 10px 16px;
  }

  .speed-controls {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    padding: 8px 12px;
  }

  .speed-label {
    font-size: 13px;
  }

  .speed-buttons {
    justify-content: flex-end;
  }

  .speed-button {
    min-width: 70px;
    padding: 7px 10px;
    font-size: 13px;
  }

  .stage {
    justify-content: flex-start;
  }

  canvas {
    max-width: none;
    border-width: 4px;
    border-radius: 16px;
    box-shadow: 0 12px 0 rgba(61, 43, 53, 0.2);
  }
}

@keyframes drift-clouds-back {
  from {
    transform: translateX(-120px);
  }
  to {
    transform: translateX(120px);
  }
}

@keyframes drift-clouds-mid {
  from {
    transform: translateX(-90px);
  }
  to {
    transform: translateX(90px);
  }
}

@keyframes drift-clouds-front {
  from {
    transform: translateX(-160px);
  }
  to {
    transform: translateX(140px);
  }
}

@keyframes fall-rain {
  from {
    background-position: 0 -120px;
  }
  to {
    background-position: 38px 120px;
  }
}

@media (max-width: 980px) {
  body {
    padding: 10px;
  }

  .hero {
    gap: 8px;
    padding: 10px 12px;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button {
    flex: 1 1 0;
    min-width: 0;
  }

  .speed-controls {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .speed-buttons {
    width: 100%;
    justify-content: stretch;
  }

  .speed-button {
    flex: 1 1 0;
    min-width: 0;
  }
}
