/* ════════════════════════════════════════
   ToN Stats Tracker — style.css
   ════════════════════════════════════════ */

/* ── CSS VARIABLES ── */
:root {
  --bg-deep: #07070d;
  --bg-panel: #0e0e1a;
  --bg-card: #131320;
  --bg-hover: #1a1a2e;
  --border: #2a2a3e;
  --border-glow: #4a3a6e;
  --text-muted: #4a4a6a;
  --text-dim: #7a7a9a;
  --accent-red: #cc2233;
  --accent-red-glow: rgba(204, 34, 51, 0.3);
  --scanline: rgba(0, 0, 0, 0.15);

  /* Modifier colors */
  --col-alternate: #e8e8f0;
  --col-punished:  #d4a017;
  --col-cracked:   #9b59b6;
  --col-fog:       #8a9aaa;
  --col-bloodbath: #e74c3c;
  --col-midnight:  #c0392b;
  --col-ghost:     #5bc8d8;
  --col-8pages:    #dde0e8;
  --col-unbound:   #e67e22;
}

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

/* ── BASE ── */
body {
  background: var(--bg-deep);
  color: #ccc;
  font-family: 'Courier New', Courier, monospace;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* CRT scanlines overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    var(--scanline) 3px,
    var(--scanline) 4px
  );
  pointer-events: none;
  z-index: 1000;
  opacity: 0.4;
}

/* Vignette */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.7) 100%);
  pointer-events: none;
  z-index: 999;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* ── HEADER ── */
header {
  text-align: center;
  padding: 36px 0 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  position: relative;
}

header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 1px;
  background: var(--accent-red);
  box-shadow: 0 0 12px var(--accent-red);
}

.header-eyebrow {
  font-size: 10px;
  letter-spacing: 0.4em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 10px;
}

h1 {
  font-size: clamp(22px, 4vw, 36px);
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.08em;
  text-shadow: 0 0 20px rgba(200, 50, 50, 0.5), 0 0 40px rgba(200, 50, 50, 0.2);
}

h1 span {
  color: var(--accent-red);
}

.header-sub {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.2em;
}

/* ── SECTION HEADINGS ── */
.section-title {
  font-size: 10px;
  letter-spacing: 0.4em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-left: 2px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── ROUND COUNTER ── */
.round-section {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
}

.round-section::before {
  content: 'ROUND';
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 80px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.03);
  pointer-events: none;
  letter-spacing: 0.1em;
}

.round-label {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--text-muted);
  text-transform: uppercase;
  flex: 0 0 auto;
}

.round-number {
  font-size: clamp(36px, 6vw, 56px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
  min-width: 80px;
}

/* ── BUTTONS (round) ── */
.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  background: none;
  border: 1px solid var(--border);
  color: #aaa;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.1em;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
  text-transform: uppercase;
}

.btn:hover {
  border-color: var(--accent-red);
  color: #fff;
  background: rgba(204, 34, 51, 0.1);
  box-shadow: 0 0 10px var(--accent-red-glow);
}

.btn.btn-inc {
  border-color: #2a4a2a;
  color: #6a9a6a;
}
.btn.btn-inc:hover {
  border-color: #4a8a4a;
  color: #9aca9a;
  background: rgba(74, 138, 74, 0.1);
  box-shadow: 0 0 10px rgba(74, 138, 74, 0.3);
}

.btn.btn-dec {
  border-color: #4a2a2a;
  color: #9a4a4a;
}
.btn.btn-dec:hover {
  border-color: #8a3a3a;
  color: #ca7a7a;
  background: rgba(138, 58, 58, 0.1);
  box-shadow: 0 0 10px rgba(138, 58, 58, 0.3);
}

.btn.btn-reset-sm {
  font-size: 10px;
  padding: 6px 10px;
  color: var(--text-muted);
}

/* ── MODIFIER CARDS ── */
.modifiers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.mod-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  overflow: hidden;
}

.mod-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: currentColor;
  opacity: 0.6;
}

.mod-card:hover {
  border-color: var(--border-glow);
  background: var(--bg-hover);
}

.mod-name {
  flex: 1;
  min-width: 0;
}

.mod-name-en {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.mod-name-jp {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
  letter-spacing: 0.1em;
}


.mod-count {
  font-size: 28px;
  font-weight: 900;
  min-width: 52px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.mod-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mod-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  width: 26px;
  height: 26px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.mod-btn.plus:hover {
  border-color: #4a8a4a;
  color: #9aca9a;
  background: rgba(74, 138, 74, 0.15);
}

.mod-btn.minus:hover {
  border-color: #8a3a3a;
  color: #ca7a7a;
  background: rgba(138, 58, 58, 0.15);
}

/* ── STATS SECTION ── */
.stats-section {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  margin-bottom: 24px;
}

.stats-title {
  font-size: 10px;
  letter-spacing: 0.4em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-name {
  font-size: 11px;
  min-width: 90px;
  letter-spacing: 0.05em;
}

.stat-bar-wrap {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 2px;
  height: 10px;
  overflow: hidden;
}

.stat-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.stat-pct {
  font-size: 11px;
  min-width: 36px;
  text-align: right;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ── IO SECTION ── */
.io-section {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.btn-io {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.2em;
  padding: 9px 18px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
  text-transform: uppercase;
}

.btn-io:hover {
  border-color: var(--accent-red);
  color: #fff;
  background: rgba(204, 34, 51, 0.08);
}

.btn-io.btn-import:hover {
  border-color: #4a6a9a;
  background: rgba(74, 106, 154, 0.1);
}

.btn-io.btn-danger {
  color: #6a2a2a;
  border-color: #3a1a1a;
}
.btn-io.btn-danger:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
  background: rgba(204, 34, 51, 0.08);
}

#file-input { display: none; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-card);
  border: 1px solid var(--accent-red);
  color: #ddd;
  font-size: 12px;
  letter-spacing: 0.1em;
  padding: 10px 20px;
  border-radius: 3px;
  transition: transform 0.25s ease;
  z-index: 2000;
  white-space: nowrap;
  box-shadow: 0 0 20px var(--accent-red-glow);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ── FOOTER ── */
footer {
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.2em;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── WEBSOCKET SECTION ── */
.ws-section {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ws-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Animated dot */
.ws-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background 0.3s;
}
.ws-dot.connecting { background: #d4a017; animation: ws-pulse 1s infinite; }
.ws-dot.connected  { background: #4a8a4a; animation: ws-pulse 2s infinite; }
.ws-dot.error      { background: var(--accent-red); }

@keyframes ws-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.ws-status-text {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  min-width: 60px;
}
.ws-status-text.connecting { color: #d4a017; }
.ws-status-text.connected  { color: #6aba6a; }
.ws-status-text.error      { color: var(--accent-red); }

.btn-ws-connect {
  border-color: #2a4a2a;
  color: #6a9a6a;
  font-size: 11px;
  padding: 6px 16px;
}
.btn-ws-connect:hover {
  border-color: #4a8a4a;
  color: #9aca9a;
  background: rgba(74,138,74,0.1);
  box-shadow: 0 0 10px rgba(74,138,74,0.3);
}
.btn-ws-connect.disconnect {
  border-color: #4a2a2a;
  color: #9a5a5a;
}
.btn-ws-connect.disconnect:hover {
  border-color: var(--accent-red);
  color: #ca7a7a;
  background: rgba(204,34,51,0.1);
}

/* ── RATIO TOGGLES ── */
.ratio-toggles {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.ratio-toggle-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  flex-shrink: 0;
}

.btn-ratio-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 4px 12px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s;
  text-transform: uppercase;
}

.btn-ratio-toggle:hover {
  border-color: var(--border-glow);
  color: #ccc;
}

.btn-ratio-toggle.active {
  border-color: #4a6a9a;
  color: #8ab0da;
  background: rgba(74, 106, 154, 0.12);
  box-shadow: 0 0 8px rgba(74, 106, 154, 0.2);
}
