@import url("https://fonts.googleapis.com/css2?family=DotGothic16&family=Press+Start+2P&display=swap");
/* ボウリング記録 ファミコン版 — 並べ方（レイアウト）。色と文字は、下に続くテーマの部分で決める */
* { box-sizing: border-box; }
body { margin: 0; }
#app { max-width: 860px; margin: 0 auto; padding-block: 0 60px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 10px; padding: 14px 0 6px; }
.top h1 { margin: 0; white-space: nowrap; }
.badge { display: inline-block; margin-left: 6px; }
.sync { margin-left: 8px; font-size: 12px; }
.card { margin-bottom: 14px; }
.card h2 { margin: 0 0 10px; }
.round h3 { margin: 20px 0 8px; }
.muted { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.row.tight { margin: 0; gap: 6px; flex: none; }
.spread { justify-content: space-between; }
button, .btn { font-size: 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; word-break: keep-all; }
th { font-size: 12px; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.nm { white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { padding: 10px 12px; }
.stat b { display: block; }
.stat span { font-size: 12px; }
.kings { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.king .crown { font-size: 26px; }
.mascot-card { text-align: center; }
.mascot-card .t { text-align: left; }
.mname { font-size: 22px; margin-top: 4px; }
.login { max-width: 420px; margin: 60px auto 0; }
.login h1 { text-align: center; }
.hint { padding: 8px 12px; margin-top: 12px; }
.help { padding: 8px 12px; margin: 10px 0 0; }
.day .meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.sessrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; }
.sessrow a:not(.btn) { text-decoration: none; min-width: 0; }
.card > .sessrow:first-of-type { border-top: none; }
.rblock { padding: 12px 0; }
.rblock:first-of-type { border-top: none; }
.pw label, .pw .lab { display: block; font-size: 13px; margin: 12px 0 5px; }
.pw input:not([type="radio"]), .pw textarea { width: 100%; }
textarea { min-height: 84px; resize: vertical; }
.seg { display: flex; gap: 4px; }
.seg label { flex: 1; margin: 0 !important; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: 9px 8px; font-size: 14px; }
.or { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; font-size: 12px; }
.or::before, .or::after { content: ''; flex: 1; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 2px; }
.chips-label { font-size: 12px; }
.chip { padding: 6px 14px; font-size: 13px; text-decoration: none; white-space: nowrap; }
.field { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.field label { font-size: 13px; }
.field input:not([type="number"]) { flex: 1; }
.field input[type="number"] { width: 110px; }

/* スコア表（10フレーム）。狭い画面は5つずつ2段、広い画面は横1列 */
.sheet { padding: 12px 0 8px; }
.sheet:first-of-type { border-top: none; }
.gtop { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.frames { display: grid; gap: 4px; grid-template-columns: repeat(5, 1fr); }
.fr { min-width: 0; text-align: center; }
.fb { display: grid; grid-template-columns: repeat(2, 1fr); }
.fb.n3 { grid-template-columns: repeat(3, 1fr); }
.fb span { height: 30px; display: flex; align-items: center; justify-content: center; }
.fcum { min-height: 28px; display: flex; align-items: center; justify-content: center; }
@media (min-width: 760px) { .frames { grid-template-columns: repeat(9, 1fr) 1.5fr; } }
@media (max-width: 759px) { .fr.last { grid-column: span 1; } }
/* 入力ボタン: 指で押しやすい大きさ（48px以上）で6列 */
.keypad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 10px 0 6px; }
.keypad button { min-height: 48px; padding: 0; font-size: 18px; }
.keypad .wide { grid-column: 1 / -1; font-size: 15px; }
.sgn { display: inline-flex; flex: none; }
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal .card { max-width: 420px; width: 100%; margin: 0; }
.modal .row { justify-content: flex-end; margin-top: 14px; }
.px { display: block; margin: 12px auto 0; height: 112px; width: auto; max-width: 100%; }

/* ============================================================
   ファミコン風デザイン — 黒に近い紺の画面 / 四角いドット枠 / 赤・黄・水色 / ドット文字
   ★ 色を変えたいときは、下の :root の値だけ変える（画面のあちこちに色を直接書かない）
   ============================================================ */

:root {
  /* 配色: 地は3段階の紺、文字は白と薄い青紫、強調は赤（押す）・黄（注目）・水色（リンク）の3色だけ */
  --bg: #0b0b22;
  --card: #15153c;
  --elev: #20205a;
  --ink: #fcfcfc;
  --sub: #a8acf0;
  --line: #4a4ab4;
  --main: #e4002b;      /* 押すもの（主要ボタン・選択中） */
  --main-ink: #ffffff;
  --accent: #fcd000;    /* 注目させるもの（見出し・1位・点数） */
  --link: #3cbcfc;      /* リンク */
  --good: #5ce05c;
  --bad: #ff7a6b;
  --shadow: #000000;
  --dot: "DotGothic16", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  --px: "Press Start 2P", "DotGothic16", monospace;
  color-scheme: dark;
}
html { background: var(--bg); }
body {
  background: var(--bg);
  /* ブラウン管の走査線をうっすら */
  background-image: repeating-linear-gradient(0deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 4px);
  color: var(--ink);
  font-family: var(--dot);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: none;
}
#app { padding-bottom: 104px; display: flow-root; }
a { color: var(--link); }

/* ---- ヘッダー ---- */
.top { padding-top: 16px; }
.top h1 { font-size: 22px; font-weight: 400; color: var(--accent); text-shadow: 3px 3px 0 var(--shadow); letter-spacing: .04em; }
.top .who { color: var(--sub); font-size: 13px; }
.badge { background: var(--elev); color: var(--accent); border: 2px solid var(--accent); border-radius: 0; padding: 0 8px; font-size: 12px; }
.sync, .sync.busy { color: var(--accent); }
.sync.err { color: var(--bad); }
#app > a { display: inline-block; margin: 2px 0 12px; color: var(--link); text-decoration: none; font-size: 15px; }
#app > a:hover { color: var(--accent); }

/* ---- 下のメニュー（ゲームのコマンド選択ふう。選んでいる項目に ▶ が付く） ---- */
nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; margin: 0;
  display: flex; justify-content: center; gap: 0; flex-wrap: nowrap;
  padding: 0 8px env(safe-area-inset-bottom);
  background: #000; border-top: 3px solid var(--ink);
}
nav a, nav a:hover {
  flex: 1; max-width: 200px; min-height: 56px; display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 6px 2px; border-radius: 0; background: transparent; color: var(--sub);
  font-size: 15px; white-space: nowrap; text-decoration: none;
}
nav a:hover { color: var(--ink); }
nav a.on, nav a.on:hover { background: transparent; color: var(--accent); }
nav a.on::before { content: "\25b6"; font-size: 11px; animation: fc-blink 1s steps(1) infinite; }
@keyframes fc-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* ---- カード（角は丸めない。白い枠 + 黒いずらし影） ---- */
.card, .king, .mascot-card {
  background: var(--card); border: 3px solid var(--line); border-radius: 0;
  box-shadow: 5px 5px 0 var(--shadow); padding: 16px 16px;
}
.card h2 { font-size: 19px; font-weight: 400; color: var(--accent); letter-spacing: .03em; }
.round h3 { color: var(--link); font-weight: 400; font-size: 15px; }
.day .date { font: 400 15px/1.4 var(--px); color: var(--ink); }
.sessrow { border-top: 2px dotted var(--line); }
.sessrow a:not(.btn) { color: var(--ink); font-weight: 400; }
.sessrow a:not(.btn):hover { color: var(--accent); text-decoration: none; }
.sessblock, .rblock, .sheet, .grow { border-top: 2px dotted var(--line); }
.help, .hint { background: #000; color: var(--sub); border: 2px solid var(--line); border-radius: 0; font-size: 13px; line-height: 1.7; }
.muted { color: var(--sub); }
.err { color: var(--bad); font-size: 13px; }
.photo { border-radius: 0; border: 3px solid var(--line); }
.loading { font-family: var(--px); font-size: 12px; color: var(--accent); }

/* ---- ボタン（押すと沈む） ---- */
button, .btn {
  background: var(--elev); color: var(--ink); border: 2px solid var(--ink); border-radius: 0;
  font-family: var(--dot); font-weight: 400; padding: 8px 14px; min-height: 40px;
  box-shadow: 3px 3px 0 var(--shadow); transition: none;
}
button:hover:not(:disabled), .btn:hover { transform: none; background: var(--line); box-shadow: 3px 3px 0 var(--shadow); }
button:active:not(:disabled), .btn:active { transform: translate(3px, 3px); box-shadow: none; }
button.primary, .btn.primary { background: var(--main); color: var(--main-ink); border-color: var(--ink); }
button.primary:hover:not(:disabled), .btn.primary:hover { background: #ff2a4f; }
button.danger { color: var(--bad); border-color: var(--bad); background: #000; }
button.danger:hover:not(:disabled) { background: #3a0c12; }
button:disabled { opacity: .45; cursor: default; }
button.small, .btn.small { padding: 5px 12px; min-height: 34px; border-radius: 0; font-size: 14px; }
button:focus-visible, .btn:focus-visible, nav a:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.who button { background: transparent; color: var(--link); border: none; box-shadow: none; min-height: 32px; padding: 3px 8px; }
.who button:hover:not(:disabled) { background: transparent; color: var(--accent); box-shadow: none; }

/* ---- 入力 ---- */
input, select, textarea {
  background: #000; border: 2px solid var(--line); color: var(--ink); border-radius: 0;
  padding: 10px 12px; font-family: var(--dot); font-size: 16px; /* 16px以上: スマホで勝手に拡大されない */
}
input::placeholder, textarea::placeholder { color: #6a6eb8; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
input.bad { border-color: var(--bad); background: #2a0a0e; }
input[type="file"] { background: transparent; border: none; padding: 4px 0; color: var(--sub); font-size: 13px; }
input[type="file"]::file-selector-button {
  background: var(--elev); color: var(--ink); border: 2px solid var(--ink); border-radius: 0;
  padding: 7px 12px; margin-right: 10px; font: inherit; cursor: pointer;
}
.field label, .pw label { color: var(--sub); font-weight: 400; }
.seg { background: #000; border: 2px solid var(--line); border-radius: 0; padding: 3px; }
.seg span { border-radius: 0; font-weight: 400; color: var(--sub); }
.seg input:checked + span { background: var(--accent); color: #000; }
.seg input:focus-visible + span { outline: 3px solid var(--ink); }
.or { color: var(--sub); }
.or::before, .or::after { height: 0; background: none; border-top: 2px dotted var(--line); }
.chip { border-radius: 0; border: 2px solid var(--line); font-weight: 400; background: var(--elev); color: var(--ink); }
.chip.on { background: var(--accent); color: #000; border-color: var(--accent); }
.chips-label { color: var(--sub); font-weight: 400; }
.pickchip, .pickchip:hover:not(:disabled), .pickchip:active:not(:disabled) { border-radius: 0 !important; font-weight: 400; }
.sgn { border-radius: 0; border: 2px solid var(--line); background: #000; }
.draftbox, .pblock { border-radius: 0; background: #000; border: 2px solid var(--line); }
.fr { border-radius: 0; border: 2px solid var(--line); }
.fnum { font-family: var(--px); font-size: 8px; padding: 4px 0; }
.sheet .fcell { font: 400 14px/1 var(--px) !important; }
.fcum { font: 400 12px/1.6 var(--px); color: var(--accent); }

/* ---- 表（点数はドットの数字。1位は黄色） ---- */
table { font-size: 15px; }
th { color: var(--sub); font-weight: 400; border-bottom: 2px solid var(--line); }
td { border-bottom: 2px dotted var(--line); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--elev); }
td a { color: var(--link); text-decoration: none; }
td a:hover { color: var(--accent); }
td.num { font-family: var(--px); font-size: 12px; }
td.num b, .score { font-weight: 400; }
td.rolls { color: var(--sub); font-family: var(--px); font-size: 10px; letter-spacing: 0; line-height: 1.9; }
tbody tr:first-child td.num:first-child { color: var(--accent); }
.score { font-family: var(--px); font-size: 14px; color: var(--accent); }

/* ---- 統計・キング ---- */
.stat { background: #000; border: 2px solid var(--line); border-radius: 0; }
.stat b { font: 400 18px/1.6 var(--px); color: var(--accent); }
.stat span { color: var(--sub); }
.king .t { color: var(--sub); font-size: 13px; }
.king .name { color: var(--ink); font-weight: 400; font-size: 22px; }
.king .val { font: 400 13px/1.8 var(--px); color: var(--accent); }
.king.shame { border-color: var(--bad); }
.king.shame .val { color: var(--bad); }

/* ---- 結果: 天使・骸骨のカード（勝ちは黄の枠、負けは赤の枠） ---- */
.kings > .mascot-card:nth-child(1) { border-color: var(--accent); background: linear-gradient(180deg, #4a3c00 0, var(--card) 70%); }
.kings > .mascot-card:nth-child(2) { border-color: var(--main); background: linear-gradient(180deg, #4a0010 0, var(--card) 70%); }
.mascot-card .t { color: var(--ink); font-size: 14px; letter-spacing: .08em; }
.mname { color: var(--ink); font-weight: 400; }

/* ---- グラフ ---- */
.chart polyline { stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: miter; }
.chart circle { fill: var(--main); stroke: var(--ink); stroke-width: 1; }
.chart line { stroke: var(--line); stroke-dasharray: 2 4; }
.chart text { fill: var(--sub); font-family: var(--px); font-size: 8px; }

/* ---- ログイン（ゲームのタイトル画面） ---- */
.login.card { padding: 22px 20px 20px; }
.login h1 { font-size: 28px; font-weight: 400; color: var(--accent); text-shadow: 3px 3px 0 var(--shadow); letter-spacing: .06em; margin: 0 0 4px; }
.login h1::after { content: "- BOWLING RECORDS -"; display: block; margin-top: 8px; font: 400 10px/1.4 var(--px); color: var(--link); text-shadow: none; letter-spacing: 0; }
.login button.primary { padding: 14px 18px; font-size: 18px; letter-spacing: .1em; }
.login button.primary::before { content: "\25b6  "; animation: fc-blink 1s steps(1) infinite; }
.hint::before { content: "\25bc  "; color: var(--accent); }

/* ---- 編集画面: 「1位 [金額] 円」を狭い画面でも1行に ---- */
.field { flex-wrap: nowrap; }
.field label { min-width: 56px; flex: none; }
.field input[type="date"], .field input:not([type="number"]) { min-width: 0; }

@media (max-width: 560px) {
  .top h1 { font-size: 19px; }
  nav a, nav a:hover { font-size: 13px; }
  .day .date { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  nav a.on::before, .login button.primary::before { animation: none; }
}

/* ---- この版で足した部品の色 ---- */
.sheet, .rblock { border-top: 2px dotted var(--line); }
.sheet.on { background: #000; outline: 3px solid var(--accent); outline-offset: 4px; }
.fr { border: 2px solid var(--line); background: var(--card); }
.fnum { font: 400 8px/1 var(--px); padding: 4px 0; color: var(--sub); background: var(--elev); }
.fb { border-top: 2px solid var(--line); }
.fb span { font: 400 13px/1 var(--px); color: var(--ink); }
.fb span + span { border-left: 2px solid var(--line); }
.fcum { border-top: 2px solid var(--line); font: 400 11px/1 var(--px); color: var(--accent); }
.gtop b { font-weight: 400; font-size: 17px; }
.keypad button:disabled { opacity: .25; }
.pickchip { padding: 8px 14px; min-height: 44px; background: var(--elev); border-color: var(--line); }
.pickchip.on, .pickchip.on:hover:not(:disabled) { background: var(--accent); color: #000; border-color: var(--accent); }
.sgn button { box-shadow: none; border-color: var(--line); background: #000; color: var(--sub); min-height: 44px; }
.sgn button + button { margin-left: -2px; }
.sgn button.on { background: var(--good); color: #000; border-color: var(--ink); }
.sgn button.on.neg { background: var(--bad); }
.plus { color: var(--good); } .minus { color: var(--bad); }
.modal { background: rgba(0, 0, 0, .78); }
.modal .card { border-color: var(--ink); }
.modal p { margin: 0; line-height: 1.8; }
.mascot-card .amount { font: 400 22px/1.6 var(--px); margin-top: 12px; }
.mascot-card.win .amount { color: var(--accent); } .mascot-card.lose .amount { color: var(--bad); }
.mascot-card.win .px { animation: fc-hop .5s steps(2) infinite; }
@keyframes fc-hop { 50% { transform: translateY(-6px); } }
.chart { width: 100%; height: auto; }
.chart .dot { fill: var(--main); stroke: var(--ink); stroke-width: 1.5; }
.login .row { flex-direction: row; }
@media (max-width: 420px) { .sgn button { padding: 6px 8px; font-size: 13px; } .field input[type="number"] { width: 84px; } }
@media (prefers-reduced-motion: reduce) { .mascot-card.win .px { animation: none; } }

/* 隠し入口: ガーターを出すまでは枠を出さない。出るときは下からせり上がる */
.login.gate { margin: 0 auto; min-height: 0; animation: none; }
.login.card { animation: fc-open .6s steps(6) backwards; }
@keyframes fc-open { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .login.card { animation: none; } }

/* 隠し入口の一言: 左から1文字ずつ、カクッと出る。最後に四角いカーソルが点滅する */
.gate-msg { margin: 22px 0 0; text-align: center; font-size: 20px; line-height: 1.6; color: var(--accent); text-shadow: 2px 2px 0 var(--shadow); white-space: nowrap; }
.gate-msg span { animation: fc-hide calc(.5s + var(--i) * 110ms) steps(1); } /* 出番までは隠しておき、時間が来たら見える */
.gate-msg i { display: inline-block; width: .55em; height: 1em; margin-left: 4px; vertical-align: -.12em; background: var(--accent); animation: fc-blink 1s steps(1) infinite; }
@keyframes fc-hide { from, to { opacity: 0; } }
@media (max-width: 380px) { .gate-msg { font-size: 17px; } }
@media (prefers-reduced-motion: reduce) { .gate-msg span { animation: none; } .gate-msg i { animation: none; } }

/* 記録の履歴 */
.hlist { margin-top: 8px; }
.hrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 2px dotted var(--line); }
.hrow:first-child { border-top: none; }
.hrow small { display: block; color: var(--sub); font-size: 12px; }
.sync.busy { color: var(--link); }
