/* 色は6色まで：背景・面・線・文字・オレンジ（強調）・水色（トリッククロックの後攻） */
@font-face { font-family: "Orbitron"; src: url("fonts/orbitron.ttf") format("truetype"); font-weight: 400 900; font-display: swap; }
:root {
  --bg: #121212; --surface: #1a1a1a; --surface2: #1f1f1f; --line: #333333; --line2: #2a2a2a;
  --text: #f2f2f2; --sub: #bdbdbd; --dim: #9e9e9e;
  --accent: #ff9f1c; --ink: #1b1200; --accent-bg: #2a2111; --accent-soft: #ffc46b;
  --sky: #6ec1ff; --warn: #ff6b5e;
  --num: "Orbitron", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
#app { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

/* 上のバー */
.bar { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 2px solid var(--accent); padding: calc(6px + env(safe-area-inset-top)) 8px 8px; }
.bar-row { display: flex; align-items: center; gap: 4px; }
.icon-btn { width: 44px; height: 44px; flex: none; border: 0; border-radius: 22px; background: transparent; display: flex; align-items: center; justify-content: center; }
.icon-btn:active { background: var(--surface2); }
.bar-title { flex: 1; min-width: 0; font-family: var(--num); font-weight: 800; font-size: 19px; letter-spacing: .03em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-title.wrap { white-space: normal; overflow-wrap: anywhere; font-family: inherit; font-size: 17px; font-weight: 900; letter-spacing: 0; line-height: 1.35; }
.bar-title small { display: block; font-family: inherit; font-size: 12px; font-weight: 400; letter-spacing: 0; color: var(--sub); }
.chip { padding: 4px 12px; margin-right: 4px; border-radius: 14px; background: var(--accent-bg); color: var(--accent-soft); font-size: 13px; font-weight: 700; white-space: nowrap; }
.tabs { margin: 8px 8px 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface2); }
.tabs button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--sub); font-size: 15px; font-weight: 700; }
.tabs button[aria-pressed="true"] { background: var(--accent); color: var(--ink); }

/* ホーム */
.home-head { padding: calc(28px + env(safe-area-inset-top)) 20px 18px; border-bottom: 2px solid var(--accent); display: flex; align-items: flex-start; gap: 12px; }
.home-head img { width: 56px; height: 56px; border-radius: 14px; flex: none; }
.home-head h1 { margin: 0; font-family: var(--num); font-weight: 800; font-size: 24px; letter-spacing: .03em; }
.home-head p { margin: 2px 0 0; color: var(--sub); font-size: 13px; }
.lang-btn { margin-left: auto; min-height: 36px; padding: 0 12px; border: 1px solid #444; border-radius: 18px; background: var(--surface2); font-size: 13px; font-weight: 700; flex: none; }
.menu { padding: 16px 14px 0; display: flex; flex-direction: column; gap: 10px; }
.menu-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 72px; padding: 12px 16px; border: 1px solid var(--line2); border-radius: 16px; background: var(--surface); text-align: left; text-decoration: none; color: var(--text); }
.menu-item:active { border-color: var(--accent); }
.menu-item b { display: block; font-size: 18px; }
.menu-item span { display: block; font-size: 12px; color: var(--dim); margin-top: 2px; }
.menu-item .go { margin-left: auto; color: var(--accent); flex: none; }
.links { display: flex; flex-wrap: wrap; gap: 8px; padding: 18px 14px 0; }
.links button, .links a { min-height: 40px; padding: 0 14px; border: 1px solid #444; border-radius: 20px; background: transparent; color: var(--sub); font-size: 13px; display: inline-flex; align-items: center; text-decoration: none; }
.foot { padding: 20px 16px 0; color: var(--dim); font-size: 12px; line-height: 1.7; }
.foot p { margin: 0 0 8px; }
.foot button { min-height: 32px; padding: 0 12px; border: 1px solid #444; border-radius: 16px; background: transparent; color: var(--sub); font-size: 12px; }

/* KWC年度 */
.years { padding: 16px 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.year { min-height: 64px; border: 1px solid var(--line2); border-radius: 14px; background: var(--surface); font-family: var(--num); font-weight: 800; font-size: 17px; text-decoration: none; color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.year span { font-family: system-ui, sans-serif; font-weight: 400; font-size: 11px; color: var(--dim); }
.year.none { color: var(--dim); }

/* 技一覧 */
.list { padding: 0 14px; }
.grp { display: flex; align-items: center; gap: 10px; margin: 20px 2px 8px; }
.grp-name { font-family: var(--num); font-weight: 800; font-size: 14px; color: var(--accent); }
.grp-name.jp { font-family: inherit; font-size: 15px; }
.grp-line { flex: 1; height: 1px; background: var(--line); }
.grp-pt { font-size: 12px; color: var(--dim); }
.sub { display: flex; align-items: center; gap: 8px; margin: 12px 4px 6px; font-size: 13px; font-weight: 700; color: var(--sub); }
.sub .vid { width: 36px; height: 36px; }
.rows { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 8px 8px 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line2); }
.row.on { background: var(--accent-bg); border-color: var(--accent); }
.box { width: 44px; height: 44px; flex: none; margin: -6px -8px -6px -8px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; }
.box i { width: 28px; height: 28px; border-radius: 8px; border: 2px solid #555; display: flex; align-items: center; justify-content: center; }
.row.on .box i { background: var(--accent); border-color: var(--accent); }
.no { width: 22px; flex: none; padding-top: 4px; font-family: var(--num); font-weight: 600; font-size: 12px; color: var(--dim); }
.name { flex: 1; min-width: 0; padding-top: 2px; font-size: 15px; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }
.name small { display: block; font-size: 11px; color: var(--dim); }
.done-tag { flex: none; margin-top: 2px; min-height: 28px; padding: 0 8px; border: 1px solid var(--accent); border-radius: 14px; background: transparent; color: var(--accent); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 2px; }
.vid { width: 40px; height: 40px; flex: none; border-radius: 20px; background: #262626; color: var(--accent); display: flex; align-items: center; justify-content: center; }
.empty { padding: 40px 20px; text-align: center; color: var(--dim); }

/* マトリックス */
.mx-help { padding: 10px 16px 8px; font-size: 12px; color: var(--sub); }
/* 下のボタン（約80px）に横スクロールバーが隠れないよう、その分を引く */
.mx-wrap { overflow: auto; max-height: calc(100vh - 290px - env(safe-area-inset-bottom)); max-height: calc(100dvh - 290px - env(safe-area-inset-bottom)); }
.mx.fit { width: 100%; }
.mx.fit .cell { height: 100px; padding: 5px 5px; font-size: 11px; line-height: 1.35; }
.mx.fit .cell span { -webkit-line-clamp: 6; }
.mx.fit .rh.jp { font-size: 10px; }
.mx { display: grid; width: max-content; }
.mx .corner, .mx .head { position: sticky; top: 0; z-index: 2; height: 34px; background: var(--bg); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-family: var(--num); font-weight: 800; font-size: 12px; color: var(--accent); }
.mx .corner { left: 0; z-index: 3; }
.mx .rh { position: sticky; left: 0; z-index: 1; background: var(--bg); border-right: 1px solid var(--line); display: flex; align-items: center; justify-content: center; padding: 0 4px; font-family: var(--num); font-weight: 600; font-size: 12px; color: var(--dim); text-align: center; }
.mx .rh.jp { font-family: inherit; font-size: 11px; line-height: 1.3; }
.cell { height: 84px; margin: 2px; padding: 6px 7px; border-radius: 10px; border: 1px solid #2e2e2e; background: #1c1c1c; color: #e6e6e6; text-align: left; font-size: 11.5px; line-height: 1.4; font-weight: 500; position: relative; }
.cell span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cell.on { background: var(--accent); color: var(--ink); border-color: var(--accent); font-weight: 700; }
.cell.done::after { content: "✓"; position: absolute; right: 5px; bottom: 3px; font-size: 13px; font-weight: 900; color: var(--accent); }
.cell.on.done::after { color: var(--ink); }

/* 下のボタン */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #1a1a1af2; border-top: 1px solid var(--line); padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); }
.dock-in { max-width: 612px; margin: 0 auto; display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.btn { min-height: 52px; padding: 0 10px; border: 1px solid #444; border-radius: 14px; background: var(--surface2); font-size: 13px; font-weight: 700; line-height: 1.25; white-space: nowrap; }
.btn.primary { border: 0; background: var(--accent); color: var(--ink); font-weight: 900; font-size: 15px; }
.btn:disabled { opacity: .4; cursor: default; }

/* 下から出る板・お知らせ */
.sheet { position: fixed; inset: 0; z-index: 40; background: #000000a6; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet[hidden] { display: none; }
.sheet .shade { flex: 1; border: 0; background: transparent; }
.sheet .panel { max-width: 640px; width: 100%; margin: 0 auto; background: var(--surface2); border-radius: 22px 22px 0 0; border-top: 2px solid var(--accent); padding: 18px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.panel .meta { display: flex; align-items: center; gap: 10px; font-family: var(--num); font-weight: 800; font-size: 13px; color: var(--accent); }
.panel .meta span:last-child { margin-left: auto; font-family: system-ui, sans-serif; font-weight: 400; color: var(--sub); }
.panel .full { font-size: 18px; font-weight: 700; line-height: 1.6; overflow-wrap: anywhere; max-height: 40vh; overflow: auto; white-space: pre-line; }
.panel .full.text { font-size: 15px; font-weight: 400; }
.panel .two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.panel .btn { text-decoration: none; display: flex; align-items: center; justify-content: center; color: var(--text); }
.panel .btn.primary { color: var(--ink); }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; max-width: 90vw; padding: 10px 18px; border-radius: 20px; background: #333; color: var(--text); font-size: 14px; }
.toast[hidden] { display: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ルーティン（ScoreSheet風） */
.rt-my { margin: 10px 14px 0; padding: 8px 12px; border-radius: 10px; background: var(--accent-bg); border: 1px solid var(--accent); display: flex; align-items: center; gap: 8px; }
.rt-my span { flex: none; padding: 2px 8px; border-radius: 8px; background: var(--accent); color: var(--ink); font-size: 11px; font-weight: 900; }
.rt-my b { flex: 1; min-width: 0; font-size: 16px; font-weight: 900; overflow-wrap: anywhere; }
.rt-top { padding: 12px 14px 10px; display: flex; align-items: center; gap: 12px; }
.rt-time { font-family: var(--num); font-weight: 800; font-size: 44px; line-height: 1; min-width: 150px; color: var(--accent); }
.rt-time.run { color: #fff; }
.rt-time.low { color: var(--warn); }
.rt-guide { flex: 1; font-size: 12px; line-height: 1.5; color: var(--sub); }
.rt-mins { padding: 0 14px 10px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.pill { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface2); color: #e6e6e6; font-size: 15px; font-weight: 700; }
.pill[aria-pressed="true"] { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.rt-wrap { padding: 0 14px 40px; }
.rt-table { border: 2px solid #cfcfcf; border-radius: 4px; }
.rt-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 72px 64px; border-bottom: 1.5px solid #8a8a8a; }
.rt-row:last-child { border-bottom: 0; }
.rt-row > * + * { border-left: 1.5px solid #8a8a8a; }
.rt-row.on { background: var(--accent-bg); }
.rt-head { background: #1c1c1c; border-bottom: 2px solid #cfcfcf; font-size: 11px; color: #e6e6e6; }
.rt-head > div { padding: 6px 2px; text-align: center; line-height: 1.3; }
.rt-head small { display: block; font-size: 10px; color: var(--dim); }
.rt-no { display: flex; align-items: center; justify-content: center; font-family: var(--num); font-weight: 600; font-size: 13px; color: var(--sub); }
.rt-name { padding: 8px; min-width: 0; font-size: 14px; font-weight: 500; line-height: 1.45; overflow-wrap: anywhere; display: flex; flex-direction: column; justify-content: center; }
.rt-name small { font-size: 11px; color: var(--dim); }
.rt-chk { border: 0; border-left: 1.5px solid #8a8a8a; background: transparent; min-height: 58px; padding: 0; display: flex; align-items: center; justify-content: center; }
.rt-chk i { width: 38px; height: 38px; border-radius: 10px; border: 2px solid #4a4a4a; display: flex; align-items: center; justify-content: center; }
.rt-chk i.live { border-color: var(--sub); }
.rt-row.on .rt-chk i { background: var(--accent); border-color: var(--accent); }
.rt-pt { display: flex; align-items: center; justify-content: center; font-family: var(--num); font-weight: 800; font-size: 16px; color: var(--accent); }
.rt-note { margin: 8px 0 0; font-size: 12px; color: var(--dim); }
.rt-dock { grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
.total { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border: 3px solid var(--accent); border-radius: 6px; min-width: 0; }
.total span { font-family: var(--num); font-weight: 800; font-size: 12px; color: var(--accent); letter-spacing: .04em; margin-right: auto; white-space: nowrap; }
.total b { font-family: var(--num); font-weight: 800; font-size: 26px; }
.total small { font-size: 13px; color: var(--sub); white-space: nowrap; }
.rt-dock .btn { min-width: 96px; }
.rt-count { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: #000000b3; font-family: var(--num); font-weight: 800; font-size: 140px; color: var(--accent); }
.rt-end { font-size: 24px; font-weight: 900; color: var(--accent); }
.rt-endmy { font-size: 13px; font-weight: 700; color: var(--accent-soft); }
.rt-endsub { font-size: 14px; color: #e6e6e6; }
.rt-endnote { font-size: 12px; color: var(--dim); }

/* マイトリック・技セレクター */
.my-new { border-style: dashed; justify-content: center; text-align: center; }
.my-table .rt-row { grid-template-columns: 34px minmax(0, 1fr) 56px 112px; }
.my-ops { display: flex; align-items: center; justify-content: center; gap: 2px; padding: 4px; }
.my-ops button { width: 34px; height: 40px; border: 1px solid #444; border-radius: 8px; background: var(--surface2); font-size: 16px; font-weight: 700; }
.my-ops button:disabled { opacity: .3; }
.my-dock { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
.my-dock a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text); }
.my-dock a.btn[aria-disabled="true"] { opacity: .4; }
.pick-src { margin: 8px 8px 0; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--sub); }
.pick-src select { flex: 1; min-height: 44px; padding: 0 10px; border-radius: 10px; border: 1px solid #444; background: var(--surface2); color: var(--text); font: inherit; font-size: 15px; }
.row.already { opacity: .55; }
.fld { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--sub); }
.fld input { min-height: 46px; padding: 0 12px; border-radius: 10px; border: 1px solid #444; background: var(--bg); color: var(--text); font: inherit; font-size: 16px; }
.add-to { display: flex; flex-direction: column; gap: 6px; max-height: 30vh; overflow: auto; }
.add-to .btn { white-space: normal; text-align: left; justify-content: flex-start; }

/* トリッククロック */
.ck-setup { padding: 14px 14px 20px; display: flex; flex-direction: column; gap: 12px; }
.ck-card { padding: 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line2); display: flex; flex-direction: column; gap: 10px; }
.ck-card.p0 { border-color: #ff9f1c66; }
.ck-card.p1 { border-color: #6ec1ff66; }
.ck-card.win.p0 { border-color: var(--accent); }
.ck-card.win.p1 { border-color: var(--sky); }
.ck-card-head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--sub); }
.ck-card-head b { color: var(--text); font-size: 14px; }
.ck-badge { flex: none; padding: 3px 10px; border-radius: 10px; font-size: 13px; font-weight: 900; }
.ck-badge.p0 { background: var(--accent); color: var(--ink); }
.ck-badge.p1 { background: var(--sky); color: #04121f; }
.ck-src { min-height: 44px; padding: 0 10px; border-radius: 10px; border: 1px solid #444; background: var(--surface2); color: var(--text); font: inherit; font-size: 15px; }
.ck-end { display: flex; align-items: center; gap: 8px; }
.ck-end span { width: 40px; font-size: 13px; color: var(--dim); }
.ck-end b { flex: 1; text-align: center; font-size: 16px; }
.ck-step { width: 44px; height: 44px; border: 1px solid #444; border-radius: 12px; background: var(--surface2); font-size: 20px; }
.ck-count-note { font-size: 12px; color: var(--dim); }

.ck-play { position: fixed; inset: 0; z-index: 25; display: flex; flex-direction: column; background: var(--bg); padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.ck-side { flex: 1; min-height: 0; min-width: 0; position: relative; overflow: hidden; background: #141414; }
.ck-side.active.p0 { background: var(--accent-bg); box-shadow: inset 0 0 0 3px var(--accent); }
.ck-side.active.p1 { background: #0f2233; box-shadow: inset 0 0 0 3px var(--sky); }
.ck-hit { position: absolute; inset: 0; width: 100%; border: 0; background: transparent; touch-action: manipulation; }
.ck-in { position: relative; pointer-events: none; height: 100%; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; }
.ck-head { display: flex; align-items: center; gap: 8px; }
.ck-side:not(.active) .ck-badge { opacity: .55; }
.ck-src-t { font-size: 12px; color: var(--sub); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck-status { margin-left: auto; flex: none; font-size: 13px; font-weight: 900; color: #8a8a8a; }
.ck-side.active.p0 .ck-status { color: var(--accent); }
.ck-side.active.p1 .ck-status { color: var(--sky); }
.ck-time { font-family: var(--num); font-weight: 800; line-height: 1; font-size: 44px; color: #8a8a8a; }
.ck-side.active .ck-time { font-size: 64px; color: #fff; }
.ck-time.low, .ck-side.active .ck-time.low { color: var(--warn); }
.ck-step-t { font-size: 12px; color: var(--dim); }
.ck-name { font-weight: 900; line-height: 1.35; overflow-wrap: anywhere; color: #bdbdbd; }
.ck-side.active .ck-name { color: #fff; }
.ck-name[data-spin] { color: var(--dim) !important; }
.ck-hint { margin-top: auto; font-size: 13px; color: var(--sub); }
.ck-pass { position: absolute; right: 12px; bottom: 12px; min-height: 48px; padding: 0 16px; border-radius: 12px; border: 1px solid #555; background: #000000aa; color: #e6e6e6; font-size: 13px; font-weight: 700; touch-action: none; user-select: none; -webkit-user-select: none; }
.ck-pass.hold { background: var(--warn); color: #1b0000; border-color: var(--warn); }
.ck-countdown { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #000000b3; font-family: var(--num); font-weight: 800; font-size: 120px; color: var(--accent); pointer-events: none; }
.ck-strip { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #0a0a0a; border-top: 1px solid var(--line2); border-bottom: 1px solid var(--line2); }
.ck-strip .btn { flex: 1; min-height: 48px; padding: 0 6px; font-size: 13px; }
.ck-strip .btn:disabled { opacity: .35; }
.ck-begin { font-size: 15px !important; }
.ck-paused { position: absolute; left: 24px; right: 24px; top: 50%; transform: translateY(-50%); z-index: 2; padding: 20px; border-radius: 18px; background: var(--surface2); border: 2px solid var(--accent); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.ck-paused p { margin: 0; font-size: 13px; color: var(--sub); }
/* 横に置いたときは左右に並べる（左が先攻）。まん中のボタンは縦に並ぶ */
@media (orientation: landscape) {
  .ck-play { flex-direction: row; }
  .ck-strip { flex-direction: column; width: 120px; border: 0; border-left: 1px solid var(--line2); border-right: 1px solid var(--line2); }
  .ck-strip .btn { width: 100%; flex: 1; }
  .ck-side.active .ck-time { font-size: 72px; }
  .ck-paused { left: 50%; right: auto; width: min(360px, 80vw); transform: translate(-50%, -50%); }
}

.ck-result { padding: 14px 14px 20px; display: flex; flex-direction: column; gap: 12px; }
.ck-win { text-align: center; font-size: 40px; font-weight: 900; padding-top: 12px; }
.ck-win.p0 { color: var(--accent); }
.ck-win.p1 { color: var(--sky); }
.ck-got { font-size: 15px; font-weight: 700; }
.ck-got b { font-family: var(--num); font-size: 22px; color: var(--accent); }
.ck-names { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 13px; line-height: 1.5; color: #e6e6e6; overflow-wrap: anywhere; }
