/* =============================================================================
   style.css – Dark minimalist design for "EINS"
   ============================================================================= */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-dark: #121212;
  --bg-card: #1a1a1a;
  --bg-surface: #222;
  --bg-hover: #2a2a2a;
  --border: #333;
  --text-primary: #e0e0e0;
  --text-secondary: #888;
  --text-muted: #555;
  --accent: #fff;
  --accent-dim: #aaa;
  --blue: #2979ff;
  --green: #00c853;
  --yellow: #ffd600;
  --red: #ff1744;
  --gold: #ffd700;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
  --glow-active: 0 0 12px rgba(255, 255, 255, 0.5);
  --glow-red: 0 0 18px rgba(255, 23, 68, 0.7);
  --radius: 8px;
  --transition: 0.2s ease;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
  user-select: none;
}

/* Prevent image dragging globally */
img {
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: auto;
}

/* ===================== SCREENS ===================== */

.screen {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
}

/* ===================== LOGIN ===================== */

#login-screen {
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.logo {
  font-size: 5rem;
  font-weight: 800;
  letter-spacing: 0.3em;
  margin-left: 0.3em;
  margin-bottom: 0.2em;
  color: #fff;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 2.5em;
  font-weight: 300;
}

.login-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1em;
}

input[type="text"] {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.7em 1.2em;
  font-size: 1rem;
  border-radius: var(--radius);
  outline: none;
  text-align: center;
  transition: border-color var(--transition);
  width: 220px;
}

input[type="text"]:focus {
  border-color: var(--accent-dim);
}

input[type="text"]::placeholder {
  color: var(--text-muted);
}

.error-msg {
  color: var(--red);
  font-size: 0.85rem;
  min-height: 1.2em;
}

/* ===================== BUTTONS ===================== */

.btn {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 0.6em 1.5em;
  font-size: 0.95rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-dim);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #fff;
  color: #111;
  border-color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: #ddd;
  border-color: #ddd;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg-hover);
}

.btn-large {
  font-size: 1.1rem;
  padding: 0.8em 2em;
}

.btn-small {
  font-size: 0.85rem;
  padding: 0.4em 0.8em;
}

/* Pass button – removed, auto-pass is used */

/* ===================== TOPBAR ===================== */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.2em;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1em;
}

.logo-small {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}

.topbar-credits {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 300;
}

.username-display {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===================== LOBBY ===================== */

#lobby-screen {
  flex-direction: column;
}

.lobby-content {
  display: flex;
  flex: 1;
  margin-top: 50px;
}

.lobby-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lobby-sidebar {
  width: 320px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  padding: 1.5em;
  overflow-y: auto;
}

.lobby-sidebar h3 {
  font-weight: 400;
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 1em;
  letter-spacing: 0.05em;
}

.room-list {
  list-style: none;
}

.room-list li {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8em 1em;
  margin-bottom: 0.5em;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.room-list li:hover {
  background: var(--bg-hover);
  border-color: var(--accent-dim);
}

.room-host {
  font-weight: 500;
  font-size: 0.95rem;
}

.room-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.room-pin-icon {
  font-size: 0.75rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===================== ROOM ===================== */

#room-screen {
  flex-direction: column;
}

.waiting-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 50px;
  gap: 1em;
}

.waiting-area h2 {
  font-weight: 300;
  font-size: 1.5rem;
  color: var(--text-secondary);
}

.room-url {
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: color var(--transition);
}

.room-url:hover {
  color: var(--text-primary);
}

/* ===================== GAME AREA ===================== */

.game-area {
  flex: 1;
  margin-top: 50px;
  margin-right: 220px;
  position: relative;
  overflow: hidden;
}

.table-center {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -60%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3em;
}

.pile-group {
  display: flex;
  gap: 1.5em;
  align-items: center;
}

.card-slot {
  position: relative;
}

/* Center stacks: bigger */
.card-img {
  width: 130px;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

.draw-pile {
  cursor: pointer;
  transition: transform var(--transition), filter 0.3s ease;
}

.draw-pile:hover {
  transform: scale(1.05);
}

.draw-pile.glow-red {
  animation: pulseRed 1.2s ease-in-out infinite;
}

.draw-pile.glow-red .card-img {
  box-shadow: 0 0 12px 3px rgba(255, 23, 68, 0.6), 0 0 28px 6px rgba(255, 23, 68, 0.35), inset 0 0 6px rgba(255, 23, 68, 0.2);
  border: 2px solid rgba(255, 23, 68, 0.8);
  animation: pulseRedBorder 1.2s ease-in-out infinite;
}

@keyframes pulseRed {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(255, 23, 68, 0.4)); }
  50% { filter: drop-shadow(0 0 20px rgba(255, 23, 68, 0.85)); }
}

@keyframes pulseRedBorder {
  0%, 100% { border-color: rgba(255, 23, 68, 0.5); box-shadow: 0 0 10px 2px rgba(255, 23, 68, 0.4); }
  50% { border-color: rgba(255, 23, 68, 1); box-shadow: 0 0 22px 6px rgba(255, 23, 68, 0.7); }
}

.penalty-badge {
  position: absolute;
  top: -14px;
  right: -14px;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0.2em 0.55em;
  border-radius: 20px;
  min-width: 30px;
  text-align: center;
}

.direction-indicator {
  font-size: 2.5rem;
  color: var(--text-muted);
  transition: transform 0.4s ease;
  margin-top: -0.3em;
}

.direction-indicator.reverse {
  transform: scaleX(-1);
}

/* ===================== OTHER PLAYERS (SEMICIRCLE) ===================== */

.other-players {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  pointer-events: none;
}

.other-player {
  position: absolute;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateX(-50%);
  gap: 0.25em;
}

.other-player-name {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: transform 0.5s cubic-bezier(0.25, 0.8, 0.25, 1), color 0.5s ease, text-shadow 0.5s ease;
  transform: scale(1);
}

.other-player.active-turn .other-player-name {
  color: #fff;
  text-shadow: var(--glow-active);
  animation: pulseName 2.5s ease-in-out infinite;
}

@keyframes pulseName {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.other-player-cards {
  display: flex;
  position: relative;
  transition: transform 0.5s cubic-bezier(0.25, 0.8, 0.25, 1), filter 0.5s ease;
  transform: scale(1);
}

.other-player.active-turn .other-player-cards {
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.4)) brightness(1.2);
}

.other-player-cards .mini-card {
  height: auto;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  position: absolute;
  top: 0;
}

.other-player-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 4px;
}

.other-player .place-crown {
  font-size: 1rem;
}

/* ===================== MY HAND ===================== */

.my-hand-area {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: calc(100% - 60px);
  transition: filter 0.6s ease, transform 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.my-hand-area.not-my-turn {
  filter: brightness(0.4);
  transform: translateX(-50%) scale(0.95);
}

.my-hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  position: relative;
  height: 200px;
  min-width: 150px;
}

/* Own cards: bigger */
.my-hand .hand-card {
  width: 140px;
  height: auto;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, margin 0.2s ease, filter 0.15s ease;
  box-shadow: 0 3px 12px rgba(0,0,0,0.4);
  position: relative;
  flex-shrink: 0;
}

.my-hand .hand-card:hover {
  transform: translateY(-24px) scale(1.12);
  z-index: 10;
  filter: brightness(1.15);
}

.my-hand .hand-card.unplayable {
  filter: brightness(0.5);
  cursor: default;
}

.my-hand .hand-card.unplayable:hover {
  transform: none;
  filter: brightness(0.5);
}

/* ===================== PLAYER SIDEBAR ===================== */

.player-sidebar {
  position: fixed;
  top: 50px;
  right: 0;
  width: 220px;
  height: calc(100% - 50px);
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  padding: 1em;
  overflow-y: auto;
  z-index: 50;
  display: none;
}

.player-sidebar h4 {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.8em;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.player-list, .spectator-list {
  list-style: none;
  margin-bottom: 1em;
}

.player-list li, .spectator-list li {
  padding: 0.5em 0.6em;
  border-radius: var(--radius);
  margin-bottom: 0.3em;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5em;
  transition: background var(--transition);
}

.player-list li.active-player {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.player-list li .player-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-list li .player-cards-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.player-list li .host-badge {
  font-size: 0.65rem;
  color: var(--gold);
  font-weight: 600;
}

.place-crown {
  font-size: 0.85rem;
}

.crown-gold { color: var(--gold); }
.crown-silver { color: var(--silver); }
.crown-bronze { color: var(--bronze); }

/* ===================== MODALS ===================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2em;
  min-width: 260px;
  max-width: 340px;
  animation: slideUp 0.25s ease;
}

.modal h3 {
  font-weight: 400;
  margin-bottom: 1.2em;
  font-size: 1.2rem;
}

.modal-title-center {
  text-align: center;
}

.modal-row {
  margin-bottom: 1em;
}

.modal-row label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.8em;
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 0.8em;
  justify-content: flex-end;
  margin-top: 1.5em;
}

/* PIN inputs (2FA style) */
.pin-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
}

input.pin-digit {
  width: 38px;
  height: 44px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 600;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border);
  border-radius: 0;
  color: var(--text-primary);
  outline: none;
  caret-color: var(--accent);
  transition: border-color 0.2s ease;
  padding: 0;
}

input.pin-digit:focus {
  border-bottom-color: #fff;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===================== COLOR MODAL ===================== */

.color-modal {
  text-align: center;
  position: relative;
}

.color-modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: color 0.2s ease;
}

.color-modal-close:hover {
  color: var(--text-primary);
}

.color-choices {
  display: flex;
  gap: 1em;
  justify-content: center;
  margin-top: 1em;
}

.color-btn {
  width: 60px;
  height: 60px;
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.color-btn:hover {
  transform: scale(1.15);
  border-color: #fff;
}

.color-blue { background: var(--blue); }
.color-green { background: var(--green); }
.color-yellow { background: var(--yellow); }
.color-red { background: var(--red); }

/* ===================== ANNOUNCEMENTS ===================== */

.announce-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s ease;
}

.announce-text {
  font-size: 3rem;
  font-weight: 200;
  color: #fff;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
  letter-spacing: 0.1em;
  animation: announceIn 0.5s ease;
}

.announce-overlay--top {
  align-items: flex-start;
  padding-top: 12vh;
}

@keyframes announceIn {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ===================== ENDGAME ===================== */

.endgame-modal {
  text-align: center;
  min-width: 350px;
}

.placements-list {
  list-style: none;
  margin: 1em 0;
}

.placements-list li {
  padding: 0.6em 1em;
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-size: 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.3em;
}

.placements-list li:first-child {
  background: rgba(255, 215, 0, 0.1);
}

/* ===================== CARD ANIMATIONS ===================== */

/* Draw pile soft pulse when it's my turn to draw */
.draw-pile.pulse-draw {
  animation: pulseDrawPile 1.5s ease-in-out infinite;
}

@keyframes pulseDrawPile {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.06); filter: brightness(1.25); }
}

/* Discard pile pulse when a card is played */
@keyframes pulseDiscard {
  0% { transform: scale(1); }
  25% { transform: scale(1.12); }
  50% { transform: scale(0.97); }
  75% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.discard-pile.pulse {
  animation: pulseDiscard 0.4s ease;
}

/* Hand slide-in from bottom */
@keyframes slideInHand {
  from { transform: translateY(120%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.my-hand.slide-in {
  animation: slideInHand 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

/* Drawn card zoom highlight */
@keyframes drawnCardZoom {
  0% { transform: translateY(0) scale(1); z-index: 1; }
  30% { transform: translateY(-30px) scale(1.25); z-index: 100; }
  70% { transform: translateY(-30px) scale(1.25); z-index: 100; }
  100% { transform: translateY(0) scale(1); z-index: 1; }
}

.hand-card.drawn-highlight {
  animation: drawnCardZoom 1s ease;
}

/* Animated dots for waiting text */
@keyframes dotPulse {
  0%, 20% { opacity: 0; }
  40% { opacity: 1; }
  100% { opacity: 1; }
}

.dot-animate .dot:nth-child(1) { animation: dotPulse 1.4s infinite 0s; }
.dot-animate .dot:nth-child(2) { animation: dotPulse 1.4s infinite 0.2s; }
.dot-animate .dot:nth-child(3) { animation: dotPulse 1.4s infinite 0.4s; }

.dot-animate .dot {
  opacity: 0;
}

/* Pass button */
.btn-pass {
  position: absolute;
  bottom: 260px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 0.6em 2em;
  font-size: 1.05rem;
}

.btn-pass:active {
  transform: translateX(-50%) scale(0.97);
}

/* ===================== SPECTATOR BANNER ===================== */

.spectator-banner {
  position: fixed;
  bottom: 60px;
  left: calc(50% - 110px);
  transform: translateX(-50%);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 0.5em 1.5em;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  z-index: 80;
}

/* ===================== RESPONSIVE ===================== */

@media (max-width: 768px) {
  .lobby-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .lobby-content {
    flex-direction: column;
  }

  .lobby-main {
    padding: 2em;
  }

  .player-sidebar {
    width: 160px;
  }

  .game-area {
    margin-right: 160px;
  }

  .card-img {
    width: 100px;
  }

  .my-hand .hand-card {
    width: 100px;
  }

  .my-hand {
    height: 140px;
  }

  .logo {
    font-size: 3.5rem;
  }

  .spectator-banner {
    left: calc(50% - 80px);
  }

}

/* ===================== BLACK HOLE ANIMATION ===================== */

.bh-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #000;
  opacity: 0;
  z-index: 2500;
  pointer-events: none;
  animation: bhDarken 2s ease forwards;
}

@keyframes bhDarken {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

/* ===================== LEAVE BUTTON ===================== */

.btn-leave {
  display: block;
  margin: 1em auto 0;
  z-index: 200;
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  padding: 0.5em 1.4em;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.btn-leave:hover {
  background: rgba(255, 23, 68, 0.15);
  border-color: #ff5252;
  color: #ff5252;
}

.btn-leave:active {
  transform: scale(0.96);
}

/* ===================== OTHER PLAYER NAME ROW ===================== */

.other-player-name-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Endgame modal wider override */
.endgame-modal {
  min-width: 320px;
  max-width: 400px;
}

#endgame-overlay {
  z-index: 3000;
}


