/* ══════════════════════════════════════════════════════════
   UNO — Stylesheet
   Designed for iPad 10th Gen (820 × 1180 pt portrait)
   Works in Safari, Chrome, and as a standalone PWA.
══════════════════════════════════════════════════════════ */

/* ── Custom Properties ── */
:root {
  --red:    #e53935;
  --red-d:  #b71c1c;
  --green:  #43a047;
  --green-d:#2e7d32;
  --blue:   #1e88e5;
  --blue-d: #0d47a1;
  --yellow: #f9a825;
  --yellow-d:#e65100;

  --felt-light: #2e9458;
  --felt-mid:   #1a6b38;
  --felt-dark:  #0e4522;

  --card-w: 140px !important;
  --card-h: 206px !important;
  --card-radius: 18px;
  --card-border: 3px solid rgba(255,255,255,0.6);

  --shadow-card: 2px 5px 16px rgba(0,0,0,0.45);
  --shadow-lift: 3px 10px 28px rgba(0,0,0,0.55), 0 0 0 3px rgba(255,255,170,0.85);

  --font-title: 'Fredoka One', cursive;
  --font-ui:    'Nunito', sans-serif;
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-ui);
  background:
    radial-gradient(ellipse at 50% 0%, var(--felt-light) 0%, var(--felt-mid) 45%, var(--felt-dark) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* subtle felt texture using a repeating tiny pattern */
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(100,220,140,0.15) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 0%, var(--felt-light) 0%, var(--felt-mid) 45%, var(--felt-dark) 100%);
}

/* ══════════════════════════════════════
   SCREEN SYSTEM
══════════════════════════════════════ */
.screen {
  display: none;
  width: 100%; height: 100%;
}
.screen.active { display: flex; }

/* ══════════════════════════════════════
   SETUP SCREEN
══════════════════════════════════════ */
#screen-setup {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 40px 24px;
  position: relative;
}

.logo {
  font-family: var(--font-title);
  font-size: 100px;
  color: #fff;
  letter-spacing: 8px;
  line-height: 1;
  text-shadow:
    5px  5px 0 var(--red),
    10px 10px 0 rgba(0,0,0,0.25);
}

.setup-card {
  background: rgba(0,0,0,0.30);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 24px;
  padding: 34px 30px;
  width: min(340px, 90vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.setup-label {
  color: rgba(255,255,255,0.92);
  font-size: 19px;
  font-weight: 800;
  text-align: center;
}

.num-row {
  display: flex;
  gap: 16px;
}

.num-btn {
  width: 68px; height: 68px;
  border-radius: 16px;
  border: 3px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-family: var(--font-title);
  font-size: 32px;
  cursor: pointer;
  transition: all .2s ease;
}
.num-btn.active {
  background: var(--red);
  border-color: #fff;
  transform: scale(1.12);
  box-shadow: 0 4px 16px rgba(229,57,53,0.5);
}

.deal-btn {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 18px 54px;
  font-family: var(--font-title);
  font-size: 26px;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--red-d), 0 8px 20px rgba(0,0,0,0.3);
  transition: transform .12s, box-shadow .12s;
  white-space: nowrap;
}
.deal-btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 var(--red-d), 0 4px 10px rgba(0,0,0,0.3);
}

/* iOS install hint */
.install-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  padding: 14px 20px;
  width: min(360px, 90vw);
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.9);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}
.hint-icon { font-size: 22px; flex-shrink: 0; }
.hint-close {
  background: none; border: none;
  color: rgba(255,255,255,0.6);
  font-size: 18px; cursor: pointer;
  margin-left: auto; flex-shrink: 0;
  padding: 4px 6px;
}

/* ══════════════════════════════════════
   GAME SCREEN LAYOUT
══════════════════════════════════════ */
#screen-game {
  flex-direction: column;
  padding: 8px 8px 6px;
  gap: 6px;
}

/* ── CPU Area ── */
#cpu-area {
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  gap: 8px;
  flex-shrink: 0;
  padding: 2px 4px;
}

.cpu-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}

.cpu-name-tag {
  font-size: 13px;
  font-weight: 900;
  color: rgba(255,255,255,0.88);
  background: rgba(0,0,0,0.30);
  padding: 4px 13px;
  border-radius: 20px;
  white-space: nowrap;
  transition: background .25s, color .25s;
}
.cpu-name-tag.active {
  background: var(--yellow);
  color: #333;
  animation: pulse-turn .9s ease-in-out infinite alternate;
}

.cpu-hand-fan {
  display: flex;
  align-items: flex-end;
}

/* Tiny card backs for CPU hand fan */
.mini-back {
  width: 65px !important;
  height: 96px !important;
  border-radius: 7px;
  background: linear-gradient(135deg, #434343 0%, #000000 100%); /* Black gradient */
  border: 2px solid rgba(255,255,255,0.7);
  box-shadow: 1px 2px 5px rgba(0,0,0,0.4);
  margin-left: -20px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  position: relative;
}
.mini-back:first-child { margin-left: 0; }
.mini-back::after {
  content: 'UNO';
  font-family: var(--font-title);
  font-size: 7px;
  color: rgba(255,255,255,0.65);
  transform: rotate(-20deg);
  display: block;
}

.cpu-count {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.72);
}

/* ── Center Table ── */
#table-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 0;
}

#status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

#color-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.32);
  padding: 6px 14px;
  border-radius: 20px;
}
#color-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.45);
  transition: background .3s;
}
#color-label {
  font-size: 13px; font-weight: 900; color: #fff;
}

#game-message {
  font-size: 15px; font-weight: 800;
  color: #fff;
  background: rgba(0,0,0,0.30);
  padding: 6px 16px;
  border-radius: 20px;
  text-align: center;
  max-width: 280px;
  line-height: 1.3;
  transition: opacity .2s;
}

#piles-row {
  display: flex;
  align-items: center;
  gap: 24px;
}

/* ── Player Area ── */
#player-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

#player-label {
  font-size: 14px; font-weight: 900;
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.30);
  padding: 4px 14px;
  border-radius: 20px;
  letter-spacing: .5px;
  transition: background .25s, color .25s;
}
#player-label.active {
  background: var(--yellow);
  color: #333;
  animation: pulse-turn .9s ease-in-out infinite alternate;
}

#player-hand {
  display: flex;
  overflow-x: scroll;
  overflow-y: visible;
  gap: 14px !important;
  padding: 18px 18px 8px;
  max-width: 100vw;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: none;
  -ms-overflow-style: none;
  align-items: flex-end;
}
#player-hand::-webkit-scrollbar { display: none; }

/* ══════════════════════════════════════
   CARDS
══════════════════════════════════════ */
.card {
  --cc: #888;          /* card color for oval text */
  width:  var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  border: var(--card-border);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
  user-select: none;
  flex-shrink: 0;
  overflow: hidden;
  /* subtle top-light sheen */
  background-image: linear-gradient(155deg, rgba(255,255,255,0.18) 0%, transparent 45%);
}

/* Card colors */
.card.red    { background-color: var(--red);    --cc: var(--red-d); }
.card.green  { background-color: var(--green);  --cc: var(--green-d); }
.card.blue   { background-color: var(--blue);   --cc: var(--blue-d); }
.card.yellow { background-color: var(--yellow); --cc: var(--yellow-d); }
.card.wild   { background-color: #1a1a1a;       --cc: #555; }

/* Oval center of card */
.card-oval {
  width: 46px; height: 68px;
  background: rgba(255,255,255,0.93);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transform: rotate(-22deg);
}

.card-val {
  font-family: var(--font-title);
  font-size: 30px;
  color: var(--cc);
  transform: rotate(22deg);
  line-height: 1;
}
.card-val.sm { font-size: 26px; }

/* Wild card — 4-color oval */
.wild-oval {
  width: 46px; height: 68px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  transform: rotate(-22deg);
  border: 2px solid rgba(255,255,255,0.2);
}
.wq      { width:100%; height:100%; }
.wq.r    { background: var(--red); }
.wq.b    { background: var(--blue); }
.wq.g    { background: var(--green); }
.wq.y    { background: var(--yellow); }

/* Corner pips */
.pip {
  position: absolute;
  font-family: var(--font-title);
  font-size: 18px;
  color: rgba(255,255,255,0.95);
  line-height: 1;
}
.pip.tl { top: 5px; left: 6px; }
.pip.br { bottom: 5px; right: 6px; transform: rotate(180deg); }

/* ── Draw pile (card back stack) ── */
.draw-stack {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  cursor: pointer;
}
.draw-shadow {
  position: absolute;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  background: #111; /* Dark shadow color */
  border: var(--card-border);
}
.draw-shadow.s1 { top: 3px; left: -3px; opacity: 0.45; }
.draw-shadow.s2 { top: 6px; left: -6px; opacity: 0.25; }
.draw-top {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  background: linear-gradient(135deg, #434343 0%, #000000 100%); /* Black gradient */
  border: var(--card-border);
  box-shadow: var(--shadow-card);
  display: flex; align-items: center; justify-content: center;
  background-image: linear-gradient(155deg, rgba(255,255,255,0.18) 0%, transparent 45%);
  transition: transform .13s;
}
.draw-stack:active .draw-top {
  transform: scale(0.95);
}
.draw-top-inner {
  width: 46px; height: 68px;
  background: rgba(255,255,255,0.12);
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.38);
  display: flex; align-items: center; justify-content: center;
  transform: rotate(-22deg);
}
.draw-top-label {
  font-family: var(--font-title);
  font-size: 16px; color: #fff;
  transform: rotate(22deg);
  letter-spacing: 1px;
}

.draw-empty {
  width: var(--card-w); height: var(--card-h);
  border-radius: var(--card-radius);
  border: 3px dashed rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.4);
  font-size: 12px; font-weight: 700;
  text-align: center;
  padding: 8px;
}

/* ── Discard pile ── */
.discard-card {
  /* same as .card but displayed without pointer events */
  cursor: default;
}

/* ── Player hand card states ── */
.hand-card {
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease;
  flex-shrink: 0;
}
.hand-card.playable {
  transform: translateY(-14px);
  box-shadow: var(--shadow-lift);
}
.hand-card.playable:active {
  transform: translateY(-8px) scale(0.94);
}
.hand-card.dimmed {
  opacity: 0.62;
  cursor: default;
}

/* Drawn card zone */
#drawn-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.6);
  padding: 18px 20px;
  border-radius: 18px;
  margin: 8px 0;
  position: relative;
  z-index: 10;
}

.drawn-label {
  font-size: 16px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.95);
  text-align: center;
  width: 100%;
  margin-bottom: 4px;
}

.drawn-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

/* Ensure the drawn card doesn't float upward and hide the label */
#drawn-card-el {
  transform: none !important;
  margin-top: 0 !important;
}

.pass-btn {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50px;
  padding: 10px 24px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.pass-btn:active {
  background: rgba(255, 255, 255, 0.28);
}
/* ══════════════════════════════════════
   COLOR PICKER MODAL
══════════════════════════════════════ */
.modal {
  display: none;
  position: fixed; inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.72);
  align-items: center; justify-content: center;
  animation: fadeIn .18s ease;
}
.modal.open { display: flex; }

.modal-inner {
  background: rgba(20,20,20,0.92);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 26px;
  padding: 32px 28px;
  display: flex; flex-direction: column;
  align-items: center; gap: 22px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.modal-title {
  font-family: var(--font-title);
  font-size: 30px; color: #fff;
}

.color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.color-btn {
  width: 116px; height: 90px;
  border-radius: 20px;
  border: 4px solid rgba(255,255,255,0.35);
  cursor: pointer;
  font-family: var(--font-title);
  font-size: 22px; color: #fff;
  text-shadow: 1px 2px 4px rgba(0,0,0,0.4);
  transition: transform .12s, border-color .12s;
  background-image: linear-gradient(155deg, rgba(255,255,255,0.18) 0%, transparent 50%);
}
.color-btn:active { transform: scale(0.91); border-color: #fff; }
.c-red    { background-color: var(--red); }
.c-blue   { background-color: var(--blue); }
.c-green  { background-color: var(--green); }
.c-yellow { background-color: var(--yellow); }

/* ══════════════════════════════════════
   UNO SHOUT
══════════════════════════════════════ */
#uno-shout {
  display: none;
  position: fixed; inset: 0;
  pointer-events: none; z-index: 200;
  flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
}
#uno-shout.show {
  display: flex;
  animation: uno-fade 2.2s ease-in-out forwards;
}
#uno-word {
  font-family: var(--font-title);
  font-size: 102px; color: var(--yellow);
  text-shadow:
    5px  5px  0 var(--red),
    10px 10px 0 rgba(0,0,0,0.3);
  animation: uno-bounce .42s cubic-bezier(0.34,1.56,0.64,1);
}
#uno-name {
  font-size: 22px; font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

/* ══════════════════════════════════════
   WIN SCREEN
══════════════════════════════════════ */
.win-inner {
  text-align: center;
  gap: 16px;
}
.win-emoji {
  font-size: 64px;
  animation: uno-bounce .5s cubic-bezier(0.34,1.56,0.64,1) .1s both;
}
.win-title {
  font-family: var(--font-title);
  font-size: 52px; color: var(--yellow);
  text-shadow: 4px 4px 0 var(--red), 8px 8px 0 rgba(0,0,0,0.25);
}
.win-sub {
  font-size: 18px; font-weight: 800; color: rgba(255,255,255,0.88);
  max-width: 260px;
}

/* ══════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════ */
@keyframes pulse-turn {
  from { box-shadow: none; }
  to   { box-shadow: 0 0 0 4px rgba(249,168,37,0.4); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes uno-fade {
  0%   { opacity: 0; }
  12%  { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes uno-bounce {
  0%   { transform: scale(0.2) rotate(-14deg); }
  55%  { transform: scale(1.18) rotate(4deg); }
  100% { transform: scale(1)    rotate(0deg); }
}

/* ══════════════════════════════════════
   LANDSCAPE ADJUSTMENTS
══════════════════════════════════════ */
@media (orientation: landscape) and (max-height: 600px) {
  :root {
    --card-w: 56px;
    --card-h: 82px;
    --card-radius: 10px;
  }
  .logo { font-size: 72px; }
  .setup-card { padding: 22px 24px; gap: 16px; }
  #screen-game { padding: 4px; gap: 4px; }
  .cpu-name-tag { font-size: 12px; }
  #game-message { font-size: 13px; }
}
