/* task_ver4 (AppColors) のパレットを再現 */
:root {
  --bg: #121212;
  --card: #1e1e1e;
  --item: #232323;
  --button: #2c2c2c;
  --accent: #00e676;
  --accent-bright: #69f0ae;
  --cyan: #00e5ff;
  --yellow: #ffd600;
  --gold: #ffb300;
  --orange: #ff6d00;
  --red: #ff5252;
  --text: #ffffff;
  --text2: #cccccc;
  --muted: #888888;
  --current-row: #33331a;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
.num, .rta-timer, .seg-time, .now-clock, .stat-val, .splits, .board { font-variant-numeric: tabular-nums; }

.screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding-top: env(safe-area-inset-top);
}
.screen[hidden] { display: none; }

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--button);
}
.bar-title { flex: 1; color: var(--accent); font-weight: bold; font-size: 15px; }
.icon-btn {
  background: none; border: 0; font-size: 20px; padding: 4px 8px; cursor: pointer;
}
.content { flex: 1; overflow-y: auto; padding: 14px 16px; }
.foot {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--button);
}
.muted { color: var(--muted); }
.small { font-size: 12px; }

.big-btn {
  width: 100%;
  min-height: 64px;
  border: 0; border-radius: 14px;
  background: var(--accent); color: #000;
  font-size: 20px; font-weight: bold;
  cursor: pointer;
}
.big-btn:active { background: var(--accent-bright); }
.sub-btn {
  min-height: 44px; padding: 0 14px;
  border: 0; border-radius: 10px;
  background: var(--button); color: var(--text2);
  font-weight: bold; cursor: pointer;
}
.sub-btn.wide { width: 100%; display: flex; align-items: center; justify-content: center; }
.sub-btn.danger { color: var(--red); }

/* ホーム */
.clock-card {
  background: var(--card); border-radius: 14px; padding: 16px; text-align: center;
}
.now-clock { font-size: 56px; font-weight: bold; line-height: 1.1; }
.forecast { margin-top: 10px; font-weight: bold; }
.forecast.ok { color: var(--accent); }
.forecast.ng { color: var(--red); }
.pb-list { margin-top: 14px; display: grid; gap: 8px; }
.pb-item {
  display: flex; align-items: baseline; gap: 8px;
  background: var(--item); border-radius: 10px; padding: 12px 14px;
}
.pb-item .name { flex: 1; font-weight: bold; }
.pb-item .pb { color: var(--yellow); font-size: 22px; font-weight: bold; font-variant-numeric: tabular-nums; }
.pb-item.total .name { color: var(--accent); }
.stat-row { display: flex; gap: 8px; margin-top: 14px; }
.stat { flex: 1; background: var(--item); border-radius: 10px; padding: 10px; text-align: center; }
.stat-val { font-size: 22px; font-weight: bold; margin-top: 2px; }

/* タイマー */
.run-content { display: flex; flex-direction: column; }
.timer-block { text-align: center; padding: 6px 0 14px; }
.rta-timer { font-weight: bold; color: var(--accent); line-height: 1; }
.rta-timer .main { font-size: 64px; }
.rta-timer .cs { font-size: 28px; }
.rta-timer.behind { color: var(--red); }
.rta-timer.center { text-align: center; margin: 10px 0; }
.seg-line { margin-top: 10px; display: flex; justify-content: center; align-items: baseline; gap: 8px; }
.seg-name { font-weight: bold; }
.seg-time { font-size: 28px; font-weight: bold; color: var(--yellow); }
.seg-time.over { color: var(--red); }
.bar-track { margin: 10px auto 0; height: 8px; background: var(--button); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); }
.bar-fill.over { background: var(--red); }
.run-meta { margin-top: 10px; display: flex; justify-content: space-around; font-size: 14px; color: var(--text2); }
.run-meta b { font-size: 16px; }
.run-meta .ahead { color: var(--accent); }
.run-meta .behind { color: var(--red); }
.run-foot { flex-direction: row; align-items: stretch; }
.run-foot .big-btn { flex: 2; }
.run-foot .sub-btn { flex: 1; font-size: 13px; }
.paused .rta-timer, .paused .seg-time { opacity: .45; }

/* スプリット表 */
.splits { background: var(--card); border-radius: 10px; overflow: hidden; }
.split-head, .split-row {
  display: grid; grid-template-columns: 1fr 80px 80px; gap: 6px;
  padding: 10px 12px; align-items: baseline;
  border-bottom: .5px solid var(--button);
}
.split-head { color: var(--muted); font-size: 11px; font-weight: bold; }
.split-row:last-child { border-bottom: 0; }
.split-row .r { text-align: right; }
.split-row .name { font-weight: bold; }
.split-row.current { background: var(--current-row); box-shadow: inset 3px 0 0 var(--yellow); }
.split-row.current .time { color: var(--yellow); }
.split-row.future { color: var(--muted); }
.split-row.total { border-top: 1px solid var(--button); }
.split-row.total .name { color: var(--accent); }
.d-ahead { color: var(--accent); }
.d-behind { color: var(--red); }
.d-gold { color: var(--gold); }

/* リザルト */
.rank-block { text-align: center; margin-top: 6px; }
.rank-letter { font-size: 88px; font-weight: 900; line-height: 1; }
.rank-title { font-weight: bold; letter-spacing: .08em; }
.badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 14px; }
.badge {
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: bold;
  background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--gold);
}
.badge.cyan { background: color-mix(in srgb, var(--cyan) 15%, transparent); color: var(--cyan); }
.bed-line { text-align: center; margin-top: 14px; font-weight: bold; }

/* 歴代記録 */
.tabs { display: flex; gap: 6px; padding: 10px 16px 0; overflow-x: auto; }
.tab {
  flex: 1; min-height: 38px; border: 0; border-radius: 999px;
  background: var(--button); color: var(--text2); font-weight: bold; white-space: nowrap; padding: 0 12px;
  cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--accent); color: #000; }
.board { display: grid; gap: 6px; }
.board-row {
  display: grid; grid-template-columns: 36px 1fr auto; gap: 8px; align-items: center;
  background: var(--item); border-radius: 10px; padding: 10px 12px;
  border: 0; text-align: left; width: 100%; cursor: pointer;
}
.board-row .place { font-weight: 900; color: var(--muted); text-align: center; }
.board-row.p1 .place { color: var(--gold); }
.board-row.p2 .place { color: #c0c0c0; }
.board-row.p3 .place { color: #cd7f32; }
.board-row .time { font-size: 20px; font-weight: bold; }
.board-row .sub { color: var(--muted); font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.chart { background: var(--card); border-radius: 10px; padding: 10px; margin-bottom: 12px; }
.chart svg { display: block; width: 100%; height: auto; }
.sort-row { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.sort-row .tab { flex: 0 0 auto; min-height: 30px; font-size: 12px; }

/* 設定 */
.form { display: grid; gap: 12px; margin-bottom: 24px; }
.form h3 { margin: 8px 0 0; font-size: 15px; color: var(--accent); }
.form p { margin: 0; }
.form label { display: grid; gap: 4px; color: var(--text2); font-size: 13px; }
.form label.check { display: flex; align-items: center; gap: 8px; }
.form input[type=text], .form input[type=number], .form input[type=time] {
  background: var(--item); border: 1px solid var(--button); border-radius: 8px;
  padding: 10px; font-size: 16px;
}
.form fieldset { border: 1px solid var(--button); border-radius: 10px; display: grid; gap: 8px; }
.form legend { color: var(--muted); font-size: 12px; padding: 0 4px; }
.file-btn { cursor: pointer; }

dialog {
  background: var(--card); color: var(--text); border: 1px solid var(--button);
  border-radius: 14px; width: min(92vw, 480px); padding: 16px;
}
dialog::backdrop { background: rgba(0, 0, 0, .7); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.detail-title { font-weight: bold; margin-bottom: 8px; }

/* 順番の選択とスタート案内 */
.center-text { text-align: center; }
.order-select { display: flex; gap: 8px; }
.order-btn {
  flex: 1; min-height: 48px; border-radius: 12px;
  border: 2px solid var(--button); background: var(--item); color: var(--text2);
  font-weight: bold; cursor: pointer;
}
.order-btn[aria-checked="true"] { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--item)); }
.start-hint { text-align: center; color: var(--yellow); font-weight: bold; font-size: 14px; }

/* ひとこと */
.comment-label { display: block; margin: 16px 0 6px; color: var(--text2); font-size: 13px; font-weight: bold; }
.comment-input {
  width: 100%; resize: vertical;
  background: var(--item); border: 1px solid var(--button); border-radius: 10px;
  padding: 10px; font-size: 16px; color: var(--text); font-family: inherit;
}
.comment-box {
  margin-top: 14px; padding: 12px 14px; border-radius: 10px;
  background: var(--item); border-left: 3px solid var(--cyan);
  white-space: pre-wrap; word-break: break-word;
}

/* カレンダー */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-nav .icon-btn { font-size: 28px; padding: 0 14px; }
.cal-title { font-weight: bold; font-size: 17px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0; }
.cal-dow.sun { color: var(--red); }
.cal-dow.sat { color: var(--cyan); }
.cal-cell {
  min-height: 58px; border-radius: 8px; border: 1px solid transparent;
  background: var(--card); color: var(--text2);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 3px 0; gap: 1px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.cal-cell.blank { background: none; cursor: default; }
.cal-cell.today { border-color: var(--muted); }
.cal-cell.selected { border-color: var(--accent); }
.cal-cell .d { font-size: 11px; }
.cal-cell .rk { font-size: 18px; font-weight: 900; line-height: 1.1; }
.cal-cell .bt { font-size: 9px; }
.cal-legend { margin: 8px 0 14px; }
.cal-day h3 { margin: 0 0 8px; font-size: 15px; }
.cal-day .board { margin-bottom: 8px; }
