/* ────────────────────────────────────────────────
   CATGAME – Global Styles
   ──────────────────────────────────────────────── */

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

.hidden {
  display: none !important;
}

:root {
  --accent: #ff7b54;
  --accent-dark: #e85d2f;
  --purple: #7c6fcd;
  --surface: rgba(16, 12, 24, 0.95);
  --surface-2: rgba(28, 22, 42, 0.97);
  --text: #f5ede0;
  --text-muted: #a090838;
  --radius: 18px;
  --shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  --font: 'Outfit', sans-serif;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: #0d0b14;
  color: var(--text);
}

/* ── Portada Canvas ──────────────────────────────── */
#game-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Especial Event Modal (Fase 4) ── */
.event-box {
  text-align: center;
  border-radius: 24px;
  padding: 2.5rem 2rem;
}

.event-good {
  border: 3px solid #4CAF50 !important;
  box-shadow: 0 0 50px rgba(76, 175, 80, 0.4) !important;
}

.event-good h2 {
  color: #4CAF50;
}

.event-bad {
  border: 3px solid #E05C7A !important;
  box-shadow: 0 0 50px rgba(224, 92, 122, 0.4) !important;
}

.event-bad h2 {
  color: #E05C7A;
}

.event-box .modal-icon {
  font-size: 3.5rem;
  margin-bottom: 0.8rem;
  display: block;
}

/* ── Modal overlay ───────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 4, 12, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-box {
  background: var(--surface-2);
  border: 1px solid rgba(255, 123, 84, 0.2);
  border-radius: var(--radius);
  padding: 2.2rem 2rem 1.8rem;
  width: min(460px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow), 0 0 80px rgba(255, 123, 84, 0.08);
  animation: slideUp 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
  from {
    transform: translateY(28px) scale(0.96);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: #998888;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
  background: rgba(255, 123, 84, 0.2);
  color: var(--accent);
}

.modal-icon {
  font-size: 2.2rem;
  text-align: center;
  margin-bottom: 0.4rem;
}

.modal-box h2 {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.3rem;
}

.modal-sub {
  font-size: 0.85rem;
  color: #9a8878;
  text-align: center;
  margin-bottom: 1rem;
  line-height: 1.5;
}

label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #9a8878;
  text-transform: uppercase;
  margin: 0.9rem 0 0.4rem;
}

input[type="text"] {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 123, 84, 0.18);
}

.input-code {
  font-size: 1.5rem !important;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
  font-weight: 700 !important;
}

/* ── Avatar Picker ───────────────────────────────── */
.avatar-picker {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.2rem;
}

.avatar-option {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  background: rgba(255, 255, 255, 0.05);
}

.avatar-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-option:hover {
  transform: scale(1.08);
  border-color: rgba(255, 123, 84, 0.5);
}

.avatar-option.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 123, 84, 0.3);
  transform: scale(1.1);
}

/* ── Primary button ──────────────────────────────── */
.btn-primary {
  margin-top: 1.4rem;
  width: 100%;
  padding: 0.82rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: none;
  border-radius: 12px;
  color: #fff;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  box-shadow: 0 4px 20px rgba(255, 123, 84, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 6px 28px rgba(255, 123, 84, 0.45);
}

.btn-primary:active {
  transform: translateY(0);
}

/* ── Toast ───────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.8rem;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: #1e1520;
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 0.65rem 1.4rem;
  border-radius: 50px;
  font-size: 0.88rem;
  z-index: 999;
  transition: opacity 0.35s, transform 0.35s;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(12px);
}

/* ── Room Screen ─────────────────────────────────── */
.room-screen {
  position: fixed;
  inset: 0;
  background: #0d0b14;
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow: hidden;
}

.room-screen.hidden {
  display: none;
}

/* ── HUD ─────────────────────────────────────────── */
.room-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.2rem;
  background: rgba(20, 15, 32, 0.95);
  border-bottom: 1px solid rgba(255, 123, 84, 0.15);
  flex-shrink: 0;
  gap: 1rem;
  flex-wrap: wrap;
  min-height: 52px;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.room-code-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #6a5a7a;
  text-transform: uppercase;
}

.room-code {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  color: var(--accent);
}

.hud-center {
  font-size: 0.85rem;
  color: #9a8878;
  text-align: center;
  flex: 1;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.role-badge {
  background: rgba(255, 123, 84, 0.12);
  border: 1px solid rgba(255, 123, 84, 0.3);
  color: var(--accent);
  padding: 0.2rem 0.7rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}

.btn-copy {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.btn-copy:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-start {
  background: linear-gradient(135deg, #4caf50, #2e7d32);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.45rem 1.1rem;
  cursor: pointer;
  box-shadow: 0 3px 14px rgba(76, 175, 80, 0.35);
  transition: transform 0.15s, filter 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.btn-start:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow: 0 5px 20px rgba(76, 175, 80, 0.5);
}

.btn-start:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.btn-start.hidden {
  display: none;
}

/* ── Players Bar ─────────────────────────────────── */
.players-bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.5rem 1.2rem;
  background: rgba(14, 11, 22, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.player-slot {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50px;
  padding: 0.25rem 0.7rem 0.25rem 0.3rem;
}

.player-slot img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255, 123, 84, 0.4);
  object-fit: cover;
}

.player-slot span {
  font-size: 0.82rem;
  font-weight: 600;
}

/* ── Countdown Banner ────────────────────────────── */
.countdown-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 300;
  background: rgba(16, 12, 24, 0.92);
  border: 2px solid var(--accent);
  border-radius: 20px;
  padding: 1.2rem 2.4rem;
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 0 60px rgba(255, 123, 84, 0.3);
  animation: pulseIn 0.4s ease;
}

@keyframes pulseIn {
  from {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
  }

  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.countdown-banner.hidden {
  display: none;
}

/* ── Turn Banner ─────────────────────────────────── */
.turn-banner {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: rgba(255, 123, 84, 0.95);
  padding: 0.8rem 2rem;
  border-radius: 50px;
  box-shadow: 0 4px 30px rgba(255, 123, 84, 0.4);
  animation: slideDown 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  min-width: 200px;
}

@keyframes slideDown {
  from {
    transform: translateX(-50%) translateY(-20px);
    opacity: 0;
  }

  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

.turn-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #fff;
}

#turn-text {
  font-weight: 800;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
}

.turn-timer-bg {
  width: 100%;
  height: 4px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.turn-timer-bar {
  width: 100%;
  height: 100%;
  background: #fff;
  transition: width 0.1s linear;
}

/* ── Dice Container ──────────────────────────────── */
.dice-container {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.dice-label {
  background: var(--accent);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 0 4px 15px rgba(255, 123, 84, 0.3);
}

.btn-dice {
  width: 80px;
  height: 80px;
  background: #fff;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), inset 0 -5px 0 #ddd;
  transition: transform 0.1s, box-shadow 0.1s;
  position: relative;
}

.btn-dice:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5), inset 0 -5px 0 #ddd;
}

.btn-dice:active {
  transform: translateY(0);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3), inset 0 -2px 0 #ddd;
}

.dice-result-bubble {
  position: absolute;
  top: -15px;
  right: -15px;
  width: 40px;
  height: 40px;
  background: var(--purple);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 900;
  border: 3px solid #fff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  animation: popIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popIn {
  from {
    transform: scale(0);
  }

  to {
    transform: scale(1);
  }
}

.rolling {
  animation: shake 0.2s infinite;
}

@keyframes shake {
  0% {
    transform: translate(2px, 1px) rotate(0deg);
  }

  10% {
    transform: translate(-1px, -2px) rotate(-1deg);
  }

  20% {
    transform: translate(-3px, 0px) rotate(1deg);
  }

  30% {
    transform: translate(3px, 2px) rotate(0deg);
  }

  40% {
    transform: translate(1px, -1px) rotate(1deg);
  }

  50% {
    transform: translate(-1px, 2px) rotate(-1deg);
  }
}

/* ── Board Container ─────────────────────────────── */
.board-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

#board-canvas {
  display: block;
}