html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "Microsoft JhengHei", "Segoe UI", Arial, sans-serif;
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  background: #101418;
  color: #eef4f7;
}

button,
input,
select {
  font: inherit;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

#cesiumContainer {
  position: absolute;
  inset: 0;
}

#rainOverlay {
  display: none;
  position: absolute;
  inset: -20%;
  z-index: 1;
  pointer-events: none;
  opacity: var(--rain-opacity, 0);
  background-image:
    repeating-linear-gradient(
      112deg,
      rgba(210, 238, 255, 0) 0 10px,
      rgba(210, 238, 255, 0.34) 11px 12px,
      rgba(210, 238, 255, 0) 13px 30px
    );
  background-size: 160px 220px;
  mix-blend-mode: screen;
  transform: skewX(-8deg);
  transition: opacity 160ms ease;
  animation: rainSweep 520ms linear infinite;
}

#rainOverlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      112deg,
      rgba(255, 255, 255, 0) 0 18px,
      rgba(255, 255, 255, 0.18) 19px 20px,
      rgba(255, 255, 255, 0) 21px 58px
    );
  background-size: 220px 280px;
  opacity: 0.52;
  animation: rainSweep 720ms linear infinite;
}

.stage-panel {
  position: absolute;
  top: 18px;
  left: 18px;
  width: min(380px, calc(100vw - 36px));
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(9, 15, 20, 0.92);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.86);
  z-index: 2;
}

.stage-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.stage-title h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
}

.stage-title span {
  font-size: 12px;
  color: #9ad7ff;
  white-space: nowrap;
}

.control-group {
  margin: 14px 0;
}

.alert-banner {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  margin: 8px 0 14px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(68, 136, 255, 0.14);
  color: #d9ecff;
}

.alert-banner span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 26px;
  border-radius: 4px;
  background: #287bd9;
  font-size: 12px;
  font-weight: 700;
}

.alert-banner strong {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
}

.alert-banner.is-warning {
  background: rgba(244, 163, 64, 0.16);
  color: #fff1dc;
}

.alert-banner.is-warning span {
  background: #f4a340;
  color: #201307;
}

.alert-banner.is-critical {
  background: rgba(255, 95, 86, 0.2);
  color: #fff0ee;
  animation: panelPulse 1.1s ease-in-out infinite;
}

.alert-banner.is-critical span {
  background: #ff5f56;
  color: #260908;
}

.control-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #c9d8df;
  font-size: 15px;
  font-weight: 700;
}

.control-label strong {
  color: #ffffff;
}

input[type="range"] {
  width: 100%;
  accent-color: #4cc3ff;
}

.rain-control {
  padding: 10px;
  border: 1px solid rgba(114, 227, 255, 0.16);
  border-radius: 8px;
  background: rgba(26, 67, 83, 0.24);
}

.scenario-select {
  width: 100%;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(5, 10, 14, 0.86);
  color: #f4fbff;
  font-size: 15px;
  font-weight: 800;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 10px;
}

.action-row button {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(76, 195, 255, 0.18);
  color: #eef8ff;
  cursor: pointer;
}

.action-row button:hover {
  background: rgba(76, 195, 255, 0.28);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.stat {
  min-width: 0;
  padding: 9px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.stat-value {
  display: block;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
}

.stat-label {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  color: #b5c4cb;
}

.layer-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #dce8ed;
  font-size: 15px;
  font-weight: 700;
}

.layer-toggle input {
  accent-color: #4cc3ff;
}

.status {
  min-height: 36px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: #d5e4ea;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.status.is-warn {
  color: #ffd08a;
}

.status.is-error {
  color: #ff9f9f;
}

.legend {
  position: absolute;
  right: 18px;
  bottom: 24px;
  display: grid;
  gap: 8px;
  width: min(280px, calc(100vw - 36px));
  padding: 12px;
  border-radius: 8px;
  background: rgba(9, 15, 20, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.86);
  z-index: 2;
}

.impact-strip {
  position: absolute;
  top: auto;
  right: 318px;
  bottom: 24px;
  left: 420px;
  display: grid;
  gap: 4px;
  width: auto;
  min-width: 0;
  padding: 14px 16px;
  border-left: 4px solid #ff5f56;
  border-radius: 8px;
  background: rgba(9, 15, 20, 0.9);
  color: #eef4f7;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.86);
  pointer-events: none;
  z-index: 2;
}

#cesiumContainer .cesium-infoBox,
#cesiumContainer .cesium-selection-wrapper {
  z-index: 4;
}

.impact-strip strong {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}

.impact-strip span {
  color: #e2edf1;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

@keyframes panelPulse {
  0%,
  100% {
    box-shadow: inset 0 0 0 1px rgba(255, 95, 86, 0.1);
  }
  50% {
    box-shadow: inset 0 0 0 1px rgba(255, 95, 86, 0.55), 0 0 22px rgba(255, 95, 86, 0.3);
  }
}

@keyframes rainSweep {
  from {
    background-position: 0 0;
  }
  to {
    background-position: -90px 220px;
  }
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #dce8ed;
}

.swatch {
  width: 18px;
  height: 10px;
  border-radius: 2px;
  flex: 0 0 auto;
}

@media (max-width: 1100px) {
  .impact-strip {
    left: 18px;
    right: 318px;
  }
}

@media (max-width: 720px) {
  .stage-panel {
    top: 10px;
    left: 10px;
    right: 10px;
    width: auto;
    padding: 12px;
  }

  .stage-title h1 {
    font-size: 18px;
  }

  .legend {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
  }

  .impact-strip {
    top: auto;
    right: 10px;
    left: 10px;
    bottom: 138px;
    width: auto;
    min-width: 0;
  }
}
