/* 操作画面。黒に近いネイビーの地＋白＋シアン1色。書体は Barlow（英数字）と Noto Sans JP（日本語） */
:root {
  --bg: #090D15;
  --panel: #111723;
  --raise: #182031;
  --line: #222C3D;
  --line2: #2E3A50;
  --text: #EEF2F8;
  --sub: #8C98AB;
  --mute: #5E6A7D;
  --accent: #00B3D6;
  --accent-hi: #29C9E8;
  --ink: #07101C;
  --ok: #3DD68C;
  --danger: #FF5C5C;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 500 15px/1.5 "Barlow", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  font-feature-settings: "palt";
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }

/* ヘッダー */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: rgba(9, 13, 21, 0.92);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top .logo { height: 26px; width: auto; }
.app-name {
  font-size: 12px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--sub);
  padding-left: 14px; border-left: 1px solid var(--line2);
}
.conn { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--sub); }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--mute); }
.conn.ok i { background: var(--ok); box-shadow: 0 0 0 3px rgba(61, 214, 140, 0.15); }
.conn.ng i { background: var(--danger); }
.conn.ng { color: var(--danger); font-weight: 700; }
.conn span, .top .link, .app-name, .games > span { white-space: nowrap; }
.link { background: none; border: 0; padding: 4px; color: var(--sub); font-size: 13px; }
.link:hover { color: var(--text); }

/* コートのタブ */
.tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 14px 16px 0;
  max-width: 1180px; margin: 0 auto;
}
.tab {
  display: grid; gap: 3px; justify-items: start; min-width: 0;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); text-align: left;
}
.tab b { font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--sub); }
.tab small {
  font-family: "Barlow Semi Condensed", sans-serif; font-variant-numeric: tabular-nums;
  font-size: 17px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.tab em { font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--accent); }
.tab em:empty { display: none; }
.tab[aria-selected="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--raise); }
.tab[aria-selected="true"] b { color: var(--accent); }

/* 本体 */
.main {
  display: grid; gap: 16px;
  padding: 14px 16px 28px;
  grid-template-columns: minmax(0, 1fr);
  max-width: 1180px; margin: 0 auto;
}
@media (min-width: 960px) {
  .main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .streams { position: sticky; top: 70px; }
}
.court, .streams {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; display: grid; gap: 14px; min-width: 0;
}

.preview-wrap {
  border-radius: 10px; padding: 16px;
  background:
    radial-gradient(120% 140% at 85% 120%, rgba(0, 179, 214, 0.18), transparent 60%),
    linear-gradient(160deg, #2B3A4E 0%, #1A2433 100%); /* 映像の上に乗ったときの見え方 */
  border: 1px solid var(--line);
  overflow: hidden;
}
.preview-label { font-size: 11px; font-weight: 600; color: rgba(255, 255, 255, 0.55); margin-bottom: 10px; letter-spacing: 0.16em; text-transform: uppercase; }
.preview { font-size: 22px; min-height: 2.9em; }
/* 配信と同じ比率（帯 34px に対してロゴ 150px・すき間 10px） */
.preview-logo { display: block; width: 97px; height: auto; margin-top: 6px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45)); }
@media (max-width: 480px) { .preview { font-size: 17px; } .preview-logo { width: 75px; margin-top: 5px; } }

.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 11px; color: var(--sub); font-weight: 600; letter-spacing: 0.12em; }
.field input, .field select, .team .name {
  width: 100%; min-width: 0;
  border: 1px solid var(--line2); border-radius: 8px; background: var(--bg);
  padding: 10px 12px; font-size: 16px;
}
.field input::placeholder, .team .name::placeholder { color: var(--mute); }
.field input:focus, .field select:focus, .team .name:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 179, 214, 0.2); }
.field select option { background: var(--panel); }

/* ペアごとの操作 */
.teams { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.team {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  background: var(--raise);
}
.team .name { font-weight: 700; }
.now { display: flex; align-items: center; gap: 8px; min-height: 52px; }
.pts {
  margin-left: auto;
  font-family: "Barlow Semi Condensed", sans-serif; font-variant-numeric: tabular-nums;
  font-size: 52px; font-weight: 700; line-height: 1; color: var(--text);
  min-width: 2ch; text-align: right;
}
.serve {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line2); background: transparent; border-radius: 99px;
  padding: 5px 11px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; color: var(--mute);
}
.serve i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--mute); }
.serve:hover { color: var(--sub); border-color: var(--sub); }
.serve.on { border-color: var(--accent); color: var(--accent); cursor: default; }
.serve.on i { background: var(--accent); border-color: var(--accent); }
.plus {
  width: 100%; min-height: 104px;
  border: 0; border-radius: 12px;
  background: var(--accent); color: var(--ink);
  font-size: 28px; font-weight: 800; letter-spacing: 0.02em;
  transition: background 0.12s, transform 0.06s;
}
.plus:hover { background: var(--accent-hi); }
.plus:active { transform: scale(0.98); }
.plus:disabled { background: var(--line); color: var(--mute); transform: none; cursor: default; }
.games { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.12em; color: var(--sub); }
.games > span { margin-right: auto; }
.games b {
  font-family: "Barlow Semi Condensed", sans-serif; font-variant-numeric: tabular-nums;
  font-size: 28px; font-weight: 700; color: var(--text); min-width: 1.6ch; text-align: center; letter-spacing: 0;
}
.games button {
  width: 40px; height: 36px; border-radius: 8px;
  border: 1px solid var(--line2); background: transparent; font-size: 20px; line-height: 1; color: var(--text);
}
.games button:hover { border-color: var(--sub); }
.team.is-win { border-color: var(--accent); }
.team.is-win .pts { font-family: "Noto Sans JP", sans-serif; font-size: 22px; color: var(--accent); }

.actions { display: flex; gap: 10px; }
.undo {
  flex: 1; min-height: 52px; border-radius: 10px;
  border: 1px solid var(--line2); background: transparent; color: var(--text);
  font-size: 16px; font-weight: 700; letter-spacing: 0.04em;
}
.undo:hover { border-color: var(--sub); }
.keys { margin: -6px 0 0; font-size: 12px; color: var(--mute); }
.keys kbd {
  font: 700 11px "Barlow", sans-serif; color: var(--sub);
  border: 1px solid var(--line2); border-radius: 4px; padding: 0 5px; margin: 0 2px;
}
@media (hover: none) { .keys { display: none; } }

/* 試合方式・次の試合へ */
.setup { border-top: 1px solid var(--line); padding-top: 10px; }
.setup summary {
  cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
  font-weight: 700; padding: 4px 0; list-style: none;
}
.setup summary::-webkit-details-marker { display: none; }
.setup summary::before { content: "+"; color: var(--accent); font-weight: 700; width: 12px; }
.setup[open] summary::before { content: "−"; }
.setup summary small { font-weight: 500; color: var(--sub); font-size: 12px; }
.setup-body { display: grid; gap: 14px; padding-top: 12px; }
.fmt { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 12px; }
.next { display: grid; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--bg); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--sub); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.danger {
  min-height: 46px; border-radius: 10px; border: 1px solid rgba(255, 92, 92, 0.5);
  background: transparent; color: var(--danger); font-weight: 700;
}
.danger.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
.hint { margin: 0; font-size: 12px; color: var(--mute); }
.setup-body > .link { justify-self: start; text-align: left; text-decoration: underline; text-underline-offset: 3px; }

/* 配信 */
.streams h2 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--sub); }
#streams { display: grid; gap: 10px; }
.stream { display: grid; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--raise); }
.stream.off { background: transparent; }
.stream.off .seg { opacity: 0.5; }
.stream-head { display: flex; align-items: center; gap: 8px; }
.stream-head b { font-size: 14px; font-weight: 700; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--bg); padding: 3px; border-radius: 9px; border: 1px solid var(--line); }
.seg button {
  border: 0; background: transparent; border-radius: 6px; padding: 7px 0; font-size: 13px; font-weight: 600; color: var(--sub);
}
.seg button[aria-pressed="true"] { background: var(--text); color: var(--ink); }
/* 表示・非表示のスイッチ */
.vis {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; background: transparent; padding: 2px 0; font-size: 12px; font-weight: 600; color: var(--text);
}
.vis::after {
  content: ""; width: 34px; height: 20px; border-radius: 99px; flex: none;
  background: var(--accent) radial-gradient(circle at calc(100% - 10px) 50%, #fff 6px, transparent 6.5px);
  transition: background 0.15s;
}
.vis.off { color: var(--mute); }
.vis.off::after { background: var(--line2) radial-gradient(circle at 10px 50%, #C9D1DD 6px, transparent 6.5px); }
.copy {
  border: 1px solid var(--line2); background: transparent; border-radius: 7px; padding: 3px 9px; font-size: 12px; color: var(--sub);
}
.copy:hover { color: var(--text); border-color: var(--sub); }
.url { width: 100%; font-size: 12px; border: 1px solid var(--line2); border-radius: 6px; padding: 7px; color: var(--sub); background: var(--bg); }

/* つながっていないときは押せない */
body.is-offline .court button, body.is-offline .court input, body.is-offline .court select,
body.is-offline .streams button { pointer-events: none; opacity: 0.45; }

/* ログイン */
.login {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 16px;
  background: radial-gradient(80% 60% at 50% 0%, rgba(0, 179, 214, 0.12), transparent 70%), var(--bg);
}
.login-card {
  width: min(360px, 100%); display: grid; gap: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px;
}
.login-card .logo { width: 200px; max-width: 100%; justify-self: center; }
.login-card h1 { margin: -6px 0 4px; text-align: center; font-size: 11px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--sub); }
.primary {
  min-height: 48px; border: 0; border-radius: 10px; background: var(--accent); color: var(--ink); font-weight: 800; font-size: 16px;
}
.primary:hover { background: var(--accent-hi); }
.login-msg { margin: 0; min-height: 1.5em; color: var(--danger); font-size: 13px; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--text); color: var(--ink); font-weight: 600; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; }

@media (max-width: 520px) {
  .top { gap: 10px; }
  .top .logo { height: 22px; }
  .app-name { display: none; }
  .tabs { gap: 5px; }
  .tab { padding: 8px 8px; }
  .tab small { font-size: 14px; }
  .teams { gap: 8px; }
  .team { padding: 10px; }
  .pts { font-size: 44px; }
  .plus { min-height: 92px; font-size: 24px; }
  .serve { padding: 4px 8px; font-size: 11px; }
  .games { gap: 4px; }
  .games > span { letter-spacing: 0; }
  .games b { font-size: 24px; min-width: 1.4ch; }
  .games button { width: 30px; height: 34px; font-size: 18px; }
}
