:root {
  --bg: #ffffff;
  --panel: #f2f4f8;
  --text: #111318;
  --muted: #6b7280;
  --accent: #6ea8fe;
  --era: #f4a261;
  --eraYear: #2a9d8f;
  --zodiac: #e76f51;
  --zodiacDay: #7b2cbf;
  --ok: #52b788;
  --bad: #ef476f;
  /* Typography tokens from design system */
  --font-title-primary: Bahnschrift, "DIN Alternate", Montserrat, system-ui, sans-serif;
  --font-body-jp: "BIZ UDPGothic", 'Noto Sans JP', system-ui, -apple-system, Segoe UI, Roboto, 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Meiryo', sans-serif;
  /* Title image: size 180px, spacing 240px (max). Use responsive clamp. */
  --title-font-size-max: 180px;
  --title-letter-space-max: 240px;
  /* Puzzle glyphs: base 90px, spacing 150px */
  --puzzle-glyph-size: 90px;
  --puzzle-glyph-gap: 150px;
  --puzzle-color-normal: #333333;
  --puzzle-color-accent: #e53935;
  /* Era colors */
  --era-meiji: #f59e0b;   /* amber */
  --era-taisho: #10b981;  /* emerald */
  --era-showa: #3b82f6;   /* blue */
  --era-heisei: #8b5cf6;  /* violet */
  --era-reiwa: #ef4444;   /* red */

  /* Zodiac colors (semantic) */
  --z-1: #e53935;   /* 牡羊座: レッド */
  --z-2: #43a047;   /* 牡牛座: グリーン */
  --z-3: #fdd835;   /* 双子座: イエロー */
  --z-4: #26c6da;   /* 蟹座: ティール */
  --z-5: #fb8c00;   /* 獅子座: オレンジ/ゴールド */
  --z-6: #8bc34a;   /* 乙女座: ライトグリーン */
  --z-7: #42a5f5;   /* 天秤座: ブルー */
  --z-8: #ad1457;   /* 蠍座: マルーン/深紅 */
  --z-9: #7e57c2;   /* 射手座: インディゴ/パープル */
  --z-10: #795548;  /* 山羊座: ブラウン/アース */
  --z-11: #00acc1;  /* 水瓶座: シアン */
  --z-12: #26a69a;  /* 魚座: シーグリーン */
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-body-jp);
  background: linear-gradient(to bottom, #ffffff, #e8e8e8);
  color: var(--text);
  min-height: 100vh;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.app-header { 
  padding: 20px; 
  text-align: center; 
  display: flex; 
  justify-content: center; 
  align-items: center; 
  width: 100%;
  box-sizing: border-box;
}
.title-hero {
  margin: 0 auto;
  font-family: var(--font-title-primary), var(--font-body-jp);
  font-weight: 700;
  text-align: center;
  display: block;
  width: 100%;
  /* 960x960基準の比率を保ちつつレスポンシブ */
  font-size: clamp(48px, 12vw, var(--title-font-size-max));
  letter-spacing: clamp(6px, 6vw, var(--title-letter-space-max));
}

.app-main { max-width: 960px; margin: 0 auto; padding: 16px; padding-bottom: 80px; }
.display { background: var(--panel); border-radius: 12px; padding: 16px; }
.display .label { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.display .date { font-size: 32px; letter-spacing: .05em; }
.date--hidden { filter: blur(6px); opacity: .6; }
.judge-message { margin-top: 8px; min-height: 1.4em; }

.controls { margin-top: 20px; }
.buttons-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.ctrl-btn { height: 72px; border-radius: 12px; border: none; color: #fff; font-size: 22px; font-weight: 700; cursor: pointer; transition: transform .05s ease, filter .2s ease; background: #cbd5e1; color: #0f172a; }
.ctrl-btn:active { transform: translateY(1px); }
.ctrl-btn:focus-visible, .enter-btn:focus-visible, .reset-btn:focus-visible, .popup-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ctrl-btn--era { color: #ffffff; }
.ctrl-btn--era.is-era-1 { background: var(--era-meiji); }
.ctrl-btn--era.is-era-2 { background: var(--era-taisho); }
.ctrl-btn--era.is-era-3 { background: var(--era-showa); }
.ctrl-btn--era.is-era-4 { background: var(--era-heisei); }
.ctrl-btn--era.is-era-5 { background: var(--era-reiwa); }
.ctrl-btn--eraYear { background: var(--eraYear); }
.ctrl-btn--zodiac { color: #ffffff; }
.ctrl-btn--zodiac.is-zodiac-1 { background: var(--z-1); }
.ctrl-btn--zodiac.is-zodiac-2 { background: var(--z-2); }
.ctrl-btn--zodiac.is-zodiac-3 { background: var(--z-3); }
.ctrl-btn--zodiac.is-zodiac-4 { background: var(--z-4); }
.ctrl-btn--zodiac.is-zodiac-5 { background: var(--z-5); }
.ctrl-btn--zodiac.is-zodiac-6 { background: var(--z-6); }
.ctrl-btn--zodiac.is-zodiac-7 { background: var(--z-7); }
.ctrl-btn--zodiac.is-zodiac-8 { background: var(--z-8); }
.ctrl-btn--zodiac.is-zodiac-9 { background: var(--z-9); }
.ctrl-btn--zodiac.is-zodiac-10 { background: var(--z-10); }
.ctrl-btn--zodiac.is-zodiac-11 { background: var(--z-11); }
.ctrl-btn--zodiac.is-zodiac-12 { background: var(--z-12); }
.ctrl-btn--zodiacDay { background: #5a189a; color: #ffffff; }

.action-row { margin-top: 16px; display: flex; gap: 12px; }
.enter-btn { flex: 1; height: 56px; border-radius: 12px; background: var(--accent); border: none; color: #04121f; font-size: 20px; font-weight: 700; cursor: pointer; }

.reset-row { margin-top: 12px; display: flex; gap: 12px; }
.reset-btn { flex: 1; height: 48px; border-radius: 10px; background: #2b2f3f; border: 1px solid #3c4258; color: #ffffff; font-weight: 600; cursor: pointer; }
.reset-btn--accent { background: #3a4159; }

.popup.hidden { display: none; }
.popup { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.5); padding: 16px; }
.popup__content { width: min(520px, 100%); background: var(--panel); border-radius: 12px; padding: 20px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.popup__content--center { text-align: center; }
.popup__hint { display: none; }
.popup__explain { margin-top: 16px; text-align: center; color: var(--text); }
.popup__explain h3 { margin: 0 0 12px 0; font-size: 20px; font-weight: 700; text-align: center; color: var(--text); }
.popup__explain ul { margin: 0 auto; padding-left: 0; list-style: none; display: inline-block; text-align: left; }
.popup__explain li { margin: 8px 0; font-size: 16px; line-height: 1.6; padding-left: 0; }
.popup__explain li::before { content: '• '; color: var(--accent); font-weight: bold; margin-right: 8px; }
.popup__actions { margin-top: 12px; display: flex; justify-content: flex-end; gap: 8px; }
.popup__actions--center { justify-content: center; }
.popup-btn { padding: 10px 14px; border-radius: 8px; border: 1px solid #3c4258; background: #24293a; color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.popup-btn--primary { background: var(--accent); color: #04121f; border: none; }
.popup-btn--tweet { background: #1da1f2; color: #ffffff; border: none; }
.popup-btn--tweet:hover { background: #1a91da; }
.popup__afterword { margin-top: 16px; text-align: center; }
.popup__afterword-link { color: var(--accent); text-decoration: underline; font-size: 14px; }
.popup__afterword-link:hover { color: #4d8fe8; }

/* Puzzle image wireframe utilities (for future sections/assets) */
.puzzle-row { display: flex; align-items: center; gap: clamp(24px, 8vw, var(--puzzle-glyph-gap)); }
.puzzle-glyph { font-family: var(--font-title-primary), var(--font-body-jp); font-size: clamp(28px, 9vw, var(--puzzle-glyph-size)); color: var(--puzzle-color-normal); }
.puzzle-glyph--q { color: var(--puzzle-color-accent); }

/* Lab header image scale (design token) */
.lab-header { font-family: var(--font-title-primary), var(--font-body-jp); font-size: clamp(48px, 10vw, 300px); }

.game-instruction {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #f8f9fa;
  padding: 12px 16px;
  text-align: center;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 14px;
  color: var(--muted);
  z-index: 10;
}
.game-instruction__title {
  margin: 0 auto 8px auto;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  display: inline-block;
  border-bottom: 2px solid var(--text);
  padding-bottom: 2px;
}
.game-instruction p {
  margin: 0 auto;
  max-width: 90%;
  text-align: center;
  line-height: 1.5;
}

@media (max-width: 720px) {
  .display .date { font-size: 28px; }
  .ctrl-btn { height: 64px; font-size: 20px; }
  .game-instruction {
    padding: 12px 16px;
    font-size: 14px;
    background: #f8f9fa !important;
  }
  .game-instruction__title {
    font-size: 16px;
    margin: 0 auto 8px auto !important;
    text-align: center !important;
    display: inline-block !important;
    border-bottom: 2px solid var(--text) !important;
    padding-bottom: 2px !important;
  }
  .game-instruction p {
    font-size: 14px;
    max-width: 90% !important;
    margin: 0 auto !important;
    text-align: center !important;
  }
}

@media (max-width: 420px) {
  .app-main { padding: 12px; }
  .display .date { font-size: 24px; }
  .ctrl-btn { height: 56px; font-size: 18px; }
  .enter-btn { height: 52px; }
  .reset-btn { height: 44px; }
  .game-instruction {
    padding: 10px 12px;
    font-size: 13px;
    background: #f8f9fa !important;
  }
  .game-instruction__title {
    font-size: 15px;
    margin: 0 auto 6px auto !important;
    text-align: center !important;
    display: inline-block !important;
    border-bottom: 2px solid var(--text) !important;
    padding-bottom: 2px !important;
  }
  .game-instruction p {
    font-size: 13px;
    max-width: 90% !important;
    margin: 0 auto !important;
    text-align: center !important;
  }
}

