:root {
  --bg: #141f14;
  --surface: #1e2e1e;
  --surface2: #253525;
  --surface3: #2d422d;
  --border: #364e36;
  --text: #e4ede4;
  --text-muted: #7a9a7a;
  --green: #4caf50;
  --green-dark: #388e3c;
  --gold: #ffd54f;
  --gold-dim: rgba(255,213,79,0.15);
  --red: #ef5350;
  --red-dim: rgba(239,83,80,0.12);
  --blue: #64b5f6;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 2px 10px rgba(0,0,0,0.4);
  --shadow-gold: 0 0 16px rgba(255,213,79,0.2);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Meiryo', sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* ── Focus Visible (Accessibility) ── */
:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--green);
}

/* ── Page transitions ── */
.main {
  animation: fade-in 0.2s ease-out;
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Toast notification ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 0.88rem;
  font-weight: bold;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  pointer-events: none;
  opacity: 0;
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.toast-success { border-color: var(--green); }
.toast.toast-error { border-color: var(--red); }

/* ── Loading spinner ── */
.btn.loading {
  pointer-events: none;
  opacity: 0.6;
  position: relative;
}
.btn.loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Header ── */
.header {
  background: rgba(30,46,30,0.85);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.header-logo {
  color: var(--gold);
  font-size: 1.1rem;
  font-weight: bold;
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: opacity 0.15s;
}
.header-logo:active { opacity: 0.7; }

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 24px 18px 32px;
  border-top: 1px solid var(--border);
  margin-top: 32px;
}
.footer-link {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-decoration: none;
}
.footer-link:hover { color: var(--text); }

/* ── Hero ── */
.hero {
  text-align: center;
  padding: 32px 16px 24px;
}
.hero-icon { font-size: 3.5rem; margin-bottom: 8px; }
.hero-title {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 8px;
  letter-spacing: 0.03em;
}
.hero-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── Feature grid ── */
.lp-section { margin-top: 28px; }
.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
}
.feature-icon { font-size: 1.5rem; display: block; margin-bottom: 6px; }
.feature-title {
  font-size: 0.85rem;
  font-weight: bold;
  margin-bottom: 4px;
}
.feature-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── How-to steps ── */
.howto-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.howto-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.howto-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--green-dark);
  color: #fff;
  font-size: 0.88rem;
  font-weight: bold;
  border-radius: 50%;
}
.howto-body { flex: 1; min-width: 0; }
.howto-title {
  font-size: 0.9rem;
  font-weight: bold;
  margin-bottom: 4px;
}
.howto-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Terms ── */
.terms-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.7;
}
.terms-box h4 {
  color: var(--text);
  font-size: 0.78rem;
  margin-top: 14px;
  margin-bottom: 4px;
}
.terms-box h4:first-of-type { margin-top: 10px; }
.terms-box p { margin-bottom: 4px; }

/* ── Main ── */
.main {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}
@supports (padding-top: env(safe-area-inset-top)) {
  .header { padding-top: calc(14px + env(safe-area-inset-top)); }
}

/* ── Section ── */
.section { margin-top: 28px; }
.section-title {
  font-size: 0.72rem;
  font-weight: bold;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

/* ── Game header ── */
.game-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.game-title {
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--gold);
  flex: 1;
  line-height: 1.2;
}
.breadcrumb {
  margin-bottom: 4px;
}
.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  transition: color 0.15s;
  min-height: 44px;
}
.back-link:hover, .back-link:active { color: var(--text); }

/* ── Score grid ── */
.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.score-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px 12px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.2s;
  animation: card-appear 0.3s ease-out backwards;
}
.score-card:nth-child(1) { animation-delay: 0s; }
.score-card:nth-child(2) { animation-delay: 0.05s; }
.score-card:nth-child(3) { animation-delay: 0.1s; }
.score-card:nth-child(4) { animation-delay: 0.15s; }
@keyframes card-appear {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
.score-card:active { transform: scale(0.97); }
.score-card.rank-1 {
  border-color: var(--gold);
  box-shadow: var(--shadow), var(--shadow-gold);
  background: linear-gradient(160deg, #1e2e1e 60%, #2a3a1a);
}
.score-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.score-pos {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--surface2);
  padding: 2px 7px;
  border-radius: 5px;
  letter-spacing: 0.03em;
}
.score-rank {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}
.score-card.rank-1 .score-rank {
  background: var(--gold);
  color: #141f14;
}
.score-name {
  font-size: 0.95rem;
  font-weight: bold;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.score-value {
  font-size: 1.65rem;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
  transition: color 0.3s;
}
@media (min-width: 380px) {
  .score-value { font-size: 1.75rem; }
}
.score-diff {
  font-size: 0.8rem;
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}

/* ── Mini score grid (score entry page) ── */
.score-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 16px;
}
.score-mini-card {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
}
.score-mini-pos { color: var(--text-muted); flex-shrink: 0; }
.score-mini-name { flex: 1; font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-mini-val { font-variant-numeric: tabular-nums; font-size: 0.9rem; }

/* ── Colors ── */
.plus  { color: var(--blue); }
.minus { color: var(--red); }
.zero  { color: var(--text-muted); }

/* ── Actions ── */
.actions { margin: 14px 0; display: flex; flex-direction: column; gap: 8px; }
.actions-row {
  display: flex;
  gap: 8px;
}
/* ── 飛び警告バナー ── */
.tobi-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(239,83,80,0.12);
  border: 1.5px solid var(--red);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  animation: card-appear 0.3s ease-out;
}
.tobi-alert-icon { font-size: 1.4rem; flex-shrink: 0; line-height: 1; }
.tobi-alert-body { flex: 1; min-width: 0; font-size: 0.9rem; line-height: 1.5; }
.tobi-alert-desc { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

.danger-zone {
  display: flex;
  justify-content: center;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.btn-text-danger {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  text-decoration: none;
  display: inline-block;
}
.btn-text-danger:hover, .btn-text-danger:active { color: var(--red); background: var(--red-dim); }

/* ── Final result ── */
.final-title { font-size: 0.72rem; font-weight: bold; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 10px; }
.final-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.final-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.final-row:last-child { border-bottom: none; }
.final-rank { width: 24px; color: var(--text-muted); font-size: 0.82rem; font-weight: bold; }
.final-row:first-child .final-rank { color: var(--gold); }
.final-name { flex: 1; font-weight: bold; }
.final-score { font-variant-numeric: tabular-nums; font-size: 0.95rem; }
.final-diff { font-size: 0.82rem; width: 68px; text-align: right; font-variant-numeric: tabular-nums; }
.final-point { font-size: 0.95rem; font-weight: bold; width: 72px; text-align: right; font-variant-numeric: tabular-nums; }
.final-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 0 4px;
  letter-spacing: 0.02em;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: bold;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: filter 0.12s, transform 0.1s;
  min-height: 44px;
  gap: 6px;
}
.btn:active { transform: scale(0.97); filter: brightness(0.9); }
.btn:disabled, .btn.disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}
.btn-primary  { background: var(--green); color: #fff; }
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  flex: 1;
}
.btn-full  { display: flex; width: 100%; }
.btn-large { padding: 15px; font-size: 1.05rem; letter-spacing: 0.02em; }

/* ── Form ── */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 7px; }
.label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.input {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 13px;
  font-size: 1rem;
  width: 100%;
  -webkit-appearance: none;
  transition: border-color 0.15s;
}
.input:focus { outline: none; border-color: var(--green); }
.input-sm { width: 110px; text-align: right; font-size: 1.05rem; }

/* ── Player inputs ── */
.player-inputs { display: flex; flex-direction: column; gap: 8px; }
.player-inputs[hidden] { display: none; }
.player-row { display: flex; align-items: center; gap: 8px; transition: background 0.3s; }
.player-row.shuffle-flash { background: rgba(76,175,80,0.15); border-radius: var(--radius-sm); }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.btn-shuffle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-shuffle:hover { color: var(--text); border-color: var(--green); }
.btn-shuffle:active { transform: scale(0.95); }

.pos-badge {
  width: 34px;
  height: 34px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.9rem;
  flex-shrink: 0;
  color: var(--text-muted);
}

/* ── Index: join hero ── */
.join-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  box-shadow: var(--shadow);
}
.join-hero-label {
  font-size: 0.72rem;
  font-weight: bold;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.room-join-row { display: flex; gap: 8px; }
.room-join-row .input {
  flex: 1;
  letter-spacing: 0.14em;
  font-weight: bold;
  font-size: 1.1rem;
  text-transform: uppercase;
}

/* ── Create group card ── */
.create-group-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  box-shadow: var(--shadow);
}

/* ── Index: divider ── */
.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 0;
  color: var(--text-muted);
  font-size: 0.75rem;
}
.or-divider::before, .or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Index: create section (collapsible) ── */
.create-section { margin-top: 4px; }
.create-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: bold;
  font-size: 0.95rem;
  user-select: none;
  transition: border-color 0.15s;
}
.create-summary::-webkit-details-marker { display: none; }
.create-summary:hover { border-color: var(--green); }
.create-summary-chevron { color: var(--text-muted); transition: transform 0.2s; }
details[open] .create-summary-chevron { transform: rotate(180deg); }
.create-form-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 16px;
}

/* ── Mode tabs ── */
.mode-tabs {
  display: flex;
  margin-bottom: 18px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 3px;
}
.mode-tab {
  flex: 1;
  text-align: center;
  padding: 9px 4px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.92rem;
  transition: background 0.15s, color 0.15s;
  user-select: none;
  color: var(--text-muted);
}
.mode-tab input { display: none; }
.mode-tab:has(input:checked) {
  background: var(--green);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ── Mode sections ── */
.mode-section { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.mode-section[hidden] { display: none; }

/* ── Quick value buttons ── */
.quick-values {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.quick-val {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 5px 10px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, transform 0.1s;
  font-variant-numeric: tabular-nums;
  min-height: 32px;
}
.quick-val:hover { border-color: var(--green); color: var(--text); }
.quick-val:active { transform: scale(0.95); }
.quick-val.selected { border-color: var(--green); color: var(--green); background: rgba(76,175,80,0.1); }

/* ── Tsumo ── */
.tsumo-payers { display: flex; flex-direction: column; gap: 8px; }
.tsumo-payer {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
.tsumo-payer:focus-within { border-color: var(--green); }
.tsumo-payer[hidden] { display: none; }
.tsumo-payer-name { flex: 1; font-weight: 500; }
.tsumo-total-row {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 0.92rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tsumo-total-val { font-size: 1.1rem; font-weight: bold; color: var(--blue); font-variant-numeric: tabular-nums; }

/* ── Custom ── */
.custom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
.custom-row:focus-within { border-color: var(--green); }
.custom-name { flex: 1; font-weight: 500; }
.custom-total-row {
  padding: 11px 13px;
  font-size: 0.92rem;
  color: var(--text-muted);
  background: var(--surface2);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.custom-total-val { font-size: 1.1rem; font-weight: bold; font-variant-numeric: tabular-nums; }
#custom-total.valid  { color: var(--green); }
#custom-total.invalid { color: var(--red); }

/* ── Alert ── */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.5;
}
.alert-error { background: var(--red-dim); border: 1px solid rgba(239,83,80,0.4); color: #ff8a80; }

/* ── Next game notice ── */
.next-game-notice {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ── Room box ── */
.room-box {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  gap: 12px;
}
.room-box-left { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.room-box-label { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.room-box-code { font-size: 1.35rem; font-weight: bold; letter-spacing: 0.2em; color: var(--gold); }
.btn-copy {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  min-height: 36px;
}
.btn-copy:hover { color: var(--text); border-color: var(--green); }
.btn-copy.copied { color: var(--green); border-color: var(--green); }

/* ── Game list ── */
.game-list { display: flex; flex-direction: column; gap: 8px; }
.game-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.1s;
  box-shadow: var(--shadow);
}
.game-card:active { transform: scale(0.98); }
.game-card.active { border-left: 3px solid var(--green); }
.game-card:hover { border-color: var(--green); }
.game-card-title { font-weight: bold; font-size: 1rem; margin-bottom: 4px; }
.game-card-players { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.game-card-player { font-size: 0.75rem; color: var(--text-muted); background: rgba(255,255,255,0.06); border-radius: 4px; padding: 1px 6px; }
.game-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.game-card-date { font-size: 0.78rem; color: var(--text-muted); margin-left: auto; }
.game-card-code { font-size: 0.72rem; color: var(--gold); font-weight: bold; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }
.status-badge {
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status-active   { background: rgba(76,175,80,0.15); color: var(--green); }
.status-finished { background: rgba(122,154,122,0.15); color: var(--text-muted); }

/* ── Log items ── */
.log-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 7px;
  display: flex;
  gap: 10px;
  box-shadow: var(--shadow);
}
.log-num { color: var(--text-muted); font-size: 0.75rem; width: 26px; flex-shrink: 0; padding-top: 2px; }
.log-body { flex: 1; }
.log-desc { font-weight: bold; font-size: 0.9rem; margin-bottom: 5px; }
.log-details { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.log-detail { font-size: 0.8rem; }
.log-time { font-size: 0.72rem; color: var(--text-muted); }

/* ── Unauthorized ── */
.unauth-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 16px 32px;
  gap: 14px;
}
.unauth-icon { font-size: 3.5rem; line-height: 1; }
.unauth-title { font-size: 1.2rem; font-weight: bold; color: var(--gold); }
.unauth-desc { color: var(--text-muted); font-size: 0.9rem; max-width: 280px; line-height: 1.6; }
.unauth-box .form { width: 100%; max-width: 360px; }
.unauth-back { font-size: 0.82rem; color: var(--text-muted); text-decoration: none; margin-top: 8px; }

/* ── History ── */
.history-list { margin-top: 8px; }

/* ── Score Chart ── */
.chart-scroll-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 0 4px;
  margin-bottom: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.chart-inner {
  min-width: 100%;
}
.chart-scroll-wrap canvas {
  display: block;
}
.chart-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 4px 0 0;
}
.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: bold;
  color: var(--text-muted);
}
.chart-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ── Stats ── */
.stats-ranking {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stats-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stats-card.rank-1 {
  border-color: var(--gold);
  box-shadow: var(--shadow), var(--shadow-gold);
}
.stats-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.stats-position {
  font-size: 0.82rem;
  font-weight: bold;
  color: var(--text-muted);
  width: 28px;
}
.stats-card.rank-1 .stats-position { color: var(--gold); }
.stats-name {
  font-size: 1.1rem;
  font-weight: bold;
  flex: 1;
}
.stats-games {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 10px;
}
.stats-points {
  font-size: 1.6rem;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}
.stats-details {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 4px;
  margin-bottom: 10px;
}
.stats-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--surface2);
  border-radius: 6px;
  padding: 8px 4px;
}
.stats-detail-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: bold;
}
.stats-detail-value {
  font-size: 0.95rem;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}
.stats-ranks {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.stats-rank-chip {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.rank-chip-1st { color: var(--gold); background: var(--gold-dim); }
.rank-chip-4th { color: var(--red); background: var(--red-dim); }

/* Stats tabs */
.stats-tabs {
  display: flex;
  background: var(--surface2);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}
.stats-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.stats-tab.active {
  background: var(--green);
  color: #fff;
}

/* Stats detail view */
.stats-detail-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.stats-detail-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.stats-points-sm {
  margin-left: auto;
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stats-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 12px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.stats-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.stats-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px 4px;
}
.stats-metric-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stats-metric-value.highlight-green { color: var(--green); }
.stats-metric-value.highlight-red { color: #ef5350; }
.stats-metric-unit {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 1px;
}
.stats-metric-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
}
.stats-score-range {
  margin-top: 4px;
}
.stats-range-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px 14px;
}
.stats-range-min {
  font-weight: 700;
  font-size: 0.95rem;
  color: #ef5350;
  font-variant-numeric: tabular-nums;
}
.stats-range-max {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}
.stats-range-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
}
.stats-no-data {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 16px;
  font-style: italic;
}

/* ── Share Buttons ── */
.share-buttons {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}
.share-btn {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  padding: 10px 8px;
  white-space: nowrap;
}

/* ── Uma row ── */
.uma-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.uma-row .input-sm { flex: 1; text-align: center; }
.uma-separator {
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: bold;
}

/* ── Deposit box ── */
.deposit-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--gold-dim);
  border: 1px solid rgba(255,213,79,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.deposit-label {
  font-size: 0.72rem;
  font-weight: bold;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.deposit-value {
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* ── Game status bar (honba + deposit) ── */
.game-status-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.status-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  flex: 1;
  min-width: 0;
}
.kyoku-chip {
  background: rgba(76,175,80,0.12);
  border: 1px solid rgba(76,175,80,0.3);
  gap: 6px;
}
.kyoku-chip .status-chip-value {
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--green);
}
.kyoku-chip .status-chip-honba {
  font-size: 0.72rem;
  font-weight: bold;
  color: var(--blue);
  background: rgba(100,181,246,0.12);
  border-radius: 4px;
  padding: 1px 6px;
}
.dealer-chip {
  background: rgba(255,138,101,0.12);
  border: 1px solid rgba(255,138,101,0.3);
}
.dealer-chip .status-chip-label {
  font-size: 0.68rem;
  font-weight: bold;
  color: #ff8a65;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.dealer-chip .status-chip-value {
  font-size: 0.92rem;
  font-weight: bold;
  color: #ff8a65;
}
.deposit-chip {
  background: var(--gold-dim);
  border: 1px solid rgba(255,213,79,0.3);
}
.deposit-chip .status-chip-label {
  font-size: 0.68rem;
  font-weight: bold;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.deposit-chip .status-chip-value {
  font-size: 0.92rem;
  font-weight: bold;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* ── Status edit button ── */
.status-edit-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 6px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
  min-height: 36px;
}
.status-edit-btn:hover { color: var(--text); border-color: var(--green); }
.status-edit-btn:active { transform: scale(0.95); }

/* ── Status edit dealer selector ── */
.status-edit-dealer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.status-dealer-option {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.status-dealer-option:hover { border-color: var(--green); }
.status-dealer-option.active {
  border-color: #ff8a65;
  background: rgba(255,138,101,0.12);
}
.status-dealer-pos {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: bold;
}
.status-dealer-option.active .status-dealer-pos { color: #ff8a65; }
.status-dealer-name {
  font-weight: bold;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Riichi section ── */
.riichi-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-bottom: 18px;
}
.riichi-section[hidden] { display: none; }
.riichi-players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.riichi-toggle {
  cursor: pointer;
  user-select: none;
}
.riichi-toggle input { display: none; }
.riichi-toggle-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color 0.15s, background 0.15s;
}
.riichi-toggle input:checked + .riichi-toggle-inner {
  border-color: var(--gold);
  background: var(--gold-dim);
}
.riichi-pos {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.riichi-toggle input:checked + .riichi-toggle-inner .riichi-pos {
  color: var(--gold);
}
.riichi-name {
  font-weight: bold;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.riichi-deposit-note {
  margin-top: 8px;
}
.form-help {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Noten checkbox ── */
.chombo-info {
  background: var(--red-dim);
  border: 1px solid rgba(239,83,80,0.3);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 10px;
}
.chombo-info-row {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.chombo-info-row:last-of-type { margin-bottom: 0; }
.chombo-role {
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--red);
  background: rgba(239,83,80,0.15);
  border-radius: 4px;
  padding: 1px 6px;
  flex-shrink: 0;
}

.noten-players-selection {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 0.88rem;
  font-weight: bold;
  transition: border-color 0.15s, background 0.15s;
}
.checkbox-label:has(input:checked) {
  border-color: var(--green);
  background: rgba(76,175,80,0.08);
}

/* ── Score Calculator Modal ── */
.btn-calc-open {
  background: none;
  border: 1px solid var(--border);
  color: var(--gold);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-calc-open:hover { border-color: var(--gold); }
.btn-calc-open:active { transform: scale(0.95); }

.calc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(3px);
}
.calc-overlay[hidden] { display: none; }

.calc-modal {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 16px 18px 24px;
  animation: calc-slide-up 0.25s ease-out;
}
@keyframes calc-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.calc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.calc-title {
  font-size: 1.05rem;
  font-weight: bold;
}
.calc-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.calc-close:hover { color: var(--text); background: var(--surface2); }

.calc-auto-role {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
}
.calc-mode-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: bold;
  color: var(--green);
  background: rgba(76,175,80,0.1);
  border: 1px solid var(--green);
  border-radius: 6px;
  padding: 3px 12px;
}
.calc-role-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: bold;
  border-radius: 6px;
  padding: 3px 12px;
}
.calc-role-badge.is-dealer {
  color: #ff8a65;
  background: rgba(255,138,101,0.12);
  border: 1px solid rgba(255,138,101,0.3);
}
.calc-role-badge.is-child {
  color: var(--blue);
  background: rgba(100,181,246,0.12);
  border: 1px solid rgba(100,181,246,0.3);
}

.calc-section { margin-bottom: 14px; }
.calc-section[hidden] { display: none; }
.calc-label {
  display: block;
  font-size: 0.78rem;
  font-weight: bold;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.calc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.calc-chip {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: bold;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-width: 44px;
  text-align: center;
}
.calc-chip:hover { border-color: var(--green); }
.calc-chip.active {
  background: var(--green-dark);
  border-color: var(--green);
  color: #fff;
}

.calc-result {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  margin-bottom: 14px;
}
.calc-result[hidden] { display: none; }
.calc-result-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: bold;
}
.calc-result-value {
  font-size: 2rem;
  font-weight: bold;
  color: var(--gold);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.calc-result-detail {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Score flash animation ── */
.score-flash {
  animation: score-flash 0.5s ease-out;
}
@keyframes score-flash {
  0% { color: var(--gold); }
  100% { color: var(--text); }
}

/* ── Confirm dialog styling ── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade-in-fast 0.15s ease-out;
}
@keyframes fade-in-fast {
  from { opacity: 0; }
  to { opacity: 1; }
}
.confirm-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  max-width: 320px;
  width: 90%;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  animation: confirm-pop 0.2s ease-out;
}
@keyframes confirm-pop {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.confirm-message {
  font-size: 0.95rem;
  font-weight: bold;
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.5;
}
.confirm-actions {
  display: flex;
  gap: 8px;
}
.confirm-actions .btn { flex: 1; }
.btn-danger {
  background: var(--red);
  color: #fff;
}
.btn-outline-danger {
  background: transparent;
  color: var(--red);
  border: 1.5px solid var(--red);
}
.btn-outline-danger:hover, .btn-outline-danger:active {
  background: var(--red-dim);
}

/* ── Empty state improvements ── */
.empty-msg {
  color: var(--text-muted);
  text-align: center;
  padding: 48px 16px;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ── Score entry improvements ── */
.score-entry-submit-area {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  padding: 16px 0 8px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}

/* ── Smooth scrollbar ── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Selection color ── */
::selection {
  background: rgba(76,175,80,0.3);
  color: var(--text);
}

/* ── History Detail Log ── */

.history-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.history-summary-count {
  color: var(--text-muted);
  font-size: 14px;
}
.history-view-toggle {
  display: flex;
  background: var(--surface2);
  border-radius: 8px;
  overflow: hidden;
}
.history-toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.history-toggle-btn.active {
  background: var(--green);
  color: #fff;
}

/* Detail log card */
.detail-log-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  animation: card-appear 0.2s ease-out;
}
.detail-log-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.detail-log-num {
  color: var(--text-muted);
  font-size: 12px;
  min-width: 28px;
}
.detail-log-kyoku {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.detail-honba {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 2px;
}
.detail-log-mode {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.detail-log-mode.mode-ron {
  background: rgba(239,83,80,0.15);
  color: #ef5350;
}
.detail-log-mode.mode-tsumo {
  background: rgba(76,175,80,0.15);
  color: #4caf50;
}
.detail-log-mode.mode-noten {
  background: rgba(255,213,79,0.15);
  color: #ffd54f;
}
.detail-log-mode.mode-custom {
  background: rgba(100,181,246,0.15);
  color: #64b5f6;
}

/* Result display */
.detail-log-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.detail-result-winner {
  display: flex;
  align-items: center;
  gap: 6px;
}
.detail-result-icon {
  font-size: 16px;
}
.detail-result-name {
  font-weight: 600;
  font-size: 14px;
}
.detail-result-amount {
  font-weight: 700;
  font-size: 15px;
}
.detail-result-amount.plus { color: var(--green); }
.detail-result-amount.minus { color: #ef5350; }
.detail-result-arrow {
  color: var(--text-muted);
  font-size: 18px;
}
.detail-result-loser {
  display: flex;
  align-items: center;
  gap: 6px;
}
.detail-result-payers {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 4px;
}
.detail-payer-chip {
  background: rgba(239,83,80,0.1);
  color: #ef5350;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}
.detail-log-result-custom {
  flex-wrap: wrap;
  gap: 6px;
}
.detail-custom-chip {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}
.detail-custom-chip.plus {
  background: rgba(76,175,80,0.1);
  color: var(--green);
}
.detail-custom-chip.minus {
  background: rgba(239,83,80,0.1);
  color: #ef5350;
}

/* Running scores grid */
.detail-log-scores {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}
.detail-score-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 2px;
  border-radius: 6px;
  background: var(--surface2);
}
.detail-score-pos {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}
.detail-score-name {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.detail-score-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-top: 1px;
}
.detail-score-diff {
  font-size: 10px;
  font-weight: 600;
}
.detail-score-diff.plus { color: var(--green); }
.detail-score-diff.minus { color: #ef5350; }

.detail-no-change {
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

.detail-log-time {
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
}

/* Simple view */
.history-simple-view .log-item {
  display: flex;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

/* ── Player individual page ── */
.player-point-hero {
  text-align: center;
  padding: 24px 16px;
  border-radius: var(--radius);
  background: var(--surface2);
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.player-point-hero.plus { border-color: var(--green); background: rgba(76,175,80,0.08); }
.player-point-hero.minus { border-color: var(--red); background: rgba(239,83,80,0.08); }
.player-point-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}
.player-point-value {
  display: block;
  font-size: 2.4rem;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.player-point-hero.plus .player-point-value { color: var(--green); }
.player-point-hero.minus .player-point-value { color: var(--red); }

.player-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.player-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 10px 4px;
}
.player-stat-value {
  font-size: 1rem;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}
.player-stat-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.player-rank-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.rank-chip-pct {
  font-size: 0.7em;
  opacity: 0.75;
}
.rank-chip-2nd { color: #b0b0b0; background: rgba(176,176,176,0.12); }
.rank-chip-3rd { color: #cd7f32; background: rgba(205,127,50,0.12); }

.player-game-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.player-game-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  transition: background 0.15s;
}
.player-game-row:hover { background: var(--surface3, rgba(255,255,255,0.07)); }
.player-game-main {
  display: flex;
  align-items: center;
  gap: 8px;
}
.player-game-sub {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.player-game-rank {
  font-size: 0.8rem;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}
.rank-badge-1 { color: var(--gold); background: var(--gold-dim); }
.rank-badge-2 { color: #b0b0b0; background: rgba(176,176,176,0.12); }
.rank-badge-3 { color: #cd7f32; background: rgba(205,127,50,0.12); }
.rank-badge-4 { color: var(--red); background: var(--red-dim); }
.player-game-title {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-game-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.player-game-score {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.player-game-point {
  font-size: 0.9rem;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}
.player-game-point.plus { color: var(--green); }
.player-game-point.minus { color: var(--red); }

.stats-name-link {
  text-decoration: none;
  color: inherit;
  flex: 1;
}
.stats-name-link:hover .stats-name { text-decoration: underline; text-underline-offset: 2px; }

/* ── Safe area for notched phones ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .footer { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
  .calc-modal { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .score-entry-submit-area { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
