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

:root {
  --bg: #0f1220;
  --bg2: #171b30;
  --card: #1d2240;
  --card-2: #252b52;
  --accent: #7c5cff;
  --accent-2: #00e0a4;
  --danger: #ff4d6d;
  --warn: #ffb020;
  --text: #eef0ff;
  --muted: #9aa0c3;
  --radius: 16px;
}

html, body { height: 100%; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: radial-gradient(1200px 800px at 70% -10%, #2a2f5e 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.screen { display: none; min-height: 100vh; padding: 24px; }
.screen.active { display: flex; align-items: center; justify-content: center; flex-direction: column; }

.btn {
  border: none; border-radius: 12px; cursor: pointer;
  font-size: 1rem; font-weight: 700; padding: 13px 22px;
  color: #fff; transition: transform .12s, filter .15s, opacity .15s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #5a3cf0); box-shadow: 0 6px 22px rgba(124,92,255,.35); }
.btn-secondary { background: var(--card-2); border: 1px solid #3a4180; }
.btn-big { font-size: 1.15rem; padding: 16px 32px; width: 100%; }
.btn-mini { padding: 8px 12px; font-size: .9rem; background: var(--card-2); }

input[type="text"] {
  background: var(--bg2); border: 2px solid #333a6e; border-radius: 12px;
  color: var(--text); font-size: 1.05rem; padding: 13px 16px; outline: none; width: 100%;
  transition: border-color .15s;
}
input[type="text"]:focus { border-color: var(--accent); }
input::placeholder { color: #5a6090; }

.error-msg { color: var(--danger); font-weight: 600; min-height: 1.4em; margin-top: 10px; text-align: center; }
.hint { color: var(--muted); text-align: center; margin-top: 12px; font-size: .92rem; min-height: 1.3em; }

/* ===== HOME ===== */
.home-card {
  background: var(--card); border-radius: var(--radius); padding: 36px 34px;
  width: min(460px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.45);
  display: flex; flex-direction: column; gap: 16px;
}
.logo { font-size: 2.4rem; text-align: center; letter-spacing: -1px; }
.logo span { color: var(--accent-2); }
.tagline { text-align: center; color: var(--muted); margin-top: -8px; }
.home-actions { display: flex; flex-direction: column; gap: 12px; }
.join-row { display: flex; gap: 10px; }
.join-row input { text-transform: uppercase; letter-spacing: 4px; font-weight: 700; text-align: center; }
.join-row .btn { flex-shrink: 0; }

.pub-toggle {
  display: flex; align-items: center; gap: 8px; color: var(--muted);
  font-size: .88rem; cursor: pointer; user-select: none; padding: 0 4px;
}
.pub-toggle input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

/* ===== SALAS PÚBLICAS ===== */
.pubrooms { background: var(--bg2); border-radius: 12px; padding: 14px 16px; }
.pub-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.pub-head h3 { flex: 1; font-size: 1rem; color: var(--accent-2); }
.pub-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.pub-empty { color: var(--muted); font-size: .88rem; text-align: center; padding: 8px 0; }
.pub-item {
  display: flex; align-items: center; gap: 10px; background: var(--card-2);
  border-radius: 10px; padding: 9px 12px; font-size: .9rem;
}
.pub-item .av { font-size: 1.3rem; }
.pub-item .info { flex: 1; min-width: 0; }
.pub-item .info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pub-item .info small { color: var(--muted); }
.pub-item .btn { flex-shrink: 0; }

.rules { background: var(--bg2); border-radius: 12px; padding: 16px 20px; }
.rules h3 { margin-bottom: 8px; font-size: 1rem; color: var(--accent-2); }
.rules ul { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: .92rem; color: var(--muted); }

/* ===== LOBBY ===== */
.lobby-card {
  background: var(--card); border-radius: var(--radius); padding: 34px;
  width: min(520px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.45);
  display: flex; flex-direction: column; gap: 20px; text-align: center;
}
.code-box { background: var(--bg2); border-radius: 12px; padding: 16px; }
.code-box > span { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: 2px; }
.code-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 6px 0; }
.code-row strong {
  font-size: 2.2rem; letter-spacing: 10px; color: var(--accent-2);
  font-family: 'Consolas', monospace;
}
.code-box small { color: var(--muted); }

/* Opções de modo e tema */
.options { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.opt-group { background: var(--bg2); border-radius: 12px; padding: 12px 14px; }
.opt-label { display: block; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--card-2); border: 2px solid transparent; border-radius: 999px;
  color: var(--text); cursor: pointer; font-size: .88rem; font-weight: 700;
  padding: 7px 14px; transition: border-color .15s, transform .12s, opacity .15s;
}
.chip:hover:not(:disabled) { transform: translateY(-1px); }
.chip.active { border-color: var(--accent-2); background: #1b3b38; }
.chip:disabled { cursor: default; opacity: .55; }
.chip:disabled.active { opacity: 1; }
.opt-desc { color: var(--muted); font-size: .82rem; margin-top: 8px; min-height: 1.2em; }

.match-badge {
  background: var(--bg2); border-radius: 999px; padding: 5px 12px;
  font-size: .8rem; font-weight: 700; color: var(--muted); white-space: nowrap;
}
.match-badge:empty { display: none; }

.lobby-players { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.lobby-player {
  background: var(--card-2); border-radius: 12px; padding: 14px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  animation: pop .25s ease;
}
.lobby-player .av { font-size: 2rem; }
.lobby-player .nm { font-weight: 700; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }
.lobby-player .tag { font-size: .72rem; color: var(--warn); }
.lobby-player.empty { opacity: .3; border: 2px dashed #3a4180; background: transparent; }
.lobby-player.empty .av { filter: grayscale(1); }

@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ===== JOGO ===== */
#screen-game.active { justify-content: flex-start; padding-top: 32px; }
.game-layout { display: flex; gap: 22px; width: min(1050px, 96vw); align-items: flex-start; }

.players-panel { width: 230px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }
.player-card {
  background: var(--card); border-radius: 12px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px; border: 2px solid transparent;
  transition: opacity .3s, border-color .2s;
}
.player-card.me { border-color: var(--accent); }
.player-card.dead { opacity: .38; filter: grayscale(.8); }
.player-card .row1 { display: flex; align-items: center; gap: 8px; }
.player-card .av { font-size: 1.4rem; }
.player-card .nm { font-weight: 700; font-size: .92rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-card .st { font-size: 1rem; }
.player-card .row2 { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; }
.player-card .hearts { letter-spacing: 2px; }
.player-card .sc { color: var(--accent-2); font-weight: 700; font-family: 'Consolas', monospace; }
.pbar-track { height: 5px; background: var(--bg2); border-radius: 4px; overflow: hidden; }
.pbar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 4px; transition: width .18s linear; }

.game-main {
  flex: 1; background: var(--card); border-radius: var(--radius); padding: 28px;
  display: flex; flex-direction: column; gap: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
  min-height: 340px; position: relative;
}
.game-top { display: flex; align-items: center; gap: 14px; }
.round-label { font-weight: 800; color: var(--warn); white-space: nowrap; }
.timer-track { flex: 1; height: 10px; background: var(--bg2); border-radius: 6px; overflow: hidden; }
.timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 6px; }
.timer-bar.low { background: var(--danger); }
.timer-label { font-family: 'Consolas', monospace; font-weight: 700; min-width: 52px; text-align: right; }

.countdown {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 7rem; font-weight: 900; color: var(--accent-2);
  background: rgba(15,18,32,.82); border-radius: var(--radius); z-index: 5;
  animation: pop .3s ease;
}

.word-box {
  min-height: 110px; display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 2px; background: var(--bg2); border-radius: 12px; padding: 22px;
  font-family: 'Consolas', 'Courier New', monospace; font-size: 1.9rem; font-weight: 700;
  line-height: 1.5;
}
.word-box .ch { padding: 1px 1px; border-radius: 4px; color: #6a7099; white-space: pre; }
.word-box .ch.ok { color: var(--accent-2); }
.word-box .ch.bad { color: #fff; background: var(--danger); }
.word-box .ch.cur { border-bottom: 3px solid var(--accent); color: var(--text); animation: blink 1s infinite; }
@keyframes blink { 50% { border-color: transparent; } }

#input-typing { font-size: 1.3rem; font-family: 'Consolas', monospace; text-align: center; }
#input-typing.shake { animation: shake .35s; border-color: var(--danger); }
@keyframes shake {
  0%,100% { transform: translateX(0); } 20% { transform: translateX(-9px); }
  40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); }
}

.game-status { text-align: center; font-weight: 700; min-height: 1.5em; font-size: 1.05rem; }
.game-status.good { color: var(--accent-2); }
.game-status.bad { color: var(--danger); }

/* Feed de acontecimentos */
.feed {
  position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column-reverse;
  gap: 8px; z-index: 40; max-width: 320px;
}
.feed-item {
  background: var(--card-2); border-left: 4px solid var(--accent); border-radius: 10px;
  padding: 10px 14px; font-size: .88rem; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: slideIn .3s ease;
}
.feed-item.good { border-color: var(--accent-2); }
.feed-item.bad { border-color: var(--danger); }
@keyframes slideIn { from { transform: translateX(120%); } to { transform: translateX(0); } }

/* ===== OVERLAY DE EVENTO ===== */
.event-overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(10,12,24,.9); animation: fadeIn .25s ease;
}
.event-overlay.hidden { display: none; }
.event-content { text-align: center; animation: pop .4s cubic-bezier(.2,1.6,.4,1); }
.event-emoji { font-size: 7rem; animation: wobble 1s infinite; }
.event-text { font-size: 1.7rem; font-weight: 800; margin-top: 18px; max-width: 640px; padding: 0 20px; }
.event-text b { color: var(--danger); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes wobble {
  0%,100% { transform: rotate(-8deg) scale(1); } 50% { transform: rotate(8deg) scale(1.12); }
}

/* ===== FIM DE JOGO ===== */
.over-card {
  background: var(--card); border-radius: var(--radius); padding: 36px;
  width: min(500px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.45);
  display: flex; flex-direction: column; gap: 20px; text-align: center;
}
.winner-box { font-size: 1.25rem; font-weight: 700; }
.winner-box .big { font-size: 4rem; display: block; margin-bottom: 8px; animation: wobble 1.4s infinite; }
.winner-box .wname { color: var(--warn); }
.standings { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.standings li {
  background: var(--bg2); border-radius: 10px; padding: 11px 16px;
  display: flex; align-items: center; gap: 10px; font-weight: 600;
}
.standings li .pos { color: var(--muted); font-family: 'Consolas', monospace; width: 2em; }
.standings li .nm { flex: 1; text-align: left; }
.standings li .pts { color: var(--accent-2); font-family: 'Consolas', monospace; }
.standings li.first { background: linear-gradient(135deg, #3d3410, #4d420f); border: 1px solid var(--warn); }
.standings .li-stats { display: block; color: var(--muted); font-size: .74rem; font-weight: 500; }

.hidden { display: none !important; }

/* ===== RECONEXÃO ===== */
.reconnect {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: var(--warn); color: #201500; font-weight: 800; font-size: .95rem;
  padding: 10px 22px; border-radius: 999px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  animation: pulse 1.2s infinite;
}
@keyframes pulse { 50% { opacity: .65; } }

/* ===== RODADAS ESPECIAIS ===== */
.special-banner {
  position: absolute; inset: 0; z-index: 6; border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: rgba(15,18,32,.88); text-align: center; padding: 20px;
  animation: pop .3s cubic-bezier(.2,1.6,.4,1);
}
.special-banner .sp-title { font-size: 2rem; font-weight: 900; color: var(--warn); }
.special-banner .sp-desc { color: var(--text); font-size: 1.05rem; }

.word-box.blurred .ch { filter: blur(7px); }
.word-box.masked .ch { color: var(--muted); }

/* ===== POWER-UPS ===== */
.item-bar { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; min-height: 40px; }
.item-bar:empty { display: none; }
.item-btn {
  background: linear-gradient(135deg, #3d3410, #55430e); border: 1px solid var(--warn);
  border-radius: 999px; color: var(--text); cursor: pointer; font-weight: 700;
  padding: 8px 16px; font-size: .92rem; transition: transform .12s;
  animation: pop .3s ease;
}
.item-btn:hover { transform: translateY(-2px); }
.item-btn.passive { cursor: default; border-color: var(--accent-2); background: #14342e; }
.item-target {
  background: var(--card-2); border: 1px solid #3a4180; border-radius: 999px;
  color: var(--text); cursor: pointer; font-weight: 700; padding: 7px 13px; font-size: .88rem;
}
.item-target:hover { border-color: var(--danger); }
.item-cancel { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: .85rem; }

/* ===== REAÇÕES ===== */
.reactions {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 45;
  display: flex; gap: 6px; background: var(--card); border: 1px solid #2b3160;
  border-radius: 999px; padding: 6px 10px; box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.reactions button {
  background: transparent; border: none; font-size: 1.35rem; cursor: pointer;
  transition: transform .12s; line-height: 1; padding: 4px;
}
.reactions button:hover { transform: scale(1.35); }
.float-emoji {
  position: fixed; z-index: 60; font-size: 1.8rem; pointer-events: none;
  animation: floatUp 1.6s ease-out forwards;
}
@keyframes floatUp {
  0% { transform: translateY(0) scale(.7); opacity: 0; }
  15% { opacity: 1; transform: translateY(-12px) scale(1.15); }
  100% { transform: translateY(-90px) scale(1); opacity: 0; }
}

/* ===== STATUS DO JOGADOR (cartões) ===== */
.player-card.off { opacity: .5; }
.player-card .item-ico { font-size: .95rem; }
.player-card .wpm { color: var(--warn); font-size: .78rem; font-family: 'Consolas', monospace; }

/* ===== ESPECTADORES ===== */
.spectators-line { color: var(--muted); font-size: .85rem; text-align: center; }

/* ===== RANKING GERAL ===== */
.ranking-box { background: var(--bg2); border-radius: 12px; padding: 14px 18px; text-align: left; }
.ranking-box h3 { font-size: .95rem; color: var(--warn); margin-bottom: 8px; text-align: center; }
.ranking-list { list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: .88rem; }
.ranking-list li { display: flex; gap: 8px; align-items: center; }
.ranking-list li .pos { color: var(--muted); font-family: 'Consolas', monospace; width: 1.8em; }
.ranking-list li .nm { flex: 1; }
.ranking-list li .st { color: var(--muted); font-family: 'Consolas', monospace; font-size: .8rem; }

/* ===== CHAT ===== */
.chat {
  position: fixed; bottom: 18px; left: 18px; width: 290px; z-index: 50;
  background: var(--card); border-radius: 14px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,.5); border: 1px solid #2b3160;
  display: flex; flex-direction: column;
}
.chat-head {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 10px 14px; background: var(--card-2); font-weight: 700; font-size: .92rem;
  user-select: none;
}
.chat-title { flex: 1; }
.chat-caret { transition: transform .2s; color: var(--muted); }
.chat.collapsed .chat-caret { transform: rotate(180deg); }
.chat-unread {
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: .72rem; font-weight: 800; padding: 2px 8px;
}
.chat-body { display: flex; flex-direction: column; }
.chat.collapsed .chat-body { display: none; }
.chat-msgs {
  height: 190px; overflow-y: auto; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px; font-size: .86rem;
}
.chat-msg { line-height: 1.35; word-break: break-word; animation: pop .15s ease; }
.chat-msg b { color: var(--muted); font-weight: 700; }
.chat-msg.mine b { color: var(--accent-2); }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #2b3160; }
.chat-form input[type="text"] {
  flex: 1; padding: 8px 12px; font-size: .88rem; border-radius: 10px; border-width: 1px;
}
.chat-form .btn { padding: 8px 12px; }

@media (max-width: 760px) {
  .chat { width: calc(100vw - 36px); max-width: 340px; }
  .chat-msgs { height: 140px; }
}

/* ===== UNIVERSO 3D ===== */
#bg3d {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  z-index: 0; display: none; pointer-events: none;
}
.screen, .feed, .event-overlay { position: relative; z-index: 1; }
.event-overlay, .feed { position: fixed; }

body.mode3d #screen-game .game-main {
  background: rgba(23, 27, 48, .78);
  backdrop-filter: blur(8px);
}
body.mode3d #screen-game .players-panel { display: none; }
body.mode3d #screen-game .word-box { background: rgba(15, 18, 32, .72); }
body.mode3d .over-card { background: rgba(29, 34, 64, .85); backdrop-filter: blur(8px); }

/* ===== TEXTO CORRIDO ===== */
.word-box.long { font-size: 1.25rem; line-height: 1.7; justify-content: flex-start; text-align: left; }

/* ===== RESPONSIVO ===== */
@media (max-width: 760px) {
  .game-layout { flex-direction: column-reverse; }
  .players-panel { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .player-card { flex: 1 1 140px; }
  .word-box { font-size: 1.3rem; padding: 16px; min-height: 80px; }
  .event-emoji { font-size: 4.5rem; }
  .event-text { font-size: 1.2rem; }
}
