:root {
  --ink: #1b2430;
  --ink-soft: #5c6672;
  --line: #dfe4ea;
  --rain: #2f6f8f;
  --rain-bg: rgba(47, 111, 143, 0.08);
  --dry: #3f8f5b;
  --dry-bg: rgba(63, 143, 91, 0.08);
  --neutral: #8a94a0;
  --hot: #d4602e;
  --hot-bg: rgba(212, 96, 46, 0.08);
  --cold: #3b7bb5;
  --cold-bg: rgba(59, 123, 181, 0.08);
  --card: #ffffff;
  --card-glass: rgba(255, 255, 255, 0.88);
  --primary: #1b2430;
  --primary-accent: #2b3848;
  
  --disp: 'Space Grotesk', 'Noto Sans JP', system-ui, -apple-system, sans-serif;
  --jp: 'Noto Sans JP', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', monospace;
  
  --shadow-sm: 0 2px 8px rgba(27, 36, 48, 0.04);
  --shadow-md: 0 8px 24px rgba(27, 36, 48, 0.06);
  --shadow-lg: 0 14px 36px rgba(27, 36, 48, 0.10);

  /* 統一デザインシステム トークン */
  --radius-card: 20px;      /* メインカード類（3連タイル、タイムライン、GPSボタン、設定アコーディオン）の統一角丸 */
  --radius-control: 12px;   /* 入力フィールド、ボタンスイッチの統一角丸 */
  --radius-pill: 9999px;    /* バッジ・丸ボタン用角丸 */

  --gap-section: 14px;      /* メイン要素・カード間の統一縦ギャップ */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100dvh;
  background:
    radial-gradient(120% 80% at 50% -10%, #f7efe4 0%, rgba(247, 239, 228, 0) 60%),
    linear-gradient(180deg, #eaf0f5 0%, #edf1f4 100%);
  background-attachment: fixed;
}

body {
  font-family: var(--jp);
  color: var(--ink);
  display: flex;
  justify-content: center;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

/* アプリ全体コンテナ */
.panel {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: var(--gap-section);
}

/* ヘッダー ナビゲーションバー */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
}

.place-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: var(--card-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.place-badge:active {
  transform: scale(0.97);
}

.datenav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav {
  font-family: var(--disp);
  font-size: 18px;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-control);
  border: 1px solid var(--line);
  background: var(--card-glass);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav:disabled {
  opacity: 0.3;
  cursor: default;
  box-shadow: none;
}

.nav:active:not(:disabled) {
  transform: scale(0.92);
  background: #f0f4f8;
}

.date {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  min-width: 120px;
  text-align: center;
}

/* メイン判定ボードコンテナ */
#board {
  display: flex;
  flex-direction: column;
  gap: var(--gap-section);
}

/* 見立てキャプション */
.subline {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.subline-badge {
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(27, 36, 48, 0.06);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  color: var(--ink-soft);
}

/* 3連判定タイル */
.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.tile {
  background: var(--card-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px 10px 14px;
  text-align: center;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 156px;
  justify-content: space-between;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
  position: relative;
  overflow: hidden;
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.tile .cap {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.glyph {
  width: 46px;
  height: 46px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.05));
  transition: transform 0.3s ease;
}

.tile:hover .glyph {
  transform: scale(1.08);
}

.verdict {
  font-family: var(--disp);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.stat {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
}

/* Verdict カラーテーマ */
.verdict.rain { color: var(--rain); }
.verdict.dry { color: var(--dry); }
.verdict.neutral { color: var(--neutral); }
.verdict.hot { color: var(--hot); }
.verdict.cold { color: var(--cold); }

.g-rain path, .g-rain line { stroke: var(--rain); }
.g-dry path, .g-dry line { stroke: var(--dry); }
.g-neutral path, .g-neutral line, .g-neutral circle { stroke: var(--neutral); }
.g-hot path, .g-hot line, .g-hot circle { stroke: var(--hot); }
.g-cold path, .g-cold line { stroke: var(--cold); }

/* タイムラインカード */
.timeline-wrap {
  background: var(--card-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  box-shadow: var(--shadow-md);
}

.tl-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.tl-bar {
  position: relative;
  height: 16px;
  border-radius: 8px;
  background: #e6ebf0;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
}

.tl-out {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(212, 96, 46, 0.16);
  border-left: 2px solid rgba(212, 96, 46, 0.6);
  border-right: 2px solid rgba(212, 96, 46, 0.6);
  transition: all 0.3s ease;
}

.tl-rain {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--rain);
  opacity: 0.85;
  border-radius: 2px;
}

.tl-scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 9.5px;
  color: #9aa2ac;
  margin-top: 6px;
}

.tl-legend {
  display: flex;
  gap: 16px;
  font-family: var(--jp);
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 12px;
}

.tl-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

/* GPSアクションカード */
.location-bar {
  display: flex;
}

.btn-gps {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--jp);
  font-size: 14px;
  font-weight: 500;
  padding: 16px 18px;
  background: var(--card-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-gps:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.btn-gps:active {
  transform: translateY(1px);
  background: rgba(255, 255, 255, 0.95);
}

.btn-gps svg {
  width: 18px;
  height: 18px;
  stroke: var(--rain);
}

/* 設定アコーディオンカード */
details.settings {
  background: var(--card-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: all 0.25s ease;
}

summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

summary::-webkit-details-marker { display: none; }

summary .chev {
  transition: transform 0.25s ease;
  font-size: 14px;
}

details[open] summary .chev {
  transform: rotate(180deg);
}

.fields {
  padding: 4px 18px 20px;
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input {
  font-family: var(--jp);
  font-size: 14.5px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: #fcfdfe;
  color: var(--ink);
  width: 100%;
  transition: all 0.2s ease;
}

input:focus {
  outline: none;
  border-color: var(--rain);
  box-shadow: 0 0 0 3px rgba(47, 111, 143, 0.15);
}

input[type=time] {
  font-family: var(--mono);
}

button.apply {
  font-family: var(--jp);
  font-weight: 700;
  font-size: 14px;
  padding: 13px;
  border: none;
  border-radius: var(--radius-control);
  background: var(--ink);
  color: #ffffff;
  cursor: pointer;
  margin-top: 4px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

button.apply:active {
  transform: translateY(1px);
  background: var(--primary-accent);
}

.hint {
  font-size: 11px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.status {
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-soft);
  padding: 48px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--card-glass);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--line);
  border-top-color: var(--rain);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.err {
  color: var(--hot);
  font-family: var(--jp);
  line-height: 1.6;
  background: var(--hot-bg);
  padding: 14px 16px;
  border-radius: var(--radius-control);
  border: 1px solid rgba(212, 96, 46, 0.2);
}

/* PWA インストールプロンプトバナー */
.pwa-banner {
  background: var(--ink);
  color: #ffffff;
  border-radius: var(--radius-card);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-lg);
}

.pwa-banner-text {
  font-size: 12px;
  line-height: 1.4;
}

.pwa-banner-text strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

.btn-pwa-install {
  font-family: var(--jp);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-pill);
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
