/* タイフーンドッジ */
:root {
  --ink: #eaf3fc;
  --sea: #16305b;
  --panel: rgba(6, 38, 74, 0.78);
  --accent: #ffb300;
  --navy: #12233f;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #0d1c38;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: var(--ink);
}
#wrap { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
canvas { display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* HUD */
#hud {
  position: absolute; left: 10px; right: 10px; top: 10px;
  display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none; font-size: 14px;
}
#hud .hud-left, #hud .hud-right { display: flex; flex-direction: column; gap: 6px; }
#hud .hud-right { text-align: right; }
#hud .hud-left > div, #hud .hud-right > div {
  background: var(--panel); border-radius: 8px; padding: 6px 10px; width: max-content;
}
#hud .hud-right > div { margin-left: auto; }
#date { font-size: 17px; font-weight: 600; }
#ff { color: var(--accent); font-size: 12px; }

/* 年選択 */
#yearScreen {
  position: absolute; inset: 0; overflow-y: auto;
  background: rgba(7, 22, 46, 0.92);
  backdrop-filter: blur(3px);
  padding: 28px 16px 40px;
}
.year-inner { max-width: 560px; margin: 0 auto; text-align: center; }
.year-inner h1 { font-size: 30px; margin: 8px 0 10px; letter-spacing: 0.02em; }
.tagline { font-size: 14px; line-height: 1.8; color: #c9dcf2; margin: 0 0 18px; }
.year-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  gap: 8px; margin-top: 14px;
}
.year-grid button {
  background: rgba(255, 255, 255, 0.08); color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 10px;
  padding: 9px 4px 7px; font-size: 15px; font-weight: 600; line-height: 1.25;
}
.year-grid button small { display: block; font-size: 10px; font-weight: 400; color: #a9c2de; margin-top: 2px; }
.year-grid button.named { border-color: var(--accent); background: rgba(255, 179, 0, 0.14); }
.year-grid button.selected {
  background: var(--accent); color: var(--navy); border-color: var(--accent);
}
.year-grid button.selected small { color: rgba(18, 35, 63, 0.75); }
.year-grid button:active { transform: scale(0.96); }
.year-actions {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: rgba(10, 28, 56, 0.95); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
#selSummary { font-size: 13px; color: #c9dcf2; }
.year-actions .btns { display: flex; gap: 6px; }
.year-actions button {
  border: none; border-radius: 8px; font-weight: 700;
}
#startBtn {
  background: var(--accent); color: var(--navy);
  font-size: 15px; padding: 0 18px; height: 40px;
}
#startBtn:disabled { background: rgba(255, 255, 255, 0.15); color: #7e96b5; cursor: default; }
.year-actions .mini {
  background: rgba(255, 255, 255, 0.12); color: var(--ink);
  font-size: 12px; padding: 0 10px; height: 40px;
}
.year-grid .loading { grid-column: 1 / -1; color: #a9c2de; }
.credit { margin-top: 20px; font-size: 11px; color: #7e96b5; }
.year-info {
  background: rgba(255,255,255,0.1); border-radius: 10px; padding: 10px 12px;
  font-size: 13px; line-height: 1.7; margin-bottom: 4px; text-align: left;
}

/* ポップアップ */
#popup {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%);
  width: min(84vw, 340px);
  background: rgba(255, 255, 255, 0.97); color: var(--navy);
  border-radius: 16px; padding: 24px 20px; text-align: center;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
}
#popup h1 { margin: 0 0 10px; font-size: 21px; font-weight: 700; }
#popup h1:empty { display: none; }
#popup p { margin: 0 0 18px; font-size: 14.5px; line-height: 1.75; white-space: pre-line; }
#popup button {
  display: block; width: 100%; height: 48px; margin-top: 10px;
  font-size: 16px; font-weight: 700; border: none; border-radius: 10px;
  background: var(--accent); color: var(--navy);
}
#popup button.ghost { background: #e8eef6; color: var(--navy); font-weight: 500; }
#popup button#sharebtn { background: #12233f; color: #fff; }

/* 仮想スティック */
#pad {
  position: absolute; left: 16px; bottom: calc(16px + var(--rows, 0) * 36px);
  width: 148px; height: 148px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.13); border: 1px solid rgba(255, 255, 255, 0.45);
}
#knob {
  width: 60px; height: 60px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  position: absolute; left: 44px; top: 44px; pointer-events: none;
}

/* ティッカー */
#ticker { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; pointer-events: none; }
.row { height: 36px; display: flex; align-items: stretch; overflow: hidden; }
.row.red { background: rgba(226, 75, 74, 0.92); color: #fff; }
.row.yellow { background: rgba(250, 199, 117, 0.95); color: #412402; }
.row.blue { background: rgba(80, 140, 220, 0.92); color: #fff; }
.tag {
  font-size: 13px; font-weight: 700; padding: 0 12px;
  display: flex; align-items: center; white-space: nowrap; flex: none;
  background: rgba(0, 0, 0, 0.25);
}
.track { flex: 1; position: relative; overflow: hidden; }
.ttext {
  position: absolute; top: 0; left: 100%; height: 36px; line-height: 36px;
  font-size: 15px; white-space: nowrap; animation: tk linear forwards;
}
@keyframes tk { from { transform: translateX(0); } to { transform: translateX(var(--dist)); } }

/* メニュー */
#menubtn {
  position: absolute; right: 12px; top: 12px; width: 44px; height: 44px;
  border-radius: 10px; background: var(--panel); color: var(--ink);
  border: none; font-size: 22px; line-height: 44px; text-align: center; padding: 0;
}
#hud:not(.hidden) ~ #menubtn { top: 12px; }
#menu {
  position: absolute; inset: 0; display: none;
  background: rgba(5, 18, 40, 0.97); color: var(--ink);
  padding: 22px 18px 40px; overflow-y: auto; font-size: 14px; line-height: 1.8;
}
#menu.open { display: block; }
#menu h2 { font-size: 19px; margin: 0 0 14px; }
#menu h3 {
  font-size: 15px; margin: 20px 0 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.25); padding-bottom: 4px;
}
#menu p { margin: 0 0 8px; }
#menu pre {
  white-space: pre-wrap; font-size: 11.5px; line-height: 1.5;
  background: rgba(255, 255, 255, 0.08); padding: 10px; border-radius: 8px;
}
#menuclose {
  position: absolute; right: 12px; top: 12px; width: 44px; height: 44px;
  border-radius: 10px; background: rgba(230, 241, 251, 0.15);
  color: var(--ink); border: none; font-size: 22px;
}
#menuYearBtn {
  margin-top: 18px; width: 100%; height: 46px; border-radius: 10px; border: none;
  background: var(--accent); color: var(--navy); font-size: 15px; font-weight: 700;
}
