:root {
  --bg: #0c1320;
  --panel: #131e32;
  --panel2: #1a2942;
  --line: #2a3d5f;
  --text: #e9eef6;
  --sub: #92a4bf;
  --brand: #1258ad;        /* DARTSLIVE SPORTS ブランドブルー (ロゴ背景) */
  --accent: #2377e0;       /* ボタン等のメインブルー */
  --accent-soft: #6db1ff;  /* 暗背景上の強調テキスト用の明るいブルー */
  --blue: #2f80ed;
  --red: #e05555;
  --green: #3fbf7f;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  min-height: 100vh;
}

#appHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--brand);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; letter-spacing: 1px; color: #fff; }
.brand span { font-weight: 800; }
.brand em { font-style: normal; font-size: 11px; color: rgba(255, 255, 255, .75); margin-left: 6px; }

.env-badge {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .3);
}
.env-badge.prod {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  font-weight: 700;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

h2 { font-size: 18px; margin: 8px 0 16px; }
.sub { color: var(--sub); font-size: 13px; }
.loading { color: var(--sub); text-align: center; padding: 40px 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
}

label { display: block; font-size: 13px; color: var(--sub); margin: 12px 0 4px; }
input[type=email], input[type=password], input[type=text], textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font-size: 15px;
}
textarea { font-family: monospace; font-size: 13px; }

button {
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font-size: 15px;
  cursor: pointer;
  background: var(--panel2);
  color: var(--text);
}
button.primary { background: var(--accent); color: #fff; font-weight: 700; }
button.danger { background: var(--red); color: #fff; font-weight: 700; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--sub); }
button.block { width: 100%; margin-top: 16px; }
button:disabled { opacity: .45; cursor: default; }

.err {
  background: #3a1f22;
  border: 1px solid var(--red);
  color: #ffb9b9;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0;
  font-size: 13px;
  white-space: pre-wrap;
}
.err b { display: block; color: #ffdcdc; margin-bottom: 4px; }

.notice {
  background: #14222e;
  border: 1px solid var(--blue);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0;
  font-size: 13px;
  color: #bcd7f5;
  white-space: pre-wrap;
}

/* card select */
.card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--panel2);
  cursor: pointer;
}
.card-item:hover { border-color: var(--accent-soft); }
.card-item .name { font-weight: 700; }
.card-item .meta { font-size: 12px; color: var(--sub); }
.tag {
  font-size: 11px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 2px 8px;
  font-weight: 700;
}

/* tournament header */
.t-head { border-left: 4px solid var(--accent); padding-left: 10px; margin-bottom: 12px; }
.t-head .t-name { font-size: 16px; font-weight: 700; }
.t-head .t-sub { font-size: 12px; color: var(--sub); margin-top: 2px; }
.badge-live {
  display: inline-block;
  font-size: 11px;
  background: var(--green);
  color: #04140c;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 8px;
  margin-left: 8px;
  vertical-align: 2px;
}

/* tournament blocks (通常トーナメント) */
.tour-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 12px;
  margin-bottom: 12px;
}
.tour-title { font-size: 14px; font-weight: 700; }
.tour-title .flight {
  font-size: 11px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--accent-soft);
  border-radius: 10px;
  padding: 1px 8px;
  margin-left: 6px;
  font-weight: 700;
}
.tour-team { font-size: 12px; color: var(--sub); margin: 4px 0 10px; }
.mtime { font-size: 11px; color: var(--sub); font-weight: 400; margin-left: 6px; }

/* match rows */
.match {
  display: flex;
  align-items: stretch;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel2);
  margin-bottom: 10px;
  padding: 10px 12px;
}
.match.done { opacity: .45; }
.match .no {
  display: flex;
  align-items: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--sub);
  min-width: 28px;
  justify-content: center;
}
.match .body { flex: 1; min-width: 0; }
.match .round { font-size: 11px; color: var(--accent-soft); font-weight: 700; }
.match .vs { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.match .p { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match .p.me { color: var(--accent-soft); font-weight: 700; }
.match .p.right { text-align: right; }
.match .vsmark { font-size: 11px; color: var(--sub); font-weight: 700; }
.match .ump { font-size: 11px; color: var(--sub); }
.match .machine { font-size: 12px; color: var(--sub); margin-top: 4px; }
.match .machine b { color: var(--text); font-size: 14px; }
.match .machine.changed b { color: var(--red); }
.match .machine.changed::after { content: " (変更)"; color: var(--red); }
.match .statusmsg { font-size: 11px; color: var(--green); margin-top: 2px; }
.match .qrbtn {
  align-self: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
}
.match.done .qrbtn { background: var(--panel); color: var(--sub); }

.toolbar { display: flex; gap: 8px; margin: 14px 0; }
.toolbar button { flex: 1; }

/* QR scan */
#qrVideoWrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 3 / 4;
  max-height: 60vh;
}
#qrVideo { width: 100%; height: 100%; object-fit: cover; }
#qrMask {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
#qrMask .frame {
  width: 62%;
  aspect-ratio: 1;
  border: 2px solid rgba(109, 177, 255, .9);
  border-radius: 12px;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, .45);
}
.scan-target { font-size: 13px; color: var(--sub); margin: 10px 0; }
details { margin-top: 14px; }
summary { color: var(--sub); font-size: 13px; cursor: pointer; }

/* result */
.result-msg { font-size: 16px; font-weight: 700; text-align: center; white-space: pre-wrap; margin: 10px 0 16px; }
.score-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 12px 0;
}
.score-row .pl { flex: 1; text-align: center; font-size: 14px; }
.score-row .pl.win { color: var(--accent-soft); font-weight: 700; }
.score-row .sc { font-size: 34px; font-weight: 800; }
.legs table { width: 100%; border-collapse: collapse; font-size: 12px; }
.legs th, .legs td { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: center; }
.legs th { color: var(--sub); font-weight: 400; }
.legs .win { color: var(--accent-soft); font-weight: 700; }
.result-img { width: 100%; border-radius: 8px; margin-top: 12px; }

.footer-note { color: var(--sub); font-size: 11px; text-align: center; margin: 24px 0 8px; }
