
/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

:root {
  --green-dark:  #0a2e0a;
  --green-mid:   #0f4a0f;
  --green-felt:  #1a6b1a;
  --green-light: #22882a;
  --gold:        #f9a825;
  --gold-light:  #ffe082;
  --red-uno:     #d32f2f;
  --surface:     rgba(0,0,0,0.45);
  --glass:       rgba(255,255,255,0.07);
  --white:       #fff;
  --radius:      16px;
  --shadow:      0 8px 32px rgba(0,0,0,0.6);
}

html, body {
  height: 100%; width: 100%;
  font-family: 'Nunito', sans-serif;
  background: var(--green-dark);
  color: var(--white);
  overflow: hidden;
  user-select: none;
}

/* ===== SCREENS ===== */
.screen { display: none; width: 100%; height: 100vh; }
.screen.active { display: flex; }

/* ===== MENU SCREEN ===== */
#menu-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #1a6b1a 0%, #071a07 100%);
  gap: 32px;
}

.uno-logo {
  font-size: clamp(72px, 12vw, 120px);
  font-weight: 900;
  letter-spacing: -4px;
  color: var(--white);
  text-shadow:
    0 0 30px rgba(249,168,37,0.8),
    4px 4px 0 var(--red-uno),
    8px 8px 0 rgba(0,0,0,0.5);
  animation: logoPulse 3s ease-in-out infinite;
  background: linear-gradient(135deg, #fff 0%, var(--gold-light) 50%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
@keyframes logoPulse {
  0%,100% { transform: scale(1) rotate(-2deg); }
  50%      { transform: scale(1.04) rotate(2deg); }
}

.menu-panel {
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px;
  padding: 36px 44px;
  width: min(480px, 90vw);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.menu-panel h2 {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--gold-light);
  letter-spacing: 1px;
}

.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.6);
}

.form-group input[type="text"],
.form-group select {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  color: white;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.form-group input[type="text"]:focus,
.form-group select:focus {
  border-color: var(--gold);
  background: rgba(255,255,255,0.15);
}
.form-group select option { background: #1a3a1a; }

.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }

.difficulty-buttons { display: flex; gap: 8px; }
.diff-btn {
  flex: 1; padding: 9px; border: 2px solid rgba(255,255,255,0.2);
  border-radius: 10px; background: transparent; color: rgba(255,255,255,0.5);
  font-family: inherit; font-size: 13px; font-weight: 800;
  cursor: pointer; transition: all 0.2s;
}
.diff-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(249,168,37,0.12);
}
.diff-btn:hover { border-color: rgba(255,255,255,0.5); color: white; }

.start-btn {
  margin-top: 8px;
  padding: 16px;
  background: linear-gradient(135deg, var(--red-uno), #b71c1c);
  border: none; border-radius: 14px;
  color: white; font-family: inherit; font-size: 20px; font-weight: 900;
  cursor: pointer; letter-spacing: 2px;
  box-shadow: 0 6px 24px rgba(211,47,47,0.5);
  transition: all 0.2s;
}
.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(211,47,47,0.7);
}
.start-btn:active { transform: translateY(0); }

/* ===== GAME SCREEN ===== */
#game-screen {
  flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 50%, #216621 0%, #0a2e0a 100%);
  overflow: hidden;
  position: relative;
}

/* Felt texture overlay */
#game-screen::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.015) 0px, rgba(255,255,255,0.015) 1px, transparent 1px, transparent 8px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.015) 0px, rgba(255,255,255,0.015) 1px, transparent 1px, transparent 8px);
  pointer-events: none;
  z-index: 0;
}

/* ===== OPPONENTS AREA ===== */
#opponents-area {
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding: 12px 20px 0;
  z-index: 1;
  flex-shrink: 0;
}

.opponent-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}

.opponent-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  border: 3px solid rgba(255,255,255,0.2);
  background: var(--surface);
  backdrop-filter: blur(10px);
  transition: border-color 0.3s, box-shadow 0.3s;
  position: relative;
}
.opponent-avatar.active-turn {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(249,168,37,0.8);
  animation: activePulse 1s ease-in-out infinite;
}
@keyframes activePulse {
  0%,100% { box-shadow: 0 0 18px rgba(249,168,37,0.7); }
  50%      { box-shadow: 0 0 28px rgba(249,168,37,1); }
}

.opponent-name {
  font-size: 12px; font-weight: 800;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.opponent-hand-display {
  display: flex;
  position: relative;
  height: 70px;
}
.opp-card-back {
  width: 42px; height: 63px;
  border-radius: 6px;
  position: absolute;
  transition: transform 0.3s;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.5);
}

.card-count-badge {
  position: absolute;
  top: -6px; right: -6px;
  background: var(--red-uno);
  color: white;
  font-size: 10px; font-weight: 900;
  min-width: 20px; height: 20px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.uno-badge {
  position: absolute;
  bottom: -4px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, var(--red-uno), #b71c1c);
  color: white; font-size: 10px; font-weight: 900;
  padding: 2px 8px; border-radius: 10px;
  border: 1.5px solid white;
  letter-spacing: 1px;
  animation: unoBlink 0.4s ease-in-out infinite alternate;
}
@keyframes unoBlink {
  from { opacity: 1; } to { opacity: 0.6; }
}

/* ===== TABLE CENTER ===== */
#table-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  z-index: 1;
  position: relative;
}

.pile-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.pile-label {
  font-size: 11px; font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.45);
}

#draw-pile {
  position: relative; cursor: pointer;
  transition: transform 0.2s;
}
#draw-pile:hover { transform: scale(1.06) rotate(-3deg); }
#draw-pile:active { transform: scale(0.97); }

.pile-stack {
  position: relative;
  width: 90px; height: 135px;
}
.pile-stack-shadow {
  position: absolute;
  width: 90px; height: 135px;
  border-radius: 9px;
  background: rgba(0,0,0,0.3);
}
.pile-stack-shadow:nth-child(1) { top: 4px; left: 4px; }
.pile-stack-shadow:nth-child(2) { top: 2px; left: 2px; }

#discard-top {
  width: 90px; height: 135px;
  border-radius: 9px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  position: relative;
}
#discard-top svg { border-radius: 9px; }

/* Current color indicator */
#color-indicator {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 0 12px currentColor, 0 0 24px currentColor;
  transition: background 0.4s;
  margin: 0 auto;
}

/* Direction arrow */
#direction-arrow {
  font-size: 28px;
  transition: transform 0.5s;
  color: rgba(255,255,255,0.5);
  line-height: 1;
}

/* Turn info */
#turn-info {
  position: absolute;
  top: 12px; left: 50%; transform: translateX(-50%);
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 30px;
  padding: 8px 20px;
  font-size: 13px; font-weight: 800;
  letter-spacing: 0.5px;
  white-space: nowrap;
  z-index: 5;
}

/* Draw stack count */
#draw-count-display {
  font-size: 12px; font-weight: 800;
  color: rgba(255,255,255,0.5);
}

/* ===== PLAYER AREA ===== */
#player-area {
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px 16px;
  flex-shrink: 0;
}

#player-info-bar {
  display: flex;
  align-items: center;
  gap: 16px;
}

#player-name-display {
  font-size: 15px; font-weight: 800;
  color: rgba(255,255,255,0.85);
}
#player-score-display {
  background: var(--surface);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 13px; font-weight: 700;
  color: var(--gold-light);
  border: 1px solid rgba(249,168,37,0.3);
}

.player-active-indicator {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  animation: activePulse 1s ease-in-out infinite;
}
.player-active-indicator.hidden { opacity: 0; }

#player-hand {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0px;
  padding: 10px 0 0;
  overflow-x: auto;
  max-width: 100vw;
  scrollbar-width: none;
  min-height: 155px;
  position: relative;
}
#player-hand::-webkit-scrollbar { display: none; }

.hand-card {
  position: relative;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), filter 0.2s;
  margin: 0 -14px;
  flex-shrink: 0;
}
.hand-card:first-child { margin-left: 0; }
.hand-card:last-child  { margin-right: 0; }
.hand-card svg { display: block; border-radius: 9px; }
.hand-card:hover {
  transform: translateY(-22px) scale(1.1);
  z-index: 10;
  filter: drop-shadow(0 12px 16px rgba(0,0,0,0.6));
}
.hand-card.playable::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 12px;
  background: transparent;
  border: 3px solid var(--gold);
  box-shadow: 0 0 12px rgba(249,168,37,0.7);
  pointer-events: none;
  animation: playableGlow 1.5s ease-in-out infinite;
}
@keyframes playableGlow {
  0%,100% { box-shadow: 0 0 10px rgba(249,168,37,0.6); }
  50%      { box-shadow: 0 0 20px rgba(249,168,37,1); }
}
.hand-card.not-playable {
  filter: brightness(0.55) saturate(0.5);
  cursor: not-allowed;
}
.hand-card.not-playable:hover {
  transform: translateY(-4px);
  filter: brightness(0.7) saturate(0.6);
}

/* ===== UNO BUTTON ===== */
#uno-btn {
  position: fixed;
  bottom: 200px;
  right: 24px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red-uno), #8b0000);
  border: 3px solid white;
  color: white; font-family: inherit; font-size: 18px; font-weight: 900;
  cursor: pointer; letter-spacing: 1px;
  box-shadow: 0 6px 24px rgba(211,47,47,0.6);
  z-index: 20;
  transition: all 0.2s;
  display: none;
}
#uno-btn.visible { display: flex; align-items: center; justify-content: center; }
#uno-btn:hover { transform: scale(1.1); box-shadow: 0 10px 32px rgba(211,47,47,0.9); }
#uno-btn:active { transform: scale(0.95); }
#uno-btn.urgent { animation: unoUrgent 0.5s ease-in-out infinite alternate; }
@keyframes unoUrgent {
  from { box-shadow: 0 6px 24px rgba(211,47,47,0.6); transform: scale(1); }
  to   { box-shadow: 0 8px 36px rgba(211,47,47,1); transform: scale(1.08); }
}

/* ===== COLOR PICKER MODAL ===== */
#color-picker {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
}
#color-picker.visible { display: flex; }

.color-picker-panel {
  background: rgba(10,20,10,0.95);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 24px;
  padding: 32px;
  text-align: center;
  box-shadow: var(--shadow);
}
.color-picker-panel h3 {
  font-size: 18px; font-weight: 800; margin-bottom: 24px;
  color: var(--gold-light); letter-spacing: 1px;
}
.color-options { display: flex; gap: 18px; }
.color-opt {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.2);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.color-opt:hover { transform: scale(1.2); border-color: white; box-shadow: 0 8px 24px rgba(0,0,0,0.6); }
.color-opt[data-color="red"]    { background: #D32F2F; }
.color-opt[data-color="green"]  { background: #2E7D32; }
.color-opt[data-color="blue"]   { background: #1565C0; }
.color-opt[data-color="yellow"] { background: #F9A825; }

/* ===== NOTIFICATION TOAST ===== */
#toast {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(0,0,0,0.9);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 20px 36px;
  font-size: 22px; font-weight: 900;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  z-index: 200;
  max-width: 80vw;
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ===== OVERLAY (Round/Game End) ===== */
#overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.82);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 150;
  backdrop-filter: blur(8px);
}
#overlay.visible { display: flex; }

.overlay-panel {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 28px;
  padding: 40px 52px;
  text-align: center;
  box-shadow: var(--shadow);
  min-width: 340px;
  animation: overlayIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes overlayIn {
  from { transform: scale(0.7) translateY(30px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.overlay-panel h2 { font-size: 32px; font-weight: 900; margin-bottom: 8px; }
.overlay-panel .subtitle { color: rgba(255,255,255,0.6); margin-bottom: 24px; font-size: 14px; }

.scores-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.scores-table th, .scores-table td {
  padding: 8px 16px; text-align: left; font-size: 14px;
}
.scores-table th { color: var(--gold-light); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.scores-table tr:not(:last-child) td { border-bottom: 1px solid rgba(255,255,255,0.07); }
.scores-table td:last-child { text-align: right; font-weight: 800; }

.overlay-btn {
  padding: 14px 36px;
  border: none; border-radius: 14px;
  font-family: inherit; font-size: 16px; font-weight: 900;
  cursor: pointer; letter-spacing: 1px;
  transition: all 0.2s;
}
.overlay-btn-primary {
  background: linear-gradient(135deg, var(--red-uno), #8b0000);
  color: white;
  box-shadow: 0 6px 20px rgba(211,47,47,0.5);
}
.overlay-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(211,47,47,0.7); }
.overlay-btn-secondary {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.2);
  margin-left: 10px;
}
.overlay-btn-secondary:hover { background: rgba(255,255,255,0.15); color: white; }

/* ===== PARTICLES ===== */
.particle {
  position: fixed;
  pointer-events: none;
  font-size: 20px;
  animation: particleFly 1.2s ease-out forwards;
  z-index: 300;
}
@keyframes particleFly {
  0%   { opacity: 1; transform: translate(0,0) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0.3) rotate(var(--rot)); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

/* ===== ANIMATIONS ===== */
@keyframes cardDeal {
  from { transform: translateY(-200px) scale(0.5); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.dealing { animation: cardDeal 0.35s cubic-bezier(0.34,1.56,0.64,1) both; }

@keyframes cardPlay {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1); }
}
.playing-anim { animation: cardPlay 0.3s ease-in-out; }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .hand-card { margin: 0 -18px; }
  .hand-card svg { width: 72px !important; height: 108px !important; }
}
