/* ═══════════════════════════════════════════════════════════════
   AI Ring — Modern Dark SaaS Stylesheet
   Clean, professional design inspired by Linear / Vercel / shadcn
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
  --bg:           #080814;
  --surface:      #0f1020;
  --surface2:     #151628;
  --surface3:     #1c1e33;
  --border:       #1e2142;
  --border-light: #2a2d52;
  --text:         #e2e8f0;
  --text-muted:   #6b7280;
  --accent:       #6366f1;
  --accent-hover: #4f46e5;
  --accent2:      #06b6d4;
  --success:      #10b981;
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --gold:         #f59e0b;
  --limit:        #f97316;
  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 4px 24px rgba(0,0,0,0.5);
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.35);
  --primary-font: 'Inter', system-ui, sans-serif;
  --mono-font:    'JetBrains Mono', 'Fira Code', monospace;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--primary-font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover { color: var(--accent-hover); }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Utility ────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Modern Card (replaces ff7-panel) ──────────────────────── */
.ff7-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: relative;
}
.ff7-panel::before,
.ff7-panel::after { display: none; }

/* ═══════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 8, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-icon {
  font-size: 22px;
  line-height: 1;
}

.logo-text {
  font-family: var(--primary-font);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--accent);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-sub {
  font-family: var(--mono-font);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Header Buttons ─────────────────────────────────────────── */
.settings-btn,
.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-light);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--primary-font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}

.settings-btn:hover,
.header-btn:hover {
  background: var(--surface3);
  border-color: var(--accent);
  color: var(--accent);
}

.settings-btn:focus-visible,
.header-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.demo-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ── API Status Badge ───────────────────────────────────────── */
.api-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.api-status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.api-status-badge.api-live {
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--success);
}

.api-status-badge.api-live::before {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse-dot 2s infinite;
}

.api-status-badge.api-demo {
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--warning);
}

.api-status-badge.api-demo::before {
  background: var(--warning);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ═══════════════════════════════════════════════════════════════
   SETTINGS PANEL
   ═══════════════════════════════════════════════════════════════ */
.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.settings-panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.settings-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.settings-row:last-child { margin-bottom: 0; }

.settings-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.settings-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--primary-font);
  font-size: 13px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.settings-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.settings-input::placeholder { color: var(--text-muted); }

.settings-status {
  font-size: 11px;
  font-family: var(--mono-font);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.settings-status.ok {
  color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}

.settings-status.err {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.settings-status.info {
  color: var(--accent2);
  background: rgba(6, 182, 212, 0.1);
}

.settings-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.settings-save-btn {
  flex: 1;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  font-family: var(--primary-font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.settings-save-btn:hover {
  background: rgba(16, 185, 129, 0.22);
  border-color: var(--success);
}

.settings-save-btn:focus-visible {
  outline: 2px solid var(--success);
  outline-offset: 2px;
}

.settings-clear-btn {
  flex: 1;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
  color: var(--danger);
  font-family: var(--primary-font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.settings-clear-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: var(--danger);
}

.settings-clear-btn:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   MAIN LAYOUT
   ═══════════════════════════════════════════════════════════════ */
.layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 24px 40px;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 24px;
  align-items: start;
}

/* ═══════════════════════════════════════════════════════════════
   ROOM / 3D ARENA SECTION
   ═══════════════════════════════════════════════════════════════ */
.room-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.room-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.room-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
}

/* The battle arena — Three.js canvas renders inside here */
.room {
  aspect-ratio: 4 / 3;
  position: relative;
  overflow: hidden;
  width: 100%;
  background: var(--bg);
}

/* Three.js canvas fills the room completely */
.room canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Hide the old 2D floor canvas */
#room-floor {
  display: none !important;
}

/* Subtle inner glow overlay (kept for JS toggling) */
.arena-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  border-radius: inherit;
  background: radial-gradient(
    ellipse 80% 50% at 50% 100%,
    rgba(99, 102, 241, 0.08) 0%,
    transparent 70%
  );
  transition: opacity 0.4s ease;
}

/* ── Round Indicator ────────────────────────────────────────── */
.round-indicator {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.round-label {
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 600;
  color: rgba(226, 232, 240, 0.7);
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.round-pips {
  display: flex;
  gap: 5px;
  align-items: center;
}

.round-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.round-pip.done {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 6px rgba(99, 102, 241, 0.6);
}

.round-pip.current {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.7);
  animation: pip-pulse 1.2s infinite;
}

@keyframes pip-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.85; }
}

/* ── Thinking Overlay ───────────────────────────────────────── */
.thinking-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(8, 8, 20, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.thinking-overlay.active { opacity: 1; }

.thinking-dots {
  display: flex;
  gap: 6px;
}

.thinking-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: thinking-bounce 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-10px); opacity: 1; }
}

/* ── Zoom Button ────────────────────────────────────────────── */
.zoom-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 20;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: rgba(15, 16, 32, 0.75);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.zoom-btn:hover {
  background: var(--surface3);
  color: var(--text);
  border-color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════
   AGENT ELEMENTS (overlaid on 3D canvas)
   ═══════════════════════════════════════════════════════════════ */

/* Agent wrapper — positioned absolutely inside .room by JS */
.agent-wrapper {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: default;
  z-index: 10;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* Three.js renders the agent 3D model — hide DOM sprites */
.agent-sprite  { display: none; }
.pixel-sprite  { display: none; }
.agent         { display: none; }
.agent-ring    { display: none; }
.agent-pulse   { display: none; }

/* Agent name label */
.agent-label {
  font-family: var(--primary-font);
  font-size: 11px;
  font-weight: 600;
  color: var(--color, var(--text));
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.7);
  letter-spacing: 0.2px;
  transition: color 0.3s ease, opacity 0.3s ease, text-shadow 0.3s ease;
}

/* Agent score display */
.agent-score {
  font-family: var(--mono-font);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  transition: color 0.3s ease, opacity 0.3s ease;
}

/* Speech bubble */
.agent-bubble {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: rgba(15, 16, 32, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  font-family: var(--primary-font);
  color: var(--text);
  white-space: nowrap;
  max-width: 200px;
  white-space: normal;
  text-align: center;
  z-index: 15;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.agent-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--border-light);
}

.agent-bubble.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Battle State Classes ───────────────────────────────────── */

/* Thinking: label pulses with glow */
.agent-wrapper.thinking .agent-label {
  animation: label-pulse 1.2s ease-in-out infinite;
  text-shadow: 0 0 12px var(--color, var(--accent)), 0 1px 4px rgba(0,0,0,0.9);
}

@keyframes label-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Winner: brighten label, gold score */
.agent-wrapper.winner .agent-label {
  color: #fff;
  text-shadow: 0 0 14px var(--gold), 0 1px 4px rgba(0,0,0,0.9);
}

.agent-wrapper.winner .agent-score {
  color: var(--gold);
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

/* Loser: dim out */
.agent-wrapper.loser {
  opacity: 0.35;
}

/* Minimal stubs for JS animation classes — Three.js handles visuals */
.agent-wrapper.charging {}
.agent-wrapper.lunging-right {}
.agent-wrapper.lunging-left {}
.agent-wrapper.flinching-left {}
.agent-wrapper.flinching-right {}
.agent-wrapper.hit {}
.agent-wrapper.fighting {}

/* ═══════════════════════════════════════════════════════════════
   BATTLE EFFECTS (spawned dynamically into #room)
   ═══════════════════════════════════════════════════════════════ */

/* Impact flash — white/cyan star burst */
.impact-flash {
  position: absolute;
  pointer-events: none;
  z-index: 50;
  width: 60px;
  height: 60px;
  transform: translate(-50%, -50%);
  animation: impact-burst 0.45s ease-out forwards;
}

.impact-flash::before,
.impact-flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    rgba(255, 255, 255, 0.9) 15deg,
    transparent 30deg,
    rgba(6, 182, 212, 0.8) 45deg,
    transparent 60deg,
    rgba(255, 255, 255, 0.9) 75deg,
    transparent 90deg,
    rgba(6, 182, 212, 0.8) 105deg,
    transparent 120deg,
    rgba(255, 255, 255, 0.9) 135deg,
    transparent 150deg,
    rgba(6, 182, 212, 0.8) 165deg,
    transparent 180deg,
    rgba(255, 255, 255, 0.9) 195deg,
    transparent 210deg,
    rgba(6, 182, 212, 0.8) 225deg,
    transparent 240deg,
    rgba(255, 255, 255, 0.9) 255deg,
    transparent 270deg,
    rgba(6, 182, 212, 0.8) 285deg,
    transparent 300deg,
    rgba(255, 255, 255, 0.9) 315deg,
    transparent 330deg,
    rgba(6, 182, 212, 0.8) 345deg,
    transparent 360deg
  );
  border-radius: 50%;
  clip-path: polygon(
    50% 0%, 55% 40%, 100% 50%, 55% 60%,
    50% 100%, 45% 60%, 0% 50%, 45% 40%
  );
}

.impact-flash::after {
  transform: rotate(22.5deg);
  opacity: 0.7;
}

@keyframes impact-burst {
  0%   { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
  60%  { transform: translate(-50%, -50%) scale(1.3); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

/* Damage number */
.damage-number {
  position: absolute;
  pointer-events: none;
  z-index: 55;
  font-family: var(--mono-font);
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  text-shadow:
    0 0 8px rgba(245, 158, 11, 0.8),
    0 2px 4px rgba(0,0,0,0.9),
    1px 1px 0 rgba(0,0,0,0.8);
  transform: translate(-50%, -50%);
  animation: damage-float 1.2s ease-out forwards;
  white-space: nowrap;
}

@keyframes damage-float {
  0%   { transform: translate(-50%, -50%) scale(0.6) translateY(0); opacity: 1; }
  20%  { transform: translate(-50%, -50%) scale(1.2) translateY(-8px); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.9) translateY(-40px); opacity: 0; }
}

/* Materia shot */
.materia-shot {
  position: absolute;
  pointer-events: none;
  z-index: 40;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, var(--accent2) 50%, transparent 100%);
  box-shadow: 0 0 10px var(--accent2), 0 0 20px rgba(6, 182, 212, 0.5);
  transform: translate(-50%, -50%);
  /* JS moves the element via CSS custom properties --x/--y; use transform for compositing */
  transition: transform 0.3s linear;
}

/* Room flash overlay */
.room-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.12);
  animation: room-flash-fade 0.35s ease-out forwards;
}

@keyframes room-flash-fade {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* Spark particle */
.spark {
  position: absolute;
  pointer-events: none;
  z-index: 45;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 4px var(--accent2);
  transform: translate(-50%, -50%);
  animation: spark-fly var(--duration, 0.6s) ease-out forwards;
}

@keyframes spark-fly {
  0%   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% {
    transform: translate(
      calc(-50% + var(--tx, 30px)),
      calc(-50% + var(--ty, -30px))
    ) scale(0);
    opacity: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════
   CHAT SECTION (right column)
   ═══════════════════════════════════════════════════════════════ */
.chat-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ── Input Panel ────────────────────────────────────────────── */
.input-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.input-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.input-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.5;
}

.input-row {
  margin-bottom: 12px;
}

.prompt-textarea {
  width: 100%;
  min-height: 90px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--primary-font);
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.prompt-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.prompt-textarea::placeholder { color: var(--text-muted); }

/* Rounds selector */
.rounds-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.rounds-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.rounds-btns {
  display: flex;
  gap: 4px;
}

.rounds-btn {
  width: 30px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--surface2);
  color: var(--text-muted);
  font-family: var(--mono-font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rounds-btn:hover {
  background: var(--surface3);
  border-color: var(--accent);
  color: var(--text);
}

.rounds-btn.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: var(--accent);
  color: var(--accent);
}

/* Input actions row */
.input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.char-count {
  font-family: var(--mono-font);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.submit-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: var(--primary-font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.35);
}

.submit-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.5);
}

.submit-btn:active { transform: scale(0.98); }

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.submit-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-icon {
  font-size: 14px;
  line-height: 1;
}

/* ═══════════════════════════════════════════════════════════════
   WINNER PANEL
   ═══════════════════════════════════════════════════════════════ */
.winner-panel {
  background: var(--surface);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 4px 24px rgba(245, 158, 11, 0.1), var(--shadow-sm);
}

.winner-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.winner-crown {
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.7));
}

.winner-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.winner-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.3;
}

.winner-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--gold);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.winner-response {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  border-left: 3px solid rgba(245, 158, 11, 0.5);
  padding-left: 12px;
  background: rgba(245, 158, 11, 0.04);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 12px;
  max-height: 200px;
  overflow-y: auto;
}

.win-narrative {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 10px;
  line-height: 1.5;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════════
   ALL RESPONSES / ACCORDION
   ═══════════════════════════════════════════════════════════════ */
.all-responses {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.accordion-toggle {
  width: 100%;
  padding: 14px 18px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--primary-font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.2s ease;
  text-align: left;
}

.accordion-toggle:hover { background: var(--surface2); }

.accordion-toggle::after {
  content: '⌄';
  font-size: 14px;
  color: var(--text-muted);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.accordion-toggle[aria-expanded="true"]::after {
  transform: rotate(180deg);
}

.accordion-content {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Response cards */
.response-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.response-card:hover { border-color: var(--border-light); }

.response-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.response-model {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.response-score {
  font-family: var(--mono-font);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent2);
}

.response-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.response-body {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  max-height: 150px;
  overflow-y: auto;
}

/* ═══════════════════════════════════════════════════════════════
   SCOREBOARD
   ═══════════════════════════════════════════════════════════════ */
.scoreboard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.scoreboard-title,
.scoreboard-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.7px;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.score-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.2s ease;
}

.score-row:hover { background: var(--surface2); }

.score-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 0 0 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.score-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent2) 100%);
  /* Use scaleX transform for GPU-composited animation; transform-origin anchors to left */
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* JS-generated score bar element (uses inline style.width) */
.score-row-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--surface3);
  border-radius: 3px;
  overflow: hidden;
}

.score-row-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 2px;
}

.score-value {
  font-family: var(--mono-font);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent2);
  flex: 0 0 36px;
  text-align: right;
}

.score-placeholder {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 16px 0;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════
   HISTORY / ARCHIVE PANELS
   ═══════════════════════════════════════════════════════════════ */
.history-panel,
.archive-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.history-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.7px;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  line-height: 1.5;
}

.history-item:hover {
  background: var(--surface3);
  border-color: var(--border-light);
}

.history-empty {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 20px 0;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════
   WALLET PANEL
   ═══════════════════════════════════════════════════════════════ */
.wallet-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.wallet-connect-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.wallet-connect-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--primary-font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.wallet-connect-btn:hover {
  background: var(--surface3);
  border-color: var(--accent);
  color: var(--accent);
}

.wallet-address-display {
  font-family: var(--mono-font);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

/* ── Market Ticker ──────────────────────────────────────────── */
.market-ticker {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.ticker-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.ticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}

.ticker-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color 0.2s ease;
}

.ticker-item:hover { border-color: var(--border-light); }

.ticker-symbol {
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
}

.ticker-price {
  font-family: var(--mono-font);
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
}

.ticker-change {
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 600;
}

.ticker-change.up   { color: var(--success); }
.ticker-change.down { color: var(--danger);  }

.ticker-loading {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 8px 0;
}

/* ── Portfolio Panel ────────────────────────────────────────── */
.portfolio-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.portfolio-display {
  font-family: var(--mono-font);
  font-size: 12px;
  color: var(--text);
  line-height: 1.7;
}

/* ── Trade Analysis ─────────────────────────────────────────── */
.trade-analysis-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.trade-analyze-btn,
.execute-trade-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--primary-font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.trade-analyze-btn:hover {
  background: var(--surface3);
  border-color: var(--accent2);
  color: var(--accent2);
}

.execute-trade-btn {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.35);
  color: var(--success);
}

.execute-trade-btn:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--success);
}

.auto-trade-label {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.trade-recommendation {
  margin-top: 12px;
}

.recommendation-display {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
}

/* ── Trade History ──────────────────────────────────────────── */
.trade-history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.trade-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: var(--mono-font);
  color: var(--text-muted);
  gap: 8px;
}

.trade-item .trade-symbol { color: var(--text); font-weight: 600; }
.trade-item .trade-pnl.up   { color: var(--success); }
.trade-item .trade-pnl.down { color: var(--danger); }

/* ═══════════════════════════════════════════════════════════════
   LOGIN GATE
   ═══════════════════════════════════════════════════════════════ */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  font-size: 36px;
  margin-bottom: 12px;
  line-height: 1;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 22px;
  text-align: left;
}

.login-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  display: block;
  margin-bottom: 5px;
}

.login-form input {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--primary-font);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.login-btn {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: var(--primary-font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.35);
}

.login-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.5);
}

.login-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.login-error {
  font-size: 12px;
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  text-align: center;
}

.login-install {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 14px;
  line-height: 1.5;
}

.login-install a {
  color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════════ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 16px;
}

.site-footer a {
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.site-footer a:hover { color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }

  .site-header { padding: 0 16px; }

  .logo-sub { display: none; }

  .header-actions {
    gap: 6px;
  }
}

@media (max-width: 600px) {
  .layout { padding: 12px; gap: 12px; }

  .site-header { height: auto; padding: 10px 16px; }

  .header-inner { flex-wrap: wrap; gap: 8px; }

  .rounds-btns { flex-wrap: wrap; }

  .winner-response { max-height: 160px; }

  .ticker-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
