/* UNO Online - Main styles */

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --primary: #43a047;
  --primary-hover: #66bb6a;
  --danger: #e53935;
  --warning: #ff9800;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --radius: 12px;
  --card-w: 72px;
  --card-h: 100px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
}

/* Screens */
.screen {
  display: none;
  width: 100%;
  max-width: 900px;
  flex: 1;
  flex-direction: column;
  align-items: center;
}

.screen.active {
  display: flex;
}

/* Lobby */
.lobby-card {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
}

.lobby-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  text-align: center;
}

.subtitle {
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 1.5rem;
}

.input-group {
  margin-bottom: 1rem;
}

.input-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.input-group input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--surface2);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.input-group.inline {
  display: inline-block;
  margin-right: 1rem;
  width: auto;
}

.input-group.inline input {
  width: 4rem;
}

.lobby-actions {
  margin-top: 1.5rem;
}

.btn {
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
  margin-bottom: 0.75rem;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
}

.btn-secondary:hover {
  background: #2d3a4f;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.btn-warning {
  background: var(--warning);
  color: #000;
}

.divider {
  text-align: center;
  color: var(--text-muted);
  margin: 0.5rem 0;
}

.join-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.join-row input {
  flex: 1;
  padding: 0.6rem;
  border: 1px solid var(--surface2);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.error-text {
  color: #ef5350;
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

.hidden {
  display: none !important;
}

/* Room lobby */
.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 500px;
  margin-bottom: 1rem;
}

.room-code-display {
  font-size: 1.1rem;
}

.room-code-display strong {
  letter-spacing: 0.15em;
  color: var(--primary);
}

.room-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.players-list {
  width: 100%;
  max-width: 400px;
  margin-bottom: 1rem;
}

.players-list h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.players-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.players-list li {
  padding: 0.5rem 0.75rem;
  background: var(--surface2);
  border-radius: 8px;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.players-list li .host-badge {
  font-size: 0.75rem;
  color: var(--primary);
}

/* Chat */
.chat-box {
  width: 100%;
  max-width: 400px;
  margin-top: 1rem;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 0.75rem;
  max-height: 180px;
  display: flex;
  flex-direction: column;
}

.chat-box h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.chat-box ul {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
  font-size: 0.85rem;
}

.chat-box li {
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.chat-box li .nick {
  color: var(--primary);
  margin-right: 0.35rem;
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.chat-input-row input,
.game-chat input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--surface);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

/* Game board */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.scores-summary {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.room-code-badge {
  background: var(--surface2);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.game-board {
  position: relative;
  width: 100%;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.discard-area {
  position: relative;
}

.discard-pile {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: transform 0.2s;
}

.discard-pile:hover {
  transform: scale(1.02);
}

.draw-stack-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--warning);
  color: #000;
  font-size: 0.75rem;
  font-weight: bold;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
}

.deck-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.deck-button {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  background: linear-gradient(145deg, #2d3a4f, #1a2332);
  border: 2px dashed var(--text-muted);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.deck-button:hover:not(:disabled) {
  transform: scale(1.05);
  border-color: var(--primary);
}

.deck-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.uno-btn-wrap {
  margin-top: 0.5rem;
}

.btn-uno {
  background: linear-gradient(180deg, #e53935, #c62828);
  color: #fff;
  font-size: 1.1rem;
  font-weight: bold;
  padding: 0.5rem 1.5rem;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(229,57,53,0.4);
  transition: transform 0.2s;
}

.btn-uno:hover:not(:disabled) {
  transform: scale(1.05);
}

.btn-uno:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Players bar */
.players-bar {
  width: 100%;
  margin: 1rem 0;
}

.player-slots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

.player-slot {
  background: var(--surface2);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  min-width: 100px;
  text-align: center;
  border: 2px solid transparent;
  transition: border-color 0.2s;
}

.player-slot.current-turn {
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(67,160,71,0.3);
}

.player-slot .name {
  font-weight: 600;
  font-size: 0.9rem;
}

.player-slot .cards-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.player-slot .score {
  font-size: 0.75rem;
  color: var(--primary);
}

/* My hand - cards */
.my-hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  min-height: calc(var(--card-h) + 20px);
  padding: 0.5rem;
  margin-top: auto;
}

.uno-card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  font-weight: bold;
  font-size: 1.1rem;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  user-select: none;
}

.uno-card:hover:not(.disabled) {
  transform: translateY(-8px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.uno-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.uno-card.playable {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(67,160,71,0.3);
}

.uno-card.dragging {
  opacity: 0.9;
  transform: scale(1.05);
  z-index: 10;
}

.game-message {
  min-height: 1.5em;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

.game-chat {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  max-width: 280px;
  max-height: 160px;
}

.game-chat input {
  margin-top: 0.35rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 90%;
}

.modal-content h3 {
  margin: 0 0 1rem;
}

.color-options {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.color-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  transition: transform 0.2s;
}

.color-btn:hover {
  transform: scale(1.1);
}

.color-btn[data-color="RED"] { background: #e53935; }
.color-btn[data-color="BLUE"] { background: #1e88e5; }
.color-btn[data-color="GREEN"] { background: #43a047; }
.color-btn[data-color="YELLOW"] { background: #fdd835; color: #333; }

#penalize-target-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

#penalize-target-list li {
  margin-bottom: 0.5rem;
}

#penalize-target-list button {
  width: 100%;
  padding: 0.5rem;
  text-align: left;
  background: var(--surface2);
  border: none;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}

#penalize-target-list button:hover {
  background: var(--danger);
  color: #fff;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
}

.overlay-content {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  text-align: center;
  max-width: 90%;
}

.overlay-content h2 {
  margin: 0 0 1rem;
}

#round-end-scores {
  margin: 1rem 0;
  text-align: left;
}

#round-end-scores div {
  padding: 0.35rem 0;
}

/* Responsive */
@media (max-width: 600px) {
  :root {
    --card-w: 56px;
    --card-h: 78px;
  }

  .lobby-card {
    padding: 1.25rem;
  }

  .join-row {
    flex-direction: column;
  }

  .game-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .my-hand {
    gap: 2px;
  }

  .uno-card {
    font-size: 0.9rem;
  }
}
