:root {
  --background: #101418;
  --panel: #f4f5f6;
  --panel-dark: #252b31;
  --text-main: #1f2327;
  --text-sub: #687078;
  --border: #d8dde1;

  --forecast: #f2c400;
  --warning: #d91f26;
  --normal: #2f7b51;

  --sea: #858a8f;
  --land: #ffffff;
  --prefecture-border: #000000;
  --municipality-border: #a8a8a8;

  --intensity-0: #a9a9a9;
  --intensity-1: #73d9f5;
  --intensity-2: #a9e647;
  --intensity-3: #ffe13b;
  --intensity-4: #ff9c2f;
  --intensity-5: #e31621;
  --intensity-6: #ff9b9b;
  --intensity-7: #75198e;

  --p-wave: #087fc2;
  --p-wave-fill: rgba(21, 158, 233, 0.48);
  --s-wave: #d84b00;
  --s-wave-fill: rgba(240, 90, 0, 0.58);
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body {
  color: var(--text-main);
  background: var(--background);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Yu Gothic UI", sans-serif;
}
button { font: inherit; }
.app {
  width: min(100%, 1200px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--panel);
  box-shadow: 0 0 35px rgba(0, 0, 0, 0.42);
}

.main-header {
  min-height: 78px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.16);
  transition: color 0.25s ease, background-color 0.25s ease;
}
.main-header.normal { color: #fff; background: var(--panel-dark); }
.main-header.forecast { color: #111; background: var(--forecast); }
.main-header.warning { color: #fff; background: var(--warning); }
.header-information h1 { margin: 0; font-size: 24px; }
.header-information p { margin: 4px 0 0; font-size: 13px; opacity: 0.88; }
.header-time-area { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; }
.date { font-size: 12px; font-weight: 700; opacity: 0.8; }
.clock { font-size: 23px; font-weight: 800; font-variant-numeric: tabular-nums; }

.map-section {
  position: relative;
  width: 100%;
  height: 61vh;
  min-height: 490px;
  overflow: hidden;
  background: var(--sea);
}
.map { position: absolute; inset: 0; }
.maplibregl-canvas { outline: none; }

.eew-banner {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  min-height: 76px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-radius: 14px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
  transition: opacity 0.25s ease, transform 0.25s ease, background-color 0.25s ease;
}
.eew-banner.forecast { color: #111; background: rgba(242, 196, 0, 0.97); }
.eew-banner.warning { color: #fff; background: rgba(217, 31, 38, 0.97); }
.eew-banner-left { display: flex; flex-direction: column; gap: 4px; }
.eew-type { font-size: 15px; font-weight: 800; }
.eew-message { font-size: clamp(18px, 3vw, 26px); }
.eew-banner-right { display: flex; flex-direction: column; align-items: flex-end; }
.report-number { font-size: 14px; font-weight: 800; }
.final-report { padding: 3px 7px; border-radius: 5px; background: rgba(0, 0, 0, 0.18); }
.hidden { opacity: 0; pointer-events: none; transform: translateY(-8px); }

.monitor-overlay-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.monitor-overlay-visible { opacity: 1; visibility: visible; pointer-events: auto; }

.intensity-legend {
  position: absolute;
  top: 15px;
  left: 50%;
  z-index: 7;
  width: min(620px, calc(100% - 30px));
  padding: 9px 11px 10px;
  transform: translateX(-50%);
  border-radius: 10px;
  background: rgba(18, 22, 26, 0.9);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.36);
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.intensity-legend.monitor-overlay-hidden { transform: translateX(-50%) translateY(-8px); }
.intensity-legend.monitor-overlay-visible { transform: translateX(-50%) translateY(0); }
.legend-heading { margin-bottom: 7px; color: #fff; font-size: 11px; font-weight: 800; text-align: center; }
.legend-list { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.legend-item { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.legend-color { width: 100%; min-height: 15px; border-radius: 3px; }
.legend-label { color: #fff; font-size: 10px; font-weight: 700; }
.intensity-0 { color: #000; background: var(--intensity-0); }
.intensity-1 { color: #000; background: var(--intensity-1); }
.intensity-2 { color: #000; background: var(--intensity-2); }
.intensity-3 { color: #000; background: var(--intensity-3); }
.intensity-4 { color: #000; background: var(--intensity-4); }
.intensity-5-low, .intensity-5-high { color: #fff; background: var(--intensity-5); }
.intensity-6-low, .intensity-6-high { color: #000; background: var(--intensity-6); }
.intensity-7 { color: #fff; background: var(--intensity-7); }

.wave-legend {
  position: absolute;
  top: 91px;
  left: 14px;
  z-index: 7;
  padding: 8px 10px;
  display: flex;
  gap: 12px;
  color: #fff;
  background: rgba(18, 22, 26, 0.9);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
}
.wave-legend-item { display: flex; align-items: center; gap: 6px; }
.wave-sample { width: 27px; height: 11px; display: inline-block; border-radius: 999px; }
.p-wave-sample { background: var(--p-wave-fill); border: 2px solid var(--p-wave); }
.s-wave-sample { background: var(--s-wave-fill); border: 2px solid var(--s-wave); }

.arrival-panel {
  position: absolute;
  top: 92px;
  right: 14px;
  z-index: 8;
  width: 230px;
  padding: 14px;
  color: #fff;
  background: rgba(16, 20, 24, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 14px;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.38);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}
.arrival-panel-hidden { opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(-8px); }
.arrival-panel-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.arrival-heading { font-size: 14px; font-weight: 800; text-align: center; }
.arrival-heading small { margin-left: 4px; color: #bbb; font-size: 10px; }
.arrival-countdown { margin: 4px 0 0; color: #fff; font-size: 82px; font-weight: 900; line-height: 1; text-align: center; font-variant-numeric: tabular-nums; }
.arrival-countdown.arrived { color: #ff6a22; font-size: 54px; }
.arrival-status { min-height: 22px; margin-top: 5px; color: #d9dde0; font-size: 13px; font-weight: 700; text-align: center; }
.arrival-information { margin-top: 11px; padding-top: 10px; display: grid; gap: 6px; border-top: 1px solid rgba(255, 255, 255, 0.2); }
.arrival-information div { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; }
.arrival-information span { color: #bec4c8; }
.arrival-information strong { font-variant-numeric: tabular-nums; }

.location-status, .connection-status {
  position: absolute;
  left: 14px;
  z-index: 7;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  background: rgba(18, 22, 26, 0.9);
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
}
.location-status { bottom: 52px; max-width: 310px; }
.connection-status { bottom: 14px; }
.location-lamp, .connection-lamp { width: 10px; height: 10px; flex-shrink: 0; border-radius: 50%; }
.location-lamp.loading, .connection-lamp.standby { background: #bfc4c8; }
.location-lamp.ready, .connection-lamp.connected { background: #52d273; box-shadow: 0 0 8px rgba(82, 210, 115, 0.95); }
.location-lamp.error, .connection-lamp.error { background: #ff3b30; box-shadow: 0 0 8px rgba(255, 59, 48, 0.95); }

.map-buttons { position: absolute; right: 14px; bottom: 50px; z-index: 7; display: flex; flex-direction: column; gap: 7px; }
.map-button { padding: 9px 14px; color: #fff; background: rgba(18, 22, 26, 0.92); border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 8px; font-size: 12px; font-weight: 800; cursor: pointer; }

.current-location-marker { width: 19px; height: 19px; border: 4px solid #fff; border-radius: 50%; background: #1677ff; box-shadow: 0 0 0 5px rgba(22, 119, 255, 0.25), 0 2px 8px rgba(0, 0, 0, 0.42); }
.epicenter-marker { color: #ff1010; font-size: 62px; font-weight: 900; line-height: 1; text-shadow: -3px -3px 0 #fff, 3px -3px 0 #fff, -3px 3px 0 #fff, 3px 3px 0 #fff, 0 0 11px rgba(255, 0, 0, 0.62); }

.information-section { padding: 28px 30px 44px; background: var(--panel); }
.information-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; }
.information-type { margin: 0 0 4px; color: var(--text-sub); font-size: 14px; font-weight: 800; }
.information-header h2 { margin: 0; font-size: clamp(21px, 3vw, 30px); }
.announcement-time { margin: 7px 0 0; color: var(--text-sub); font-size: 13px; }

.tsunami-box { flex-shrink: 0; min-width: 145px; padding: 13px 17px; border-radius: 8px; text-align: center; font-size: 14px; font-weight: 800; }
.tsunami-box.none { color: #333; background: #dfe3e5; }
.tsunami-box.investigating { color: #000; background: #bfbfbf; }
.tsunami-box.advisory { color: #111; background: #ffe13b; }
.tsunami-box.warning { color: #fff; background: #e31621; }
.tsunami-box.major { color: #fff; background: #75198e; }

.summary-panel { min-height: 170px; margin-top: 26px; display: grid; grid-template-columns: 1fr 1px 1fr; align-items: stretch; border-radius: 21px; overflow: hidden; }
.summary-panel.normal { color: #fff; background: var(--normal); }
.summary-panel.forecast { color: #111; background: var(--forecast); }
.summary-panel.warning { color: #fff; background: var(--warning); }
.summary-separator { margin: 28px 0; background: currentColor; opacity: 0.32; }
.summary-block { padding: 20px; display: flex; align-items: center; justify-content: center; gap: 22px; }
.summary-label { max-width: 92px; font-size: 17px; font-weight: 800; }
.summary-value, .magnitude-value strong { font-size: clamp(70px, 10vw, 108px); line-height: 1; font-variant-numeric: tabular-nums; }
.magnitude-value { display: flex; align-items: baseline; gap: 5px; }
.magnitude-value small { font-size: 30px; font-weight: 800; }

.detail-list { margin-top: 25px; border-top: 1px solid var(--border); }
.detail-row { min-height: 96px; display: grid; grid-template-columns: 190px 1fr; align-items: center; border-bottom: 1px solid var(--border); }
.detail-name { display: flex; flex-direction: column; }
.detail-name strong { font-size: 22px; }
.detail-name small { color: var(--text-sub); font-size: 12px; }
.detail-value { font-size: clamp(25px, 4vw, 43px); font-variant-numeric: tabular-nums; }

.section-heading { display: flex; align-items: center; justify-content: space-between; }
.section-heading h3 { margin: 0; font-size: 22px; }
.section-heading span { color: var(--text-sub); font-size: 12px; }
.regional-intensity-section, .history-section { margin-top: 34px; }
.regional-intensity-list, .earthquake-history { margin-top: 14px; display: grid; gap: 10px; }
.regional-intensity-list.empty, .earthquake-history.empty { min-height: 90px; padding: 20px; display: flex; align-items: center; justify-content: center; border: 1px dashed #bcc4ca; border-radius: 12px; color: var(--text-sub); background: #eceff1; text-align: center; }
.intensity-region-row { padding: 13px 15px; display: grid; grid-template-columns: 72px 1fr; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.intensity-region-badge, .history-intensity { min-height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 18px; font-weight: 900; }
.history-item { padding: 14px 16px; display: grid; grid-template-columns: 70px 1fr auto; align-items: center; gap: 14px; border: 1px solid var(--border); border-radius: 11px; background: #fff; }
.history-main strong { display: block; }
.history-main span, .history-time { color: var(--text-sub); font-size: 13px; }
.small-button { padding: 7px 11px; border: 1px solid #bdc4c9; border-radius: 7px; background: #fff; cursor: pointer; }

.test-section { margin-top: 34px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: #e8ebed; }
.test-heading { margin: 0 0 12px; color: #555c62; font-size: 13px; font-weight: 800; }
.test-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.test-button { padding: 10px 16px; border: 0; border-radius: 8px; font-weight: 800; cursor: pointer; }
.normal-button { color: #fff; background: #30363c; }
.forecast-button { color: #111; background: var(--forecast); }
.warning-button { color: #fff; background: var(--warning); }
.earthquake-button { color: #fff; background: var(--normal); }
.clear-button { background: #cbd0d3; }

@media (max-width: 700px) {
  .main-header { padding: 10px 15px; }
  .header-information h1 { font-size: 18px; }
  .clock { font-size: 17px; }
  .map-section { height: 56vh; min-height: 440px; }
  .arrival-panel { top: 83px; right: 10px; width: 190px; padding: 10px; }
  .arrival-countdown { font-size: 64px; }
  .arrival-countdown.arrived { font-size: 38px; }
  .information-section { padding: 23px 17px 36px; }
  .summary-panel { min-height: 122px; }
  .summary-block { padding: 12px 6px; }
  .summary-value, .magnitude-value strong { font-size: 56px; }
  .detail-row { grid-template-columns: 120px 1fr; }
  .detail-name strong { font-size: 18px; }
  .detail-value { font-size: 24px; }
}