/* ============================================================
   SCREENS — Auth, Lobby, Waiting, Game
   ============================================================ */

/* ---- AUTH ---- */
#screen-auth {
  align-items: center; justify-content: center;
  background: var(--bg);
  min-height: 100vh; padding: 24px;
}
.auth-bg {
  position: fixed; inset: 0; z-index: 0;
  overflow: hidden; pointer-events: none;
}
.auth-grid {
  position: absolute; inset: -50%;
  background-image:
    linear-gradient(rgba(232,245,66,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232,245,66,0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  animation: gridDrift 30s linear infinite;
}
@keyframes gridDrift { to { transform: translate(48px, 48px); } }

.auth-wrap {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 0;
  width: 100%; max-width: 380px;
}
.auth-wrap .brand {
  margin-bottom: 28px;
  animation: fadeIn 0.6s ease;
}
.auth-wrap .brand-ivski { font-size: 36px; }
.auth-wrap .brand-uno   { font-size: 36px; }

.auth-card {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-top: 3px solid var(--yellow);
  border-radius: var(--radius-lg);
  padding: 28px 28px 20px;
  animation: fadeIn 0.6s ease 0.1s both;
}

.auth-tabs {
  display: flex; margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  flex: 1; padding: 10px; background: none; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--text-dim); font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 3px; cursor: pointer; transition: all 0.2s;
}
.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--yellow); border-bottom-color: var(--yellow); }

.auth-form { display: none; }
.auth-form.active { display: block; animation: fadeIn 0.3s ease; }

.guest-note { font-size: 10px; text-align: center; color: var(--text-dim); letter-spacing: 1px; margin-top: 8px; }

/* ---- LOBBY ---- */
#screen-lobby { background: var(--bg); }

.lobby-wrap {
  flex: 1; padding: 28px 20px; max-width: 900px;
  width: 100%; margin: 0 auto;
}
.lobby-section { animation: fadeIn 0.4s ease; }
.section-title {
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  letter-spacing: 4px; color: var(--text-dim); margin-bottom: 20px;
  text-transform: uppercase;
}

.mode-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  max-width: 600px;
}
.mode-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px 20px;
  text-align: center; cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.mode-card:hover {
  border-color: var(--yellow); transform: translateY(-3px);
}
.mode-icon  { font-size: 36px; margin-bottom: 12px; }
.mode-name  { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: #fff; margin-bottom: 6px; }
.mode-desc  { font-size: 11px; color: var(--text-dim); }

.cj-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  max-width: 700px;
}
.cj-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px;
}
.cj-card h3 {
  font-family: var(--font-display); font-size: 12px; font-weight: 700;
  letter-spacing: 3px; color: var(--yellow); margin-bottom: 18px;
}

.size-btns { display: flex; gap: 8px; }
.size-btn {
  flex: 1; padding: 8px 4px;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text-dim); border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 11px; cursor: pointer;
  transition: all 0.15s;
}
.size-btn:hover  { border-color: var(--yellow); color: var(--yellow); }
.size-btn.active { background: var(--yellow); color: #08090d; border-color: var(--yellow); font-weight: 700; }

.room-list { max-height: 200px; overflow-y: auto; margin-bottom: 10px; }
.room-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 6px;
  background: var(--bg3); cursor: pointer; transition: border-color 0.15s;
}
.room-item:hover { border-color: var(--yellow); }
.room-item-name  { font-size: 12px; color: var(--text); }
.room-item-info  { font-size: 10px; color: var(--text-dim); }
.room-item-join  {
  font-size: 10px; color: var(--yellow); letter-spacing: 1px;
  background: none; border: 1px solid var(--yellow);
  padding: 4px 10px; border-radius: 4px; cursor: pointer;
  font-family: var(--font-mono); transition: all 0.15s;
}
.room-item-join:hover { background: var(--yellow); color: #08090d; }

/* ---- WAITING ---- */
#screen-waiting {
  align-items: center; justify-content: center;
  background: var(--bg); padding: 24px;
}
.waiting-wrap { width: 100%; max-width: 460px; }
.waiting-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-top: 3px solid var(--yellow);
  border-radius: var(--radius-lg); padding: 32px 28px;
  text-align: center;
  animation: fadeIn 0.4s ease;
}
.waiting-header { margin-bottom: 24px; }
.waiting-header .brand-ivski { font-size: 22px; }
.waiting-header .brand-uno   { font-size: 22px; }

.room-code-display { margin-bottom: 24px; }
.rcd-label { font-size: 10px; letter-spacing: 3px; color: var(--text-dim); margin-bottom: 8px; }
.rcd-code {
  font-family: var(--font-display); font-size: 32px; font-weight: 800;
  color: var(--yellow); letter-spacing: 8px; margin-bottom: 10px;
}
.btn-copy {
  padding: 7px 18px; background: transparent;
  border: 1px solid var(--border2); color: var(--text-mid);
  border-radius: var(--radius); font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 2px; cursor: pointer;
  transition: all 0.15s;
}
.btn-copy:hover  { border-color: var(--yellow); color: var(--yellow); }
.btn-copy.copied { border-color: var(--green); color: var(--green); }

.waiting-players {
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: center; margin-bottom: 20px; min-height: 60px;
}
.waiting-player {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  animation: popIn 0.3s ease;
}
.wp-dot {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 14px; font-weight: 700;
  color: #08090d;
}
.wp-dot.empty { background: var(--bg3); border: 1px dashed var(--border2); color: var(--text-dim); font-size: 18px; }
.wp-name { font-size: 10px; color: var(--text-dim); letter-spacing: 1px; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wp-host { font-size: 9px; color: var(--yellow); }
.waiting-status { font-size: 11px; color: var(--text-dim); letter-spacing: 1px; margin-bottom: 16px; }

/* ---- GAME ---- */
#screen-game {
  display: none; flex-direction: column;
  background: var(--bg); min-height: 100vh;
  overflow: hidden;
}
#screen-game.active { display: flex; }

.opponents-area {
  display: flex; justify-content: center; gap: 20px;
  padding: 12px 16px 8px; flex-wrap: wrap;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  min-height: 110px;
}
.opponent-seat {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 80px;
}
.opp-info { display: flex; align-items: center; gap: 6px; }
.opp-dot {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #08090d; flex-shrink: 0;
}
.opp-name { font-size: 10px; color: var(--text-mid); letter-spacing: 1px; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp-cards { display: flex; gap: -10px; }
.opp-cards .card { margin-right: -18px; }
.opp-cards .card:last-child { margin-right: 0; }
.opp-card-count { font-size: 10px; color: var(--text-dim); }
.opp-turn-ring { outline: 2px solid var(--yellow); outline-offset: 3px; border-radius: 50%; animation: pulse 1.2s infinite; }

/* Game table */
.game-table {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; padding: 16px;
  gap: 8px;
}
.btn-leave-fixed {
  position: absolute; top: 10px; left: 12px;
  font-size: 10px !important; padding: 5px 10px !important;
  opacity: 0.6; z-index: 10;
}
.btn-leave-fixed:hover { opacity: 1; }
.callout-area {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  min-height: 0;
}
.table-felt {
  display: flex; align-items: center; gap: 28px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 24px; padding: 20px 28px;
  position: relative;
}
.pile-area { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pile-label { font-size: 9px; letter-spacing: 2px; color: var(--text-dim); text-transform: uppercase; margin-bottom: 4px; }
.pile-count { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); }

.discard-pile {
  width: 64px;
  height: 96px;
  position: relative;
  margin: 8px;
}
.discard-pile .card {
  position: absolute;
  top: 0;
  left: 0;
}

.direction-ind { font-size: 24px; transition: transform 0.4s; }
.direction-ind.reversed { transform: scaleX(-1); }

/* Draw stack banner */
.draw-stack-banner {
  position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
  background: var(--red); color: #fff;
  padding: 4px 14px; border-radius: 20px;
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-display); animation: popIn 0.3s ease;
}
.draw-stack-banner span:first-child { font-size: 16px; font-weight: 800; }
.ds-label { font-size: 9px; letter-spacing: 2px; opacity: 0.85; }

/* Game log */
.game-log {
  position: absolute; right: 8px; top: 58px;
  width: 180px; max-height: 160px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 3px;
}
.log-entry {
  font-size: 10px; color: var(--text-dim); padding: 3px 6px;
  border-left: 2px solid var(--border2); line-height: 1.4;
  animation: fadeIn 0.3s ease;
}
.log-entry.good    { color: var(--green); border-left-color: var(--green); }
.log-entry.bad     { color: var(--red); border-left-color: var(--red); }
.log-entry.special { color: var(--yellow); border-left-color: var(--yellow); }
.log-entry.info    { color: var(--blue); border-left-color: var(--blue); }

/* Player area — cards only */
.player-area {
  background: var(--bg2); border-top: 1px solid var(--border);
  padding: 8px 16px 12px; min-height: 130px;
  display: flex; flex-direction: column;
}
.player-info-bar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.pib-avatar { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: #08090d; }
.pib-name { font-size: 12px; color: var(--text); letter-spacing: 1px; }
.pib-handcount { font-size: 10px; color: var(--text-dim); margin-left: auto; }
.turn-ind {
  font-size: 10px; letter-spacing: 3px; color: var(--bg);
  background: var(--yellow); padding: 4px 10px; border-radius: 4px;
  font-weight: 700; animation: pulse 1.2s infinite;
}

.player-hand {
  display: flex;
  justify-content: safe center;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 6px 40px 8px;
  gap: 0;
  scrollbar-width: thin;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.player-hand .card {
  margin-right: -18px;
  scroll-snap-align: center;
  flex-shrink: 0;
  transition: max-width 0.2s, width 0.2s;
}
.player-hand .card:last-child { margin-right: 0; }
.player-hand .card:hover { z-index: 10; }

/* Намалување кога картите се многу */
.player-hand.compact .card {
  width: 44px !important;
  min-width: 44px !important;
  max-width: 44px !important;
  font-size: 10px;
}
.player-hand.compact .card .card-corner { font-size: 9px; }
.player-hand.compact .card .card-center { font-size: 11px; }

.hand-scroll-btn {
  display: none;
  position: absolute;
  top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  border: none; color: #fff;
  font-size: 24px; width: 32px; height: 48px;
  border-radius: 6px; cursor: pointer; z-index: 20;
  padding: 0; line-height: 1;
}
#hand-scroll-left  { left: 2px; }
#hand-scroll-right { right: 2px; }
.hand-scroll-btn.visible { display: block; }

.action-bar {
  display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 8px; padding: 8px 12px;
  background: transparent; border-top: none;
}
.action-bar-main {
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; flex: 1;
}
.action-btn {
  padding: 8px 18px; background: transparent;
  border: 1px solid var(--border2); color: var(--text-mid);
  border-radius: var(--radius); font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 1px; cursor: pointer;
  transition: all 0.15s;
}
.action-btn:hover      { border-color: var(--yellow); color: var(--yellow); }
/* Colored action buttons */
#btn-draw         { border-color: var(--green); color: var(--green); }
#btn-draw:hover   { background: var(--green); color: #08090d; }
#btn-pass         { border-color: var(--blue); color: var(--blue); }
#btn-pass:hover   { background: var(--blue); color: #fff; }
.uno-btn               { border-color: var(--red) !important; color: var(--red) !important; font-weight: 700; animation: pulse 0.8s infinite; font-size: 13px !important; padding: 10px 22px !important; }
.uno-btn:hover         { background: var(--red) !important; color: #fff !important; }

/* Game over */
.gameover-card { animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.gameover-emoji { font-size: 64px; margin-bottom: 12px; animation: popIn 0.6s ease 0.2s both; }
.gameover-card h2 {
  font-family: var(--font-display); font-size: 24px; font-weight: 800;
  letter-spacing: 2px; color: var(--yellow); margin-bottom: 8px;
}
.gameover-card p { font-size: 13px; color: var(--text-mid); margin-bottom: 20px; line-height: 1.6; }
.gameover-btns { display: flex; flex-direction: column; gap: 8px; }

/* Emoji overlay */
.emoji-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 400; overflow: hidden; }
.flying-emoji {
  position: absolute; font-size: 40px;
  animation: emojiFloat 2.5s ease forwards;
  pointer-events: none;
}
@keyframes emojiFloat {
  0%   { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translateY(-200px) scale(1.5) rotate(20deg); }
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .cj-grid       { grid-template-columns: 1fr; }
  .mode-cards    { grid-template-columns: 1fr; max-width: 300px; }
  .table-felt    { gap: 16px; padding: 14px 16px; }
  .game-log      { display: none; }
  .player-hand .card { margin-right: -22px; }
}

/* ---- IVski UNO watermark ---- */
.game-watermark {
  position: absolute; top: 10px; right: 16px;
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  color: rgba(255,255,255,0.07); letter-spacing: 3px;
  pointer-events: none; user-select: none;
}

.game-table-watermark {
  position: absolute;
  top: 20%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: clamp(32px, 6vw, 72px);
  font-weight: 800;
  letter-spacing: 8px;
  color: rgba(255,255,255,0.04);
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  z-index: 0;
}

/* ===== FOOTER ===== */

footer {
  margin-top: 100px;
  padding: 60px 0 40px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 30px;
}

.footer-links a {
  text-decoration: none;
  color: inherit;
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.footer-links a:hover {
  opacity: 1;
  color: #e8f542;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 0;
  align-items: center;
}

.footer-links a:not(:last-child)::after {
  content: '|';
  margin: 0 0.6em;
  opacity: 0.3;
  color: inherit;
}
.uno-footer span { color: rgba(74,81,104,0.4); }
.uno-footer a { color: rgba(74,81,104,0.7); text-decoration: none; }
.uno-footer a:hover { color: var(--yellow); }

/* Auth screen needs flex column for footer to stick to bottom */
#screen-auth { justify-content: flex-start; padding-top: 0; }
#screen-auth .auth-wrap { margin: auto; padding: 40px 24px 0; }

/* ---- Callout UNO button ---- */
.callout-btn {
  padding: 7px 16px; margin: 0;
  background: var(--red); color: #fff; border: none;
  border-radius: 4px; font-family: var(--font-mono);
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  cursor: pointer; animation: pulse 0.8s infinite;
  transition: all 0.15s;
}
.callout-btn:hover    { background: #ff2020; transform: scale(1.05); }
.callout-btn:disabled { background: var(--border2); animation: none; cursor: default; }

/* ---- Flying card animation ---- */
.flying-card {
  pointer-events: none;
  z-index: 500;
  border-radius: var(--radius, 10px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.4);
  will-change: transform, opacity;
  filter: brightness(1.1);
}

.audio-controls {
  position: absolute; top: 10px; right: 12px;
  display: flex; gap: 4px; z-index: 10;
}
.audio-btn {
  background: transparent; border: 1px solid var(--border2);
  border-radius: 6px; padding: 4px 7px;
  font-size: 14px; cursor: pointer; opacity: 0.5;
  transition: opacity 0.15s, border-color 0.15s;
  line-height: 1;
}
.audio-btn:hover { opacity: 1; border-color: var(--yellow); }

.cancel-color-btn {
  margin-top: 12px;
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: rgba(255,255,255,0.5);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.15s;
}
.cancel-color-btn:hover {
  border-color: rgba(255,255,255,0.5);
  color: rgba(255,255,255,0.8);
}
