/* =========================================================
   UNO – Style Sheet
   Dark theme: #0F1117 bg, #1A1D27 surface, #305CDE accent
   ========================================================= */

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

:root {
  --bg: #0F1117;
  --surface: #1A1D27;
  --surface2: #22263a;
  --accent: #305CDE;
  --accent-h: #4a73f5;
  --text: #e8eaf6;
  --text-dim: #8890b0;
  --red:    #e53935;
  --yellow: #f9a825;
  --green:  #43a047;
  --blue:   #1e88e5;
  --wild:   #7b1fa2;
  --card-w: 68px;
  --card-h: 100px;
  --radius: 12px;
}

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  touch-action: manipulation;
}

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

/* ── Start Screen ── */
#start-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #1e2540 0%, var(--bg) 70%);
}
.start-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 32px 24px;
  max-width: 380px;
  width: 100%;
}
.uno-logo {
  font-size: clamp(72px, 18vw, 120px);
  font-weight: 900;
  letter-spacing: -4px;
  background: linear-gradient(135deg, #e53935 0%, #f9a825 40%, #43a047 70%, #1e88e5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 4px 24px rgba(48,92,222,.5));
  line-height: 1;
  text-shadow: none;
}
.subtitle { color: var(--text-dim); font-size: 16px; letter-spacing: 2px; text-transform: uppercase; }
.hint-text { color: var(--text-dim); font-size: 13px; text-align: center; line-height: 1.6; margin-top: 8px; }

/* ── Stat Box ── */
.stats-row { display: flex; gap: 16px; }
.stat-box {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: var(--radius);
  padding: 16px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.stat-num { font-size: 32px; font-weight: 800; color: var(--accent-h); }
.stat-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }

/* ── Buttons ── */
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-h) 100%);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  border: none;
  border-radius: 50px;
  padding: 16px 48px;
  cursor: pointer;
  letter-spacing: 1px;
  box-shadow: 0 4px 20px rgba(48,92,222,.45);
  transition: transform .15s, box-shadow .15s;
  width: 100%;
  max-width: 280px;
}
.btn-primary:hover  { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(48,92,222,.6); }
.btn-primary:active { transform: translateY(1px); }

.btn-secondary {
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50px;
  padding: 12px 32px;
  cursor: pointer;
  transition: background .15s, color .15s;
  width: 100%;
  max-width: 280px;
}
.btn-secondary:hover { background: rgba(255,255,255,.06); color: var(--text); }

/* ── Game Screen ── */
#game-screen {
  flex-direction: column;
  align-items: stretch;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

/* Status Bar */
#status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid rgba(255,255,255,.06);
  padding: 8px 16px;
  flex-shrink: 0;
  gap: 12px;
}
.player-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.player-label { font-weight: 700; color: var(--text-dim); text-transform: uppercase; font-size: 12px; letter-spacing: 1px; }
.card-count { font-size: 22px; font-weight: 800; color: var(--accent-h); line-height: 1; }
.cards-label { color: var(--text-dim); font-size: 12px; }
.game-status-center {
  flex: 1;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  min-width: 0;
}
#status-msg {
  display: inline-block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* AI Hand */
#ai-hand-area {
  flex-shrink: 0;
  padding: 8px 12px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 76px;
}
#ai-hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: -8px;
}

/* Play Area */
#play-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  position: relative;
  padding: 12px;
}
#current-color-indicator {
  position: absolute;
  top: 12px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}
#color-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.2);
  transition: background .3s;
}
#color-name { font-size: 10px; }

/* Piles */
#draw-pile, #discard-pile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.pile-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }

/* UNO Button */
#uno-btn-area {
  display: flex;
  justify-content: center;
  padding: 4px 12px;
  flex-shrink: 0;
}
.uno-shout-btn {
  background: linear-gradient(135deg, #e53935 0%, #c62828 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 2px;
  border: none;
  border-radius: 50px;
  padding: 10px 32px;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(229,57,53,.5);
  transition: transform .12s, opacity .2s;
}
.uno-shout-btn:active { transform: scale(.94); }
.uno-shout-btn.disabled { opacity: .35; pointer-events: none; }
.uno-shout-btn.pulse {
  animation: pulse-uno .6s ease-in-out infinite alternate;
}
@keyframes pulse-uno {
  from { box-shadow: 0 3px 12px rgba(229,57,53,.5); transform: scale(1); }
  to   { box-shadow: 0 6px 24px rgba(229,57,53,.85); transform: scale(1.06); }
}

/* Player Hand */
#player-hand-area {
  flex-shrink: 0;
  padding: 8px 4px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  max-height: 140px;
}
#player-hand-area::-webkit-scrollbar { display: none; }
#player-hand {
  display: flex;
  gap: 6px;
  padding: 0 8px;
  min-width: max-content;
  align-items: flex-end;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── CARDS ── */
.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: clamp(18px, 4vw, 26px);
  cursor: pointer;
  user-select: none;
  position: relative;
  flex-shrink: 0;
  transition: transform .15s ease, box-shadow .15s ease;
  border: 2px solid rgba(255,255,255,.15);
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
  overflow: hidden;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 35% 35%, rgba(255,255,255,.22) 0%, transparent 65%);
  pointer-events: none;
}
.card::after {
  content: attr(data-label);
  position: absolute;
  font-size: 10px;
  font-weight: 700;
  top: 4px;
  left: 6px;
  opacity: .8;
  line-height: 1;
}
.card.playable:hover {
  transform: translateY(-14px) scale(1.06);
  box-shadow: 0 16px 32px rgba(0,0,0,.5), 0 0 0 2px rgba(255,255,255,.4);
  z-index: 10;
}
.card.playable:active { transform: translateY(-8px) scale(1.02); }
.card.not-playable { opacity: .55; cursor: not-allowed; }

/* Card Colors */
.card.red    { background: linear-gradient(145deg, #e53935 0%, #b71c1c 100%); }
.card.yellow { background: linear-gradient(145deg, #f9a825 0%, #e65100 100%); }
.card.green  { background: linear-gradient(145deg, #43a047 0%, #1b5e20 100%); }
.card.blue   { background: linear-gradient(145deg, #1e88e5 0%, #0d47a1 100%); }
.card.wild   { background: conic-gradient(from 0deg, #e53935 0deg 90deg, #f9a825 90deg 180deg, #43a047 180deg 270deg, #1e88e5 270deg 360deg); }

/* Card symbol decoration */
.card-oval {
  position: absolute;
  width: 52px;
  height: 76px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(16px,3.5vw,24px);
  font-weight: 900;
  color: rgba(255,255,255,.95);
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
}

/* Face-down (AI) card */
.card.facedown {
  background: linear-gradient(135deg, #1a237e 0%, #283593 50%, #1a237e 100%);
  cursor: default;
  width: 44px;
  height: 64px;
  font-size: 0;
}
.card.facedown::before { background: repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0px, rgba(255,255,255,.04) 2px, transparent 2px, transparent 8px); }
.card.facedown::after { display: none; }
.card.facedown .card-oval { width: 32px; height: 48px; font-size: 14px; border-color: rgba(255,255,255,.15); }

/* Draw pile card */
.draw-pile-card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 10px;
  background: linear-gradient(135deg, #1a237e 0%, #283593 50%, #1a237e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid rgba(255,255,255,.15);
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
  transition: transform .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
}
.draw-pile-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0px, rgba(255,255,255,.04) 2px, transparent 2px, transparent 8px);
}
.draw-pile-card:hover { transform: translateY(-4px); box-shadow: 0 10px 24px rgba(0,0,0,.5); }
.draw-pile-card:active { transform: translateY(0); }
.card-inner {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: rgba(255,255,255,.6);
  position: relative;
  z-index: 1;
}

/* Card deal animation */
@keyframes deal-in {
  from { transform: translateY(40px) scale(.7); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.card.deal-anim { animation: deal-in .25s cubic-bezier(.34,1.56,.64,1) both; }

/* ── Game Over ── */
#gameover-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #1e2540 0%, var(--bg) 70%);
}
.gameover-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 32px 24px;
  max-width: 380px;
  width: 100%;
}
.result-emoji { font-size: 72px; line-height: 1; }
.result-title { font-size: clamp(32px,8vw,52px); font-weight: 900; text-align: center; }
.result-title.win  { color: #69f0ae; }
.result-title.lose { color: #ef5350; }
.result-sub { color: var(--text-dim); font-size: 16px; text-align: center; }

/* ── Color Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--surface);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 320px;
  width: 90%;
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal-title { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.color-btn {
  padding: 18px 0;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  text-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.color-btn.red    { background: linear-gradient(135deg, #e53935, #b71c1c); box-shadow: 0 4px 14px rgba(229,57,53,.4); }
.color-btn.yellow { background: linear-gradient(135deg, #f9a825, #e65100); box-shadow: 0 4px 14px rgba(249,168,37,.4); }
.color-btn.green  { background: linear-gradient(135deg, #43a047, #1b5e20); box-shadow: 0 4px 14px rgba(67,160,71,.4); }
.color-btn.blue   { background: linear-gradient(135deg, #1e88e5, #0d47a1); box-shadow: 0 4px 14px rgba(30,136,229,.4); }
.color-btn:hover  { transform: translateY(-2px) scale(1.04); }
.color-btn:active { transform: scale(.96); }

/* Color indicator dots */
#color-dot.red    { background: var(--red); }
#color-dot.yellow { background: var(--yellow); }
#color-dot.green  { background: var(--green); }
#color-dot.blue   { background: var(--blue); }
#color-dot.wild   { background: conic-gradient(from 0deg, var(--red) 0deg 90deg, var(--yellow) 90deg 180deg, var(--green) 180deg 270deg, var(--blue) 270deg 360deg); }

/* ── Toasts / Notifications ── */
#toast-container {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: rgba(26,29,39,.95);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  animation: toast-in .25s ease both, toast-out .3s ease .9s both;
}
@keyframes toast-in  { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateY(-8px); } }

/* ── Thinking Overlay ── */
#thinking-overlay {
  position: fixed;
  bottom: 155px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26,29,39,.9);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 50px;
  padding: 8px 20px;
  font-size: 13px;
  color: var(--text-dim);
  display: none;
  z-index: 50;
  backdrop-filter: blur(6px);
}
#thinking-overlay.visible { display: block; }

/* ── Responsive tweaks ── */
@media (max-width: 380px) {
  :root { --card-w: 58px; --card-h: 86px; }
  .card.facedown { width: 38px; height: 56px; }
}
@media (max-height: 640px) {
  :root { --card-w: 56px; --card-h: 82px; }
  .card.facedown { width: 36px; height: 54px; }
  .card.playable:hover { transform: translateY(-10px) scale(1.04); }
}
