/* ============================================================
   PARCHIS ONLINE - ESTILOS v2 (LANDSCAPE-FIRST)
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #0f3460;
  --gold: #FFD700;
  --text: #EAEAEA;
  --text-muted: #8892b0;
  --yellow: #FFD700;
  --blue: #1E90FF;
  --red: #DC143C;
  --green: #228B22;
  --success: #4CAF50;
  --warning: #FF9800;
  --error: #f44336;
}

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

/* ============================
   FORZAR LANDSCAPE
   ============================ */

/* Overlay que aparece cuando el móvil está en vertical */
#rotate-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--bg-dark);
  z-index: 99999;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 20px;
}
#rotate-overlay .rotate-icon {
  font-size: 4em;
  animation: rotate-phone 2s ease-in-out infinite;
}
#rotate-overlay p {
  color: var(--text-muted);
  font-size: 1.2em;
  text-align: center;
  padding: 0 30px;
}

@keyframes rotate-phone {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-90deg); }
  75% { transform: rotate(-90deg); }
}

/* En portrait (vertical) en móviles, mostrar overlay */
@media (orientation: portrait) and (max-width: 900px) {
  #rotate-overlay { display: flex !important; }
}

/* ============================
   PANTALLAS BASE
   ============================ */
.screen {
  display: none;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  flex-direction: column;
  overflow-y: auto;
}
.screen.active { display: flex; }

/* ============================
   SPLASH
   ============================ */
#screen-splash {
  justify-content: center;
  align-items: center;
  background: radial-gradient(ellipse at center, #16213e 0%, #1a1a2e 100%);
}
.splash-title {
  font-size: 3em;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold), #ff8c00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
  margin-bottom: 20px;
}
.splash-subtitle { color: var(--text-muted); font-size: 1.1em; }
.loader {
  width: 200px; height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  margin-top: 30px;
  overflow: hidden;
}
.loader-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #ff8c00);
  animation: loading 2s ease-in-out;
}
@keyframes loading { from { width: 0; } to { width: 100%; } }

/* ============================
   LOGIN
   ============================ */
#screen-login {
  justify-content: center;
  align-items: center;
  flex-direction: row;
  padding: 20px;
}
.login-card {
  background: var(--bg-card);
  padding: 30px 40px;
  border-radius: 20px;
  max-width: 450px;
  width: 100%;
  text-align: center;
}
.login-card h2 { margin-bottom: 15px; color: var(--gold); }
.login-card input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--bg-input);
  border-radius: 10px;
  background: var(--bg-dark);
  color: var(--text);
  font-size: 1.1em;
  margin-bottom: 12px;
  outline: none;
}
.login-card input:focus { border-color: var(--gold); }

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.avatar-option {
  font-size: 1.8em;
  padding: 8px;
  border-radius: 12px;
  background: var(--bg-dark);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
}
.avatar-option.selected { border-color: var(--gold); background: var(--bg-input); }
.avatar-option:hover { transform: scale(1.1); }

/* ============================
   BOTONES
   ============================ */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: #000;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn-primary { background: linear-gradient(135deg, var(--gold), #ff8c00); color: #000; }
.btn-secondary { background: var(--bg-input); color: var(--text); }
.btn-danger { background: var(--error); color: #fff; }
.btn-block { width: 100%; }
.btn-large { font-size: 1.15em; padding: 16px 28px; }
.btn-small { padding: 8px 14px; font-size: 0.9em; }
.btn-icon {
  background: var(--bg-card);
  border: none;
  font-size: 1.4em;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-icon:hover { background: var(--bg-input); transform: scale(1.1); }

/* ============================
   MENU PRINCIPAL (landscape: centrado horizontalmente)
   ============================ */
#screen-menu {
  align-items: center;
  justify-content: center;
  flex-direction: row;
  gap: 40px;
  padding: 20px 40px;
  background: radial-gradient(ellipse at top, #16213e 0%, #1a1a2e 100%);
}
.menu-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 20px;
  background: var(--bg-card);
  border-radius: 16px;
  width: 100%;
  max-width: 350px;
}
.menu-avatar { font-size: 2.2em; }
.menu-info { flex: 1; }
.menu-name { font-size: 1.1em; font-weight: 600; }
.menu-stars { color: var(--gold); font-weight: 700; font-size: 1em; }
.menu-rank { font-size: 0.85em; }

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 350px;
}
.menu-buttons .btn { font-size: 1.1em; padding: 16px; }

.menu-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ============================
   SELECCION DE TABLERO (landscape: row de cards)
   ============================ */
.boards-grid, #boards-list {
  display: flex;
  flex-direction: row;
  gap: 15px;
  padding: 15px 20px;
  overflow-x: auto;
  align-items: stretch;
  flex: 1;
}
.board-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 18px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  min-width: 220px;
  max-width: 280px;
  flex-shrink: 0;
}
.board-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.board-card.locked { opacity: 0.5; cursor: not-allowed; }
.board-card.poor { opacity: 0.7; }
.board-preview {
  height: 70px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2em;
  margin-bottom: 8px;
  background: var(--bg-dark);
}
.board-card h3 { color: var(--gold); margin-bottom: 4px; font-size: 1em; }
.board-bet { color: var(--gold); font-weight: 700; margin-top: 4px; font-size: 0.95em; }
.board-lock { color: var(--error); font-size: 0.8em; margin-top: 4px; }

/* ============================
   MODO DE JUEGO (landscape: 4 cards en fila)
   ============================ */
.mode-grid {
  display: flex;
  gap: 12px;
  padding: 20px;
  justify-content: center;
  align-items: stretch;
  flex-wrap: wrap;
  flex: 1;
}
.mode-card {
  background: var(--bg-card);
  padding: 20px 18px;
  border-radius: 14px;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  min-width: 140px;
  max-width: 180px;
}
.mode-card:hover { border-color: var(--gold); }
.mode-card .mode-icon { font-size: 1.8em; margin-bottom: 6px; }
.mode-card h3 { color: var(--gold); margin: 4px 0; font-size: 1em; }
.mode-card p { color: var(--text-muted); font-size: 0.85em; }
.mode-teams { border-color: var(--blue); }

/* ============================
   PRE-MATCH, JOIN, MATCHMAKING
   ============================ */
.pre-match-card {
  max-width: 400px;
  margin: auto;
  padding: 25px;
  background: var(--bg-card);
  border-radius: 16px;
}
.pre-match-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg-input);
  font-size: 1em;
}
.pre-match-row:last-of-type { border: none; }
.pre-match-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.join-card {
  max-width: 400px;
  margin: auto;
  padding: 30px;
  background: var(--bg-card);
  border-radius: 16px;
  text-align: center;
}
.join-card input {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--bg-input);
  border-radius: 10px;
  background: var(--bg-dark);
  color: var(--text);
  margin: 15px 0;
  outline: none;
}
.join-card input:focus { border-color: var(--gold); }

.matchmaking-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 20px;
}
.matchmaking-content h2 { color: var(--gold); }
.matchmaking-spinner {
  width: 50px; height: 50px;
  border: 4px solid var(--bg-input);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ============================
   SALA DE ESPERA (landscape: centrado)
   ============================ */
.waiting-players-grid {
  padding: 10px 20px;
  display: flex;
  flex-direction: row;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.waiting-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: 12px;
  min-width: 180px;
}
.waiting-slot.empty { opacity: 0.4; }
.slot-color { width: 20px; height: 20px; border-radius: 50%; display: inline-block; }
.slot-name { flex: 1; font-weight: 600; font-size: 0.95em; }
.slot-status { font-size: 1.1em; }
.slot-empty { color: var(--text-muted); font-style: italic; font-size: 0.9em; }

.room-code-box {
  text-align: center;
  padding: 12px;
  background: var(--bg-card);
  border-radius: 12px;
  margin: 10px auto;
  max-width: 350px;
}
.room-code {
  font-size: 1.8em;
  font-weight: 900;
  letter-spacing: 5px;
  color: var(--gold);
}
.waiting-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 15px;
}

/* ============================
   PANTALLA DE JUEGO - FULLSCREEN BOARD
   Tablero ~90% pantalla, controles flotantes mínimos
   ============================ */
#screen-game {
  padding: 0;
  overflow: hidden;
  position: relative;
  background: #0a0a18;
}

/* --- TABLERO: fullscreen centrado --- */
.game-fullboard {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.game-fullboard canvas {
  /* Cuadrado que ocupa toda la altura */
  height: 100vh;
  width: 100vh;
  max-width: 100vw;
  display: block;
}

/* --- HUD TOP: turno, semitransparente centrado arriba --- */
.game-hud-top {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(22, 33, 62, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 5px 20px;
  border-radius: 20px;
  pointer-events: none;
}
.hud-turn {
  font-weight: 700;
  font-size: 1em;
  white-space: nowrap;
}

/* --- HUD DICE: esquina inferior izquierda --- */
.game-hud-dice {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(22, 33, 62, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 6px 10px;
  border-radius: 14px;
}
.hud-dice-box {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(15, 52, 96, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.hud-dice-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.hud-dice-btn {
  padding: 10px 16px;
  font-size: 1.3em;
  border-radius: 10px;
  min-width: 50px;
}
.dice-rolling { animation: shake 0.08s infinite; }
@keyframes shake {
  0% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}
.dice-landed { animation: pop 0.3s ease; }
@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* --- HUD RIGHT: columna de iconos, borde derecho --- */
.game-hud-right {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hud-icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(22, 33, 62, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 1.2em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  color: var(--text);
}
.hud-icon-btn:hover { background: rgba(15, 52, 96, 0.95); transform: scale(1.12); }
.hud-icon-btn.hud-exit { color: var(--error); }
.hud-icon-btn.mic-off { background: rgba(244, 67, 54, 0.7); }

/* --- EMOJI TRAY: flotante junto a los iconos --- */
.game-emoji-tray {
  position: absolute;
  right: 58px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;
  display: none;
  flex-direction: column;
  gap: 4px;
  background: rgba(22, 33, 62, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 8px 6px;
  border-radius: 14px;
}
.game-emoji-tray.open { display: flex; }
.game-emoji-tray .emoji-btn {
  font-size: 1.3em;
  background: transparent;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.12s;
}
.game-emoji-tray .emoji-btn:hover { background: rgba(255,255,255,0.1); transform: scale(1.2); }

/* --- CHAT FLOAT: panel inferior, oculto por defecto --- */
.game-chat-float {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: none;
  flex-direction: column;
  width: 340px;
  max-width: 50vw;
  background: rgba(22, 33, 62, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 10px;
}
.game-chat-float.open { display: flex; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  max-height: 100px;
  padding: 6px;
  background: rgba(10, 10, 24, 0.6);
  border-radius: 8px;
  font-size: 0.82em;
  margin-bottom: 6px;
}
.chat-msg { margin-bottom: 3px; }
.chat-input-row {
  display: flex;
  gap: 6px;
}
.chat-input-row input {
  flex: 1;
  padding: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: rgba(10, 10, 24, 0.7);
  color: var(--text);
  font-size: 0.85em;
  outline: none;
}
.chat-input-row input:focus { border-color: var(--gold); }

/* Floating emojis animados */
#emoji-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 100;
}
.floating-emoji {
  position: absolute;
  font-size: 3em;
  top: 50%; left: 50%;
  animation: float-up 2s ease forwards;
}
@keyframes float-up {
  0% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -200px) scale(2); }
}

/* --- RESPONSIVE JUEGO pantallas pequeñas --- */
@media (max-height: 380px) {
  .hud-dice-box { width: 40px; height: 40px; }
  .hud-dice-btn { padding: 8px 12px; font-size: 1.1em; }
  .hud-icon-btn { width: 36px; height: 36px; font-size: 1em; }
  .hud-turn { font-size: 0.85em; }
  .game-emoji-tray .emoji-btn { font-size: 1.1em; padding: 3px 6px; }
  .game-chat-float { width: 280px; }
}
@media (min-height: 500px) and (min-width: 900px) {
  .hud-dice-box { width: 64px; height: 64px; }
  .hud-dice-btn { padding: 12px 20px; font-size: 1.5em; }
  .hud-icon-btn { width: 48px; height: 48px; font-size: 1.4em; }
}

/* ============================
   RESULTADO
   ============================ */
#screen-result {
  justify-content: center;
  align-items: center;
  flex-direction: row;
  gap: 40px;
}
.result-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.result-icon { font-size: 4em; margin-bottom: 12px; }
.result-content h2 { font-size: 1.8em; margin-bottom: 12px; }
.result-content p { font-size: 1em; margin-bottom: 6px; }
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 300px;
  width: 100%;
}

/* ============================
   PERFIL (landscape: centrado)
   ============================ */
#screen-profile {
  padding: 20px;
  align-items: center;
  justify-content: center;
}
.profile-card {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 25px;
  max-width: 450px;
  width: 100%;
  text-align: center;
}
.profile-avatar-big { font-size: 3em; margin-bottom: 10px; }
.profile-rank-badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 20px;
  background: var(--bg-input);
  margin: 8px 0 15px;
  font-weight: 600;
  font-size: 0.95em;
}
.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.stat-box {
  background: var(--bg-dark);
  padding: 12px 8px;
  border-radius: 12px;
  text-align: center;
}
.stat-value { display: block; font-size: 1.2em; font-weight: 700; color: var(--gold); }
.stat-label { display: block; font-size: 0.75em; color: var(--text-muted); margin-top: 3px; }

/* ============================
   SKINS
   ============================ */
.skins-content {
  padding: 20px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}
.skins-content h3 { color: var(--gold); margin: 12px 0 8px; }
.skins-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.skin-card {
  background: var(--bg-card);
  padding: 16px 10px;
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
}
.skin-card.selected { border-color: var(--gold); background: var(--bg-input); }
.skin-card:hover { border-color: var(--gold); }
.skin-icon { font-size: 1.8em; margin-bottom: 6px; }
.skin-price { display: block; color: var(--success); font-size: 0.82em; margin-top: 3px; }

/* ============================
   AJUSTES
   ============================ */
#screen-settings {
  padding: 20px;
  align-items: center;
  justify-content: center;
}
.settings-content {
  padding: 20px;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
  background: var(--bg-card);
  border-radius: 16px;
}
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--bg-input);
}
.settings-info {
  padding: 15px 0 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85em;
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-input);
  border-radius: 24px;
  transition: 0.3s;
}
.toggle-slider:before {
  content: "";
  position: absolute;
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider:before { transform: translateX(22px); }

/* ============================
   AMIGOS
   ============================ */
.friends-content {
  padding: 20px;
  max-width: 500px;
  margin: 0 auto;
}

/* ============================
   HEADER GENÉRICO
   ============================ */
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg-card);
  width: 100%;
  flex-shrink: 0;
}
.screen-header h2 { flex: 1; color: var(--gold); font-size: 1.1em; }
.header-stars { color: var(--gold); font-weight: 700; font-size: 0.95em; }
.btn-back {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4em;
  cursor: pointer;
}

/* ============================
   TOAST
   ============================ */
#toast-container {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.toast {
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.9em;
  font-weight: 500;
  opacity: 0;
  transform: translateX(100px);
  transition: all 0.3s ease;
  max-width: 280px;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-info { background: var(--blue); color: #fff; }
.toast-success { background: var(--success); color: #fff; }
.toast-warning { background: var(--warning); color: #000; }
.toast-error { background: var(--error); color: #fff; }

/* ============================
   UTILIDADES
   ============================ */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
/* Fin de estilos */
