/* --- CSS Variables (default: cyber theme) --- */
:root {
  --bg: rgb(10, 10, 30);
  --border: rgba(0, 229, 255, 0.15);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --accent: #00e5ff;
  --accent2: #7c4dff;
  --text: #e0e0e0;
  --text-muted: rgba(255, 255, 255, 0.5);
  --text-dim: rgba(255, 255, 255, 0.4);
  --rank-label: #b388ff;
  --bar-glow: rgba(0, 229, 255, 0.4);
  --session-accent: rgba(0, 229, 255, 0.7);
  --score-up: #69f0ae;
  --score-down: #ef5350;
  --bar-track: rgba(255, 255, 255, 0.08);
  --font-display: "Orbitron", sans-serif;
  --font-body: "Noto Sans JP", sans-serif;
}

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

body {
  background: transparent;
  font-family: var(--font-body);
  color: var(--text);
  overflow-x: hidden;
}

/* --- Toolbar --- */
#toolbar {
  display: flex;
  gap: 8px;
  padding: 12px 24px;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.toolbar-btn {
  font-family: "Noto Sans JP", sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.toolbar-btn:hover {
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.1);
}

#overlay {
  width: 100vw;
  min-height: 100vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* --- Section groups (3-column grid per element type) --- */
.variant-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  align-items: start;
}

.variant-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* --- Group headings --- */
.group-heading {
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 1px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--border);
}

/* --- Section labels --- */
.section-label {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-dim);
}

.section-gap {
  display: none;
}

/* --- Glass morphism --- */
.glass {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
}

/* ====================================================
   Round Banner (共通)
   ==================================================== */
#round-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  max-width: 400px;
  height: 50px;
}

#round-text {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
}

#honba-text {
  font-size: 17px;
  color: var(--text-muted);
}

/* ====================================================
   Scoreboard A: Standard
   ==================================================== */
.scoreboard {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  height: 48px;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.player-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
  transition: background 0.4s ease;
}

.player-row.rank-1::before { background: linear-gradient(180deg, #ffd700, #ffab00); }
.player-row.rank-2::before { background: linear-gradient(180deg, #b0bec5, #78909c); }
.player-row.rank-3::before { background: linear-gradient(180deg, #a1887f, #795548); }
.player-row.rank-4::before { background: linear-gradient(180deg, #ef5350, #c62828); }

.player-row.rank-1 { border-color: rgba(255, 215, 0, 0.2); }

.player-rank {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 900;
  text-align: center;
  line-height: 1;
}

.rank-1 .player-rank { color: #ffd700; text-shadow: 0 0 12px rgba(255, 215, 0, 0.5); }
.rank-2 .player-rank { color: #b0bec5; }
.rank-3 .player-rank { color: #a1887f; }
.rank-4 .player-rank { color: #ef5350; }

.player-name {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-score {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  text-align: right;
  min-width: 70px;
  transition: color 0.3s ease;
}

.score-up { color: var(--score-up) !important; }
.score-down { color: var(--score-down) !important; }

.score-delta {
  position: absolute;
  right: 16px;
  top: -4px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  opacity: 0;
  animation: deltaFloat 2s ease-out forwards;
  pointer-events: none;
}

.score-delta.positive { color: var(--score-up); }
.score-delta.negative { color: var(--score-down); }

@keyframes deltaFloat {
  0% { opacity: 1; transform: translateY(0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-28px); }
}

/* ====================================================
   Scoreboard B: Compact (横一列)
   ==================================================== */
.scoreboard-compact {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 10px 12px;
}

.compact-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  min-height: 64px;
  justify-content: center;
}

.compact-player .cp-rank {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 900;
}

.compact-player .cp-name {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
  color: var(--text-muted);
}

.compact-player .cp-score {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

/* ====================================================
   Scoreboard C: Minimal
   ==================================================== */
.scoreboard-minimal {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 16px;
}

.minimal-player {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  height: 32px;
  border-bottom: 1px solid var(--border-subtle);
}

.minimal-player:last-child {
  border-bottom: none;
}

.minimal-player .mp-name {
  font-size: 15px;
  font-weight: 700;
}

.minimal-player .mp-score {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-muted);
}

/* ====================================================
   Rank Point A: Standard
   ==================================================== */
#rank-point-a {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 80px;
  justify-content: center;
}

.rank-label {
  font-size: 17px;
  font-weight: 700;
  color: var(--rank-label);
  letter-spacing: 1px;
}

.rank-bar-container {
  width: 100%;
  height: 6px;
  background: var(--bar-track);
  border-radius: 3px;
  overflow: hidden;
}

.rank-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 3px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px var(--bar-glow);
  width: 0%;
}

.rank-pt-text {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--text-muted);
  text-align: right;
}

/* ====================================================
   Rank Point B: Compact (1行)
   ==================================================== */
.rankpoint-compact {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  height: 46px;
}

.rpc-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--rank-label);
  white-space: nowrap;
}

.rpc-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--bar-track);
  border-radius: 3px;
  overflow: hidden;
}

.rpc-bar {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 3px;
  box-shadow: 0 0 8px var(--bar-glow);
  width: 0%;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.rpc-pt {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ====================================================
   Rank Point C: Ring (円形)
   ==================================================== */
.rankpoint-ring {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  height: 110px;
}

.ring-svg {
  width: 80px;
  height: 80px;
  transform: rotate(-90deg);
  flex-shrink: 0;
}

.ring-track {
  fill: none;
  stroke: var(--bar-track);
  stroke-width: 8;
}

.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 0 6px var(--bar-glow));
}

.ring-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ring-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--rank-label);
}

.ring-pt {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--text-muted);
}

/* ====================================================
   Session A: Standard
   ==================================================== */
#session-a {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 14px;
  color: var(--text-dim);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  height: 29px;
}

.session-history {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
  min-height: 32px;
  max-height: 72px;
  overflow: hidden;
}

.session-badge {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 900;
  animation: badgeIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.session-badge.rank-1 { background: rgba(255, 215, 0, 0.2); color: #ffd700; border: 1px solid rgba(255, 215, 0, 0.3); }
.session-badge.rank-2 { background: rgba(176, 190, 197, 0.15); color: #b0bec5; border: 1px solid rgba(176, 190, 197, 0.2); }
.session-badge.rank-3 { background: rgba(161, 136, 127, 0.15); color: #a1887f; border: 1px solid rgba(161, 136, 127, 0.2); }
.session-badge.rank-4 { background: rgba(239, 83, 80, 0.15); color: #ef5350; border: 1px solid rgba(239, 83, 80, 0.2); }

@keyframes badgeIn {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.session-clear-btn {
  margin-top: 6px;
  padding: 6px 14px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.session-clear-btn:hover {
  color: var(--score-down);
  border-color: rgba(239, 83, 80, 0.3);
  background: rgba(239, 83, 80, 0.1);
}

/* ====================================================
   Session B: Compact (横一列)
   ==================================================== */
.session-compact {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 16px;
  flex-wrap: wrap;
  height: 46px;
}

.sc-item {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.sc-label {
  font-size: 12px;
  color: var(--text-dim);
}

.sc-value {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.sc-sep {
  color: var(--border);
  font-size: 14px;
}

/* ====================================================
   Session C: Badges only
   ==================================================== */
.session-badges {
  padding: 10px 16px;
  min-height: 56px;
}

.session-badges .session-history {
  margin-top: 0;
}

/* ====================================================
   Session D: Tally (集計 x-x-x-x)
   ==================================================== */
.session-tally {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 16px;
  height: 56px;
}

.tally-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tally-sub {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-muted);
}

/* ===== 接続インジケータ (サーバー未接続時のみ表示 / ?status=off で無効) ===== */
#conn-status {
  position: fixed;
  right: 8px;
  bottom: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-family: "Noto Sans JP", sans-serif;
  background: rgba(0, 0, 0, 0.55);
  color: #ffb4b4;
  z-index: 9999;
  pointer-events: none;
}
