/* テニス親睦大会アプリ 共通スタイル
   屋外・スマホ縦画面が前提: 文字大きめ・白地に濃い文字・タップ領域は 48px 以上 */
:root {
  --ink: #111;
  --bg: #fff;
  --line: #222;
  --soft: #f1f1f1;
  --muted: #444;
  --accent: #0b4fb3;
  --me: #ffe45c;
  --ok: #0a6b2b;
  --warn: #b00020;
}
* { box-sizing: border-box; }
html { font-size: 18px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  line-height: 1.45; overflow-wrap: anywhere;
}
h1 { font-size: 1.15rem; margin: 0; }
h2 { font-size: 1.2rem; margin: 1.2rem 0 .5rem; border-left: 8px solid var(--accent); padding-left: .5rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }
.small { font-size: .85rem; color: var(--muted); }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 12px 110px; }
.wrap.wide { max-width: 1100px; }

button, .btn, select, input, textarea { font: inherit; color: inherit; }
button, .btn {
  min-height: 52px; padding: .5rem 1rem; border: 3px solid var(--line); border-radius: 12px;
  background: #fff; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: .4rem; touch-action: manipulation;
}
button:active, .btn:active { background: #ddd; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: var(--warn); border-color: var(--warn); color: #fff; }
button.ghost { border-color: #888; font-weight: 600; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 4px solid #f90; outline-offset: 2px; }
input[type=text], input[type=number], input[type=time], input[type=date], input[type=password], select, textarea {
  min-height: 48px; padding: .3rem .5rem; border: 2px solid var(--line); border-radius: 8px; background: #fff; max-width: 100%;
}
input[type=checkbox] { width: 26px; height: 26px; }
label { font-weight: 600; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0; }
.stack > * + * { margin-top: .5rem; }

/* ヘッダーと残り時間 */
header.top {
  position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 3px solid var(--line);
}
header.top .bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .4rem 12px; }
header.top .me-btn { min-height: 44px; padding: .2rem .7rem; border-width: 2px; font-size: .9rem; }
.timer { padding: .35rem 12px; color: #fff; background: #333; display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.timer .label { font-weight: 700; font-size: 1rem; }
.timer .clock { font-size: 2.3rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.timer.play { background: var(--ok); }
.timer.play.hurry { background: var(--warn); }
.timer.change { background: var(--accent); }
.timer.over { background: #000; }
.banner { background: var(--warn); color: #fff; font-weight: 700; padding: .4rem 12px; }

/* 下のタブ */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: #fff; border-top: 3px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button { flex: 1; border: 0; border-radius: 0; min-height: 64px; font-size: 1rem; border-right: 1px solid #999; padding: .2rem; }
nav.tabs button:last-child { border-right: 0; }
nav.tabs button[aria-selected=true] { background: var(--ink); color: #fff; }

/* 自分の出番 */
.mycard { border: 4px solid var(--line); border-radius: 14px; padding: .6rem .8rem; margin: .8rem 0; background: var(--me); }
.mycard .big { font-size: 1.25rem; font-weight: 800; }
.mycard .k { display: inline-block; min-width: 3.2em; font-weight: 800; }

/* ラウンド選択 */
.chips { display: flex; gap: .4rem; overflow-x: auto; padding: .3rem 0; }
.chips button { min-width: 62px; min-height: 48px; padding: .2rem .5rem; border-width: 2px; flex: none; }
.chips button[aria-pressed=true] { background: var(--ink); color: #fff; }
.chips button.cur::after { content: "●"; font-size: .6rem; color: #e00; margin-left: .15rem; }

/* 試合カード */
.round-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-top: 1rem; }
.round-head .t { font-size: 1.3rem; font-weight: 800; }
.match {
  display: block; width: 100%; text-align: left; border: 3px solid var(--line); border-radius: 14px; padding: .5rem .7rem;
  margin: .5rem 0; background: #fff; min-height: 0; font-weight: 400;
}
.match.mine { background: var(--me); border-width: 5px; }
.match .court { font-weight: 800; font-size: .95rem; display: flex; justify-content: space-between; }
.match .court .hint { font-weight: 600; color: var(--muted); font-size: .85rem; }
.match .side { display: flex; align-items: center; justify-content: space-between; gap: .5rem; width: 100%; }
.match .names { font-size: 1.2rem; font-weight: 700; }
.match .names .lv { font-size: .8rem; font-weight: 600; color: var(--muted); }
.match .pt { font-size: 1.9rem; font-weight: 800; min-width: 1.6em; text-align: right; font-variant-numeric: tabular-nums; }
.match .pt.none { color: #999; }
.match .vs { border-top: 2px dashed #888; margin: .25rem 0; }
.match .side.win .names::after { content: " ◯"; color: var(--ok); }
.me-name { text-decoration: underline; text-decoration-thickness: 3px; }
.rests { border: 2px dashed #555; border-radius: 12px; padding: .5rem .7rem; margin: .5rem 0; }
.rests b { margin-right: .4rem; }
.rests.mine { background: var(--me); border-style: solid; border-width: 4px; border-color: var(--line); }
.note { background: var(--soft); border-radius: 12px; padding: .6rem .8rem; margin: .5rem 0; }
.note.warn { background: #ffe9e9; border: 2px solid var(--warn); }

/* 表 */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #555; padding: .35rem .4rem; text-align: center; }
th { background: var(--soft); font-size: .9rem; }
td.l, th.l { text-align: left; }
table.standings td { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
table.standings td.l { font-weight: 700; }
tr.mine td { background: var(--me); }
table.matrix th, table.matrix td { padding: .15rem .25rem; font-size: .8rem; min-width: 1.7em; }
table.matrix td.dup { background: var(--warn); color: #fff; font-weight: 800; }
table.matrix td.self { background: #999; }
table.matrix td.one { background: #d8ecd8; }

/* スコア入力シート・名前選択 */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; }
.overlay.center { align-items: center; }
.sheet { background: #fff; width: 100%; max-width: 720px; max-height: 96vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 1rem 14px calc(1rem + env(safe-area-inset-bottom)); }
.overlay.center .sheet { border-radius: 18px; margin: 12px; }
.sheet h2 { margin-top: 0; }
.counter { display: grid; grid-template-columns: 84px 1fr 84px; align-items: center; gap: .5rem; margin: .3rem 0 .9rem; }
.counter button { min-height: 84px; font-size: 2.6rem; border-width: 4px; padding: 0; }
.counter .val { text-align: center; font-size: 3.4rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.counter-name { font-size: 1.25rem; font-weight: 800; }
.sheet .actions { display: grid; gap: .5rem; margin-top: .6rem; }
.sheet .actions button.primary { min-height: 68px; font-size: 1.3rem; }
.namegrid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.namegrid button { min-height: 60px; font-size: 1.1rem; }
.toast { position: fixed; left: 12px; right: 12px; bottom: 84px; z-index: 60; background: #111; color: #fff; padding: .7rem 1rem; border-radius: 12px; font-weight: 700; text-align: center; }
.toast.err { background: var(--warn); }
.colist { display: grid; grid-template-columns: 1fr auto; gap: .2rem .8rem; }
.colist .n { font-variant-numeric: tabular-nums; font-weight: 700; }
footer.mode { margin-top: 1.5rem; }

/* 幹事画面 */
details.sec { border: 3px solid var(--line); border-radius: 14px; margin: .8rem 0; padding: 0 .8rem; }
details.sec > summary { font-size: 1.2rem; font-weight: 800; padding: .8rem 0; cursor: pointer; }
details.sec[open] { padding-bottom: .8rem; }
.players-edit .prow { display: grid; grid-template-columns: 1.8em 1fr 4.2em auto auto; gap: .4rem; align-items: center; margin: .3rem 0; }
.players-edit .prow input[type=text] { width: 100%; min-width: 0; }
.players-edit .prow button { min-height: 44px; padding: .2rem .6rem; border-width: 2px; }
.formgrid { display: grid; grid-template-columns: auto 1fr; gap: .5rem .8rem; align-items: center; }
.formgrid input[type=number] { width: 6em; }
.status-line { font-size: 1.1rem; font-weight: 800; padding: .5rem .7rem; border-radius: 10px; background: var(--soft); margin: .5rem 0; }
.status-line.late { background: #ffe9e9; color: var(--warn); border: 2px solid var(--warn); }
.roundctl { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
@media (min-width: 700px) { .roundctl { grid-template-columns: repeat(3, 1fr); } }
.roundctl button { flex-direction: column; gap: 0; }
.roundctl button.running { background: var(--ok); border-color: var(--ok); color: #fff; }
