* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0e0a1a;
  --surface: #1a1230;
  --surface2: #2a1f45;
  --primary: #9b59b6;
  --primary-dark: #8344a5;
  --secondary: #6c3483;
  --text: #e8e0f0;
  --text-dim: #8070a0;
  --success: #2ecc71;
  --danger: #e74c3c;
  --warning: #f39c12;
  --radius: 14px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

#app { max-width: 500px; margin: 0 auto; padding: 12px; min-height: 100dvh; }
.screen { display: none; flex-direction: column; gap: 12px; animation: fadeIn .3s; }
.screen.active { display: flex; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }

.logo { text-align: center; padding: 36px 0 16px; }
.logo-icon { font-size: 68px; animation: pulse 2s infinite; }
.logo h1 { font-size: 32px; letter-spacing: 6px; color: var(--primary); text-shadow: 0 0 20px rgba(155,89,182,.4); }
.subtitle { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card h3 { font-size: 15px; color: var(--text-dim); }

input, select {
  background: var(--surface2); border: 2px solid transparent; border-radius: 10px;
  padding: 12px 14px; color: var(--text); font-size: 16px; outline: none; width: 100%;
  transition: border-color .2s;
}
input:focus { border-color: var(--primary); }
input::placeholder { color: var(--text-dim); }

.btn {
  border: none; border-radius: 10px; padding: 13px 20px; font-size: 15px;
  font-weight: 600; cursor: pointer; text-align: center; width: 100%; transition: all .2s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-large { padding: 16px; font-size: 17px; }
.btn-icon { background: none; border: none; font-size: 22px; cursor: pointer; padding: 6px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-uno {
  background: #e74c3c; color: white; font-size: 22px; font-weight: 900;
  letter-spacing: 4px; text-transform: uppercase; animation: pulse 1s infinite;
  border: 3px solid #c0392b; text-shadow: 0 2px 4px rgba(0,0,0,.4);
}
.btn-uno:hover { background: #c0392b; }

.divider { text-align: center; color: var(--text-dim); font-size: 13px; position: relative; }
.divider span { background: var(--surface); padding: 0 12px; position: relative; z-index: 1; }
.divider::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--surface2); }

.header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.code-badge { background: var(--primary); padding: 3px 12px; border-radius: 8px; font-family: monospace; font-size: 18px; letter-spacing: 3px; }

.player-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.player-list li {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--surface2); border-radius: 10px; font-size: 14px;
}
.player-list li img { width: 34px; height: 34px; border-radius: 50%; }
.player-list li.finished { opacity: .35; }

/* Players bar */
.players-bar { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; }
.player-chip {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 8px; border-radius: 10px; background: var(--surface); min-width: 60px;
  font-size: 11px; flex-shrink: 0; border: 2px solid transparent; position: relative;
  cursor: pointer;
}
.player-chip img { width: 32px; height: 32px; border-radius: 50%; }
.player-chip.current { border-color: var(--primary); background: rgba(155,89,182,.15); }
.player-chip.finished { opacity: .3; }
.player-chip .chip-cards { font-size: 10px; color: var(--text-dim); }
.player-chip .chip-uno { position: absolute; top: -4px; right: -4px; font-size: 10px; background: #e74c3c; color: white; padding: 1px 4px; border-radius: 6px; font-weight: 700; }

.turn-indicator {
  text-align: center; padding: 10px; border-radius: 10px; font-weight: 700; font-size: 15px;
  background: rgba(155,89,182,.1); border: 1px solid rgba(155,89,182,.3); color: var(--primary);
}
.turn-indicator.my-turn { background: rgba(46,204,113,.1); border-color: var(--success); color: var(--success); animation: pulse 1.5s infinite; }

/* Discard area */
.discard-area {
  display: flex; align-items: center; justify-content: center; gap: 24px; padding: 16px 0;
}
.discard-section { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.deck-section { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.deck-label { font-size: 11px; color: var(--text-dim); }

.discard-card {
  width: 90px; height: 130px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; font-weight: 900;
  border: 3px solid rgba(255,255,255,.3); box-shadow: 0 4px 20px rgba(0,0,0,.4);
  position: relative; overflow: hidden;
}
.discard-card .discard-oval {
  background: rgba(255,255,255,.92); border-radius: 50%; width: 60px; height: 85px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transform: rotate(-20deg); box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.discard-card .discard-value {
  font-size: 34px; font-weight: 900; line-height: 1; color: inherit;
  transform: rotate(20deg);
}
.discard-card .discard-label {
  font-size: 10px; font-weight: 700; transform: rotate(20deg); color: inherit; margin-top: 2px;
}
.discard-card .discard-corner {
  position: absolute; font-size: 12px; font-weight: 900; color: white; line-height: 1;
}
.discard-card .discard-corner-tl { top: 5px; left: 6px; }
.discard-card .discard-corner-br { bottom: 5px; right: 6px; transform: rotate(180deg); }
.discard-card.discard-amarillo .discard-corner { color: #2d3436; }

.deck-card {
  width: 90px; height: 130px; border-radius: 12px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; background: var(--secondary);
  border: 3px solid var(--primary); cursor: pointer; transition: transform .15s;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
.deck-card:active { transform: scale(.95); }
.deck-back { font-size: 36px; }
.deck-count { font-size: 14px; font-weight: 700; margin-top: 4px; }

.current-color-indicator {
  width: 32px; height: 32px; border-radius: 50%; border: 3px solid rgba(255,255,255,.4);
  box-shadow: 0 0 12px rgba(0,0,0,.3);
}

.direction-indicator {
  text-align: center; font-size: 13px; color: var(--text-dim); padding: 4px 0;
}

.action-log-bar {
  font-size: 13px; color: var(--warning); text-align: center; padding: 6px 12px;
  background: rgba(243,156,18,.08); border-radius: 8px; min-height: 28px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Hand */
.hand-section { }
.hand-section h3 { font-size: 14px; color: var(--text-dim); margin-bottom: 6px; }
.hand {
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 12px;
  -webkit-overflow-scrolling: touch;
}
.hand-card {
  border-radius: 10px; min-width: 62px; width: 62px; height: 90px;
  text-align: center; cursor: pointer; transition: all .15s; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.25); color: white; position: relative;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.hand-card:active { transform: scale(.95); }
.hand-card:hover { transform: translateY(-6px); border-color: rgba(255,255,255,.6); }
.hand-card .card-oval {
  background: rgba(255,255,255,.92); border-radius: 50%; width: 44px; height: 60px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transform: rotate(-20deg); box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.hand-card .card-value {
  font-size: 22px; font-weight: 900; line-height: 1; color: inherit;
  transform: rotate(20deg);
}
.hand-card .card-label {
  font-size: 8px; font-weight: 700; transform: rotate(20deg); color: inherit; margin-top: 1px;
}
.hand-card .card-corner {
  position: absolute; font-size: 9px; font-weight: 900; color: white; line-height: 1; z-index: 1;
}
.hand-card .card-corner-tl { top: 3px; left: 4px; }
.hand-card .card-corner-br { bottom: 3px; right: 4px; transform: rotate(180deg); }
.hand-card.card-amarillo .card-corner { color: #2d3436; }

/* Card color classes */
.card-rojo { background: #d63031; color: #d63031; }
.card-azul { background: #0984e3; color: #0984e3; }
.card-verde { background: #00b894; color: #00b894; }
.card-amarillo { background: #fdcb6e; color: #b8860b; }
.card-wild {
  background: linear-gradient(135deg, #d63031 25%, #0984e3 25%, #0984e3 50%, #00b894 50%, #00b894 75%, #fdcb6e 75%);
  color: #333;
}

/* Discard pile color */
.discard-rojo { background: #d63031; color: #d63031; }
.discard-azul { background: #0984e3; color: #0984e3; }
.discard-verde { background: #00b894; color: #00b894; }
.discard-amarillo { background: #fdcb6e; color: #b8860b; }
.discard-wild { background: linear-gradient(135deg, #d63031 25%, #0984e3 25%, #0984e3 50%, #00b894 50%, #00b894 75%, #fdcb6e 75%); color: #333; }

/* Color indicator */
.indicator-rojo { background: #d63031; }
.indicator-azul { background: #0984e3; }
.indicator-verde { background: #00b894; }
.indicator-amarillo { background: #fdcb6e; }

/* Color picker modal */
.color-picker {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px 0;
}
.color-btn {
  border: none; border-radius: 12px; padding: 20px; font-size: 16px; font-weight: 700;
  cursor: pointer; color: white; transition: transform .15s;
}
.color-btn:active { transform: scale(.95); }
.color-rojo { background: #d63031; }
.color-azul { background: #0984e3; }
.color-verde { background: #00b894; }
.color-amarillo { background: #fdcb6e; color: #2d3436; }

.game-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.game-actions .btn { flex: 1; min-width: 120px; }

/* Modals */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-content { max-width: 400px; width: 100%; max-height: 80vh; overflow-y: auto; }

/* Results */
.result-banner { text-align: center; padding: 30px 20px; }
.winner-icon { font-size: 64px; margin-bottom: 10px; }
.result-banner h2 { font-size: 28px; color: var(--warning); }

.hint { color: var(--text-dim); font-size: 13px; text-align: center; }
.error { color: var(--danger); font-size: 13px; text-align: center; animation: shake .3s; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--surface); color: var(--text); padding: 10px 20px; border-radius: 10px;
  font-size: 13px; z-index: 100; border: 1px solid var(--surface2);
  box-shadow: 0 6px 24px rgba(0,0,0,.5); transition: transform .3s;
}
.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 380px) {
  .logo h1 { font-size: 26px; }
  .hand-card { min-width: 54px; width: 54px; height: 78px; }
  .hand-card .card-oval { width: 38px; height: 52px; }
  .hand-card .card-value { font-size: 18px; }
  .hand-card .card-corner { font-size: 8px; }
  .discard-card, .deck-card { width: 75px; height: 110px; }
  .discard-card .discard-oval { width: 50px; height: 70px; }
}
