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

:root {
  --bg: #0d0d0d;
  --surface: #1a1a1a;
  --surface-2: #242424;
  --border: #2e2e2e;
  --accent: #f97316;
  --accent-dim: #c2570e;
  --text: #f0f0f0;
  --text-muted: #888;
  --system: #4ade80;
  --chat-bg: #111;
  --radius: 8px;
  --header-h: 56px;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ─── MODAL APODO ─── */
#nickname-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
#nickname-overlay.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 340px;
  text-align: center;
}
.modal-box .logo {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -1px;
  color: var(--accent);
  margin-bottom: 4px;
}
.modal-box .subtitle {
  color: var(--text-muted);
  font-size: .85rem;
  margin-bottom: 28px;
}
.modal-box label {
  display: block;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-align: left;
}
.modal-box input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  margin-bottom: 16px;
  transition: border-color .2s;
}
.modal-box input:focus { border-color: var(--accent); }
.modal-box button {
  width: 100%;
  padding: 11px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.modal-box button:hover { background: var(--accent-dim); }

/* ─── SCORE BAR ─── */
.score-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 38px;
  background: #111820;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  white-space: nowrap;
}
.score-bar::-webkit-scrollbar { display: none; }
.score-bar.hidden { display: none; }

.sb-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  flex-shrink: 0;
}

#sb-matches {
  display: flex;
  gap: 4px;
  align-items: center;
}

.sb-match {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: .78rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.sb-team {
  color: var(--text);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
.sb-team img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  border-radius: 2px;
}

.sb-score {
  font-weight: 800;
  color: #fff;
  font-size: .85rem;
  padding: 0 4px;
}

.sb-vs {
  color: var(--text-muted);
  font-size: .75rem;
  padding: 0 2px;
}

.sb-time {
  color: var(--text-muted);
  font-size: .72rem;
  padding: 0 2px;
}

.sb-live-badge {
  background: #ef4444;
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: .05em;
  animation: pulse 2s infinite;
}

.sb-min {
  color: #ef4444;
  font-size: .72rem;
  font-weight: 600;
}

/* ─── LAYOUT ─── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
}
header .brand {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.5px;
}
header .live-badge {
  background: #ef4444;
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: .1em;
  text-transform: uppercase;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}
header .viewers {
  margin-left: auto;
  font-size: .8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
header .viewers span { color: var(--text); font-weight: 600; }

.main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── PLAYER ─── */
.player-panel {
  flex: 1;
  background: #000;
  display: flex;
  align-items: stretch;
  min-width: 0;
}
.player-panel iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ─── CHAT ─── */
.chat-panel {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  border-left: 1px solid var(--border);
}

.chat-header {
  padding: 12px 16px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}
#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.msg {
  font-size: .875rem;
  line-height: 1.45;
  word-break: break-word;
}
.msg .nick {
  font-weight: 700;
  color: var(--accent);
  margin-right: 5px;
}
.msg .body { color: var(--text); }

.msg-system {
  font-size: .78rem;
  color: var(--system);
  font-style: italic;
  text-align: center;
  padding: 2px 0;
}

/* ─── INPUT ─── */
.chat-input-area {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
#msg-input {
  flex: 1;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: .9rem;
  outline: none;
  transition: border-color .2s;
}
#msg-input:focus { border-color: var(--accent); }
#msg-input::placeholder { color: var(--text-muted); }

#send-btn {
  padding: 9px 14px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  transition: background .15s;
  flex-shrink: 0;
}
#send-btn:hover { background: var(--accent-dim); }

/* ─── EMOJI SHORTCUTS ─── */
.emoji-bar {
  padding: 6px 12px 2px;
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.emoji-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background .15s;
}
.emoji-btn:hover { background: var(--surface); }

/* ─── RESPONSIVO ─── */
@media (max-width: 700px) {
  .main-area { flex-direction: column; }
  .player-panel { height: 45vw; min-height: 200px; flex: none; }
  .chat-panel { width: 100%; border-left: none; border-top: 1px solid var(--border); }
}
