/* ═══════════════════════════════════════════════════════════
   MAKAO ONLINE – Premium Dark Theme Stylesheet
   ═══════════════════════════════════════════════════════════ */

/* ─── CSS CUSTOM PROPERTIES ─────────────────────────────── */
:root {
  /* Background & Surface */
  --bg-deep: #060e08;
  --bg-table: #0a1e12;
  --bg-felt: #145a2e;
  --bg-surface: rgba(255,255,255,0.04);
  --bg-surface-hover: rgba(255,255,255,0.08);

  /* Glass */
  --glass-bg: rgba(255,255,255,0.06);
  --glass-border: rgba(255,255,255,0.10);
  --glass-blur: 20px;

  /* Text */
  --text-primary: #e8e6e3;
  --text-secondary: rgba(255,255,255,0.55);
  --text-muted: rgba(255,255,255,0.3);

  /* Accents */
  --gold: #d4a745;
  --gold-glow: rgba(212,167,69,0.4);
  --green: #4caf50;
  --green-glow: rgba(76,175,80,0.35);
  --red: #ef5350;
  --red-glow: rgba(239,83,80,0.35);
  --blue: #42a5f5;

  /* Cards */
  --card-white: #ffffff;
  --card-red: #e53935;
  --card-black: #111111;
  --card-back-1: #1a237e;
  --card-back-2: #0d47a1;
  --card-shadow: rgba(0,0,0,0.3);

  /* Sizing */
  --card-w: 96px;
  --card-h: 138px;
  --card-radius: 10px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%; height: 100%;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 120% 80% at 50% 45%, rgba(20,90,46,0.35), transparent 70%),
    radial-gradient(circle at 50% 50%, var(--bg-table), var(--bg-deep));
}

/* ─── PARTICLES ─────────────────────────────────────────── */
#particles {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 3px; height: 3px;
  background: rgba(212,167,69,0.15);
  border-radius: 50%;
  animation: float-particle linear infinite;
}

@keyframes float-particle {
  0%   { transform: translateY(100vh) rotate(0deg); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(-20px) rotate(720deg); opacity: 0; }
}

/* ─── VIEWS ─────────────────────────────────────────────── */
.view {
  display: none;
  width: 100%; height: 100%;
  position: absolute; inset: 0;
  z-index: 1;
}
.view.active { display: flex; }

#game-view {
  box-shadow: inset 0 0 0 20px #3e2723, inset 0 0 20px 25px rgba(0,0,0,0.8);
  border-radius: 30px;
  margin: 10px;
  height: calc(100vh - 20px);
  width: calc(100vw - 20px);
  box-sizing: border-box;
  background-image: url('../images/poker_table.png');
  background-size: cover;
  background-position: center;
  position: relative;
}

/* ─── GLASS PANELS ──────────────────────────────────────── */
.glass-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

/* ─── BUTTONS ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border: none; border-radius: 10px;
  font-family: inherit; font-weight: 600; font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  white-space: nowrap;
  user-select: none;
}
.btn:disabled {
  opacity: 0.35; cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), #c4912e);
  color: #1a1200;
  box-shadow: 0 4px 18px var(--gold-glow);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px var(--gold-glow);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) { color: var(--text-primary); }

.btn-lg { padding: 14px 32px; font-size: 1.05rem; }

.btn-icon {
  background: none; border: none; cursor: pointer;
  font-size: 1.2rem; padding: 6px;
  border-radius: 8px;
  transition: background 0.2s;
}
.btn-icon:hover { background: var(--bg-surface-hover); }

/* ─── INPUTS ────────────────────────────────────────────── */
.input-group {
  display: flex; flex-direction: column; gap: 6px; width: 100%;
}
.input-group label {
  font-size: 0.8rem; font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 1px;
}
.input-group input {
  padding: 12px 16px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: rgba(0,0,0,0.3);
  color: var(--text-primary);
  font-family: inherit; font-size: 1rem;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.input-group input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}
.input-group input::placeholder { color: var(--text-muted); }

/* ─── DIVIDER ───────────────────────────────────────────── */
.divider {
  display: flex; align-items: center; gap: 16px;
  color: var(--text-muted); font-size: 0.85rem;
  margin: 4px 0;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px;
  background: var(--glass-border);
}

/* ─── LANGUAGE TOGGLE ───────────────────────────────────── */
.lang-btn {
  position: fixed; top: 16px; right: 16px;
  z-index: 1000;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: transform 0.25s var(--ease-spring), background 0.25s;
}
.lang-btn:hover { transform: scale(1.1); background: var(--bg-surface-hover); }

/* ═══════════════════════════════════════════════════════════
   LOBBY VIEW
   ═══════════════════════════════════════════════════════════ */
#lobby-view {
  align-items: center; justify-content: center;
}

.lobby-container {
  display: flex; flex-direction: column; align-items: center;
  gap: 30px; width: 100%; max-width: 400px;
  padding: 20px;
  animation: fadeUp 0.6s var(--ease-out);
}

.logo-section { text-align: center; }

.logo-title {
  font-size: 3.5rem; font-weight: 900;
  letter-spacing: 6px;
  background: linear-gradient(135deg, var(--gold), #f0d078, var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
  text-shadow: none;
  filter: drop-shadow(0 2px 10px var(--gold-glow));
}
.logo-card {
  display: inline-block;
  animation: cardSpin 3s ease-in-out infinite;
  filter: none;
  -webkit-text-fill-color: initial;
}
.logo-subtitle {
  display: block;
  font-size: 1rem; font-weight: 600;
  letter-spacing: 12px;
  -webkit-text-fill-color: var(--text-secondary);
  margin-top: 4px;
}
.logo-tagline {
  color: var(--text-secondary);
  font-size: 0.95rem; margin-top: 8px;
}

.lobby-panel {
  width: 100%; padding: 32px;
  display: flex; flex-direction: column;
  gap: 16px; align-items: stretch;
}

@keyframes cardSpin {
  0%, 100% { transform: rotateY(0deg); }
  50% { transform: rotateY(180deg); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════
   ROOM VIEW
   ═══════════════════════════════════════════════════════════ */
#room-view {
  align-items: center; justify-content: center;
}

.room-container {
  width: 100%; max-width: 440px;
  padding: 20px;
  animation: fadeUp 0.5s var(--ease-out);
}

.room-panel {
  padding: 32px;
  display: flex; flex-direction: column;
  align-items: center; gap: 20px;
}

.room-title {
  font-size: 1.1rem; font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 3px;
}

.room-code-display {
  display: flex; align-items: center; gap: 12px;
}

.room-code-display span {
  font-size: 2.5rem; font-weight: 800;
  letter-spacing: 8px; color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.room-link-hint { color: var(--text-muted); font-size: 0.85rem; }

.players-list {
  width: 100%;
  display: flex; flex-direction: column; gap: 8px;
  max-height: 240px; overflow-y: auto;
  padding: 4px 0;
}

.player-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-radius: 10px;
  background: var(--bg-surface);
  animation: fadeUp 0.3s var(--ease-out);
}

.player-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.95rem;
  color: #fff;
  flex-shrink: 0;
}

.player-item .player-name {
  flex: 1; font-weight: 500;
}

.player-item .host-badge {
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--gold);
  background: rgba(212,167,69,0.15);
  padding: 3px 8px; border-radius: 4px;
}

.hint-text { color: var(--text-muted); font-size: 0.82rem; }

/* ═══════════════════════════════════════════════════════════
   GAME VIEW
   ═══════════════════════════════════════════════════════════ */
#game-view {
  flex-direction: column;
  position: relative;
}

/* ── OPPONENTS AREA ────────────────────────────────────── */
#opponents-area {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
  padding: 12px 16px;
  flex-wrap: nowrap;
  z-index: 2;
  min-height: 90px;
}

.opponent-panel {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 10px 18px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 2px solid transparent;
  transition: all 0.4s var(--ease-out);
  min-width: 100px;
  position: relative;
}

.opponent-panel.inactive {
  opacity: 0.45;
  filter: grayscale(40%);
}

.opponent-panel.active-turn {
  opacity: 1 !important;
  filter: grayscale(0%) !important;
  border-color: var(--green);
  background: rgba(76,175,80,0.08);
  animation: extreme-pulse 1.5s infinite;
}

#player-area {
  transition: all 0.4s var(--ease-out);
}

#player-area.inactive {
  opacity: 0.6;
}

#player-area.active-turn {
  opacity: 1 !important;
  animation: extreme-pulse-player 1.5s infinite;
  border-radius: 20px;
}

@keyframes extreme-pulse {
  0%, 100% {
    box-shadow: 0 0 15px var(--green-glow), inset 0 0 10px rgba(76,175,80,0.1);
  }
  50% {
    box-shadow: 0 0 35px rgba(76,175,80,0.7), inset 0 0 20px rgba(76,175,80,0.25);
  }
}

@keyframes extreme-pulse-player {
  0%, 100% {
    box-shadow: 0 -10px 20px -10px var(--green-glow);
  }
  50% {
    box-shadow: 0 -10px 40px -10px rgba(76,175,80,0.7);
  }
}

.opponent-wait-badge {
  position: absolute;
  top: -8px; right: -8px;
  background: #ff5252;
  color: white;
  font-size: 0.7rem; font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
  animation: pulse-wait 1.5s infinite;
}
@keyframes pulse-wait {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.opponent-name {
  font-weight: 700;
  font-size: 0.9rem;
  background: linear-gradient(90deg, #fff, #d4a745);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.opponent-cards {
  display: flex; gap: 2px; align-items: center;
}

.opponent-mini-card {
  width: 18px; height: 26px;
  background: linear-gradient(135deg, var(--card-back-1), var(--card-back-2));
  border-radius: 3px; border: 1px solid rgba(255,255,255,0.1);
}

.opponent-card-count {
  font-size: 0.8rem; font-weight: 700;
  color: var(--text-secondary);
  margin-left: 4px;
}

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

.pile-wrapper {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px;
}

.pile-label {
  font-size: 0.75rem; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 2px;
}

.pile {
  width: var(--card-w); height: var(--card-h);
  border-radius: var(--card-radius);
  position: relative;
}

/* ── DRAW PILE ─────────────────────────────────────────── */
#draw-pile {
  box-shadow: 
    -1px -1px 0 #fff, -2px -2px 0 #ddd, 
    -3px -3px 0 #fff, -4px -4px 0 #ddd,
    -5px -5px 0 #fff, -6px -6px 0 #ccc,
    -10px -10px 15px rgba(0,0,0,0.6);
  transform: translate(6px, 6px);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
#draw-pile:hover {
  transform: translate(8px, 8px);
  box-shadow: 
    -1px -1px 0 #fff, -2px -2px 0 #ddd, 
    -3px -3px 0 #fff, -4px -4px 0 #ddd,
    -5px -5px 0 #fff, -6px -6px 0 #ccc,
    -7px -7px 0 #fff, -8px -8px 0 #bbb,
    -12px -12px 20px rgba(0,0,0,0.7);
}

#draw-pile.pulse-draw {
  animation: float-deck 2s ease-in-out infinite;
}
@keyframes float-deck {
  0%, 100% { transform: translate(6px, 6px); }
  50% { transform: translate(6px, 2px); }
}

.card-back {
  background: linear-gradient(145deg, var(--card-back-1), var(--card-back-2));
  border: 2px solid rgba(255,255,255,0.1);
}

.card-back-pattern {
  width: 100%; height: 100%;
  border-radius: calc(var(--card-radius) - 2px);
  background-image: url('../images/card_back.png');
  background-size: cover;
  background-position: center;
  border: 4px solid #ffffff;
  box-sizing: border-box;
}

.pile-count {
  position: absolute; bottom: -8px; right: -8px;
  background: rgba(0,0,0,0.7);
  color: var(--text-primary);
  font-size: 0.7rem; font-weight: 700;
  padding: 2px 7px; border-radius: 10px;
  border: 1px solid var(--glass-border);
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 4px 16px var(--card-shadow); }
  50% { box-shadow: 0 4px 30px rgba(76,175,80,0.5), 0 0 40px rgba(76,175,80,0.2); }
}

/* ── DISCARD PILE ──────────────────────────────────────── */
#discard-pile .card {
  position: absolute; inset: 0;
  animation: cardPlace 0.35s var(--ease-spring);
}

@keyframes cardPlace {
  from { transform: scale(0.5) rotate(-15deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ── CARDS ─────────────────────────────────────────────── */
.card {
  width: var(--card-w); height: var(--card-h);
  border-radius: var(--card-radius);
  position: relative;
  user-select: none;
}

.card-face {
  width: 100%; height: 100%;
  background: linear-gradient(160deg, #ffffff, #f5f3ef);
  border-radius: var(--card-radius);
  border: 1.5px solid rgba(0,0,0,0.12);
  box-shadow: 0 3px 12px var(--card-shadow);
  display: flex; flex-direction: column;
  padding: 7px 10px;
  position: relative;
  overflow: hidden;
}

.card-face.red { color: var(--card-red); }
.card-face.black { color: var(--card-black); }

.card-corner {
  display: flex; flex-direction: column;
  align-items: center;
  line-height: 1;
}
.card-corner-value { font-size: 18px; font-weight: 800; }
.card-corner-suit { font-size: 14px; }

.card-corner.bottom {
  position: absolute; bottom: 7px; right: 10px;
  transform: rotate(180deg);
}

.card-center {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 42px;
}

/* Joker card special style */
.card-face.joker {
  background: linear-gradient(135deg, #1a1a2e, #2d1b69, #1a1a2e);
  color: var(--gold) !important;
  border-color: rgba(212,167,69,0.3);
}
.card-face.joker .card-center {
  font-size: 46px;
  text-shadow: 0 0 15px var(--gold-glow);
}

/* Joker-as overlay */
.joker-as-badge {
  position: absolute;
  bottom: 6px; left: 50%; transform: translateX(-50%);
  font-size: 0.6rem; font-weight: 700;
  background: rgba(0,0,0,0.75);
  color: var(--gold);
  padding: 2px 6px; border-radius: 4px;
  white-space: nowrap;
}

/* ── GAME INFO (TURN & EFFECTS) ────────────────────────── */
#game-info {
  position: absolute;
  top: -120px; /* Moved higher up away from cards */
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  z-index: 20;
  width: 100%;
}

.turn-banner {
  padding: 10px 24px;
  border-radius: 30px;
  font-weight: 800;
  font-size: 1.2rem;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  border: 2px solid var(--glass-border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #ffffff;
}
.turn-banner.my-turn {
  background: rgba(255, 215, 0, 0.2);
  border-color: #ffd700;
  color: #ffffff;
  text-shadow: 0 0 10px #000, 0 0 20px #000;
  box-shadow: 0 0 35px rgba(255, 215, 0, 0.8);
  animation: my-turn-pulse 1.5s infinite alternate;
}

@keyframes my-turn-pulse {
  from { box-shadow: 0 0 25px rgba(255, 215, 0, 0.6); transform: scale(1); }
  to { box-shadow: 0 0 50px rgba(255, 215, 0, 1); transform: scale(1.05); }
}
.opponent-panel.active-turn {
  background: rgba(76,175,80,0.2);
  border: 2px solid var(--green);
  box-shadow: 0 0 20px rgba(76,175,80,0.5);
  transform: scale(1.05);
  animation: active-pulse 1.5s infinite alternate;
}

@keyframes active-pulse {
  from { box-shadow: 0 0 10px rgba(76,175,80,0.3); }
  to { box-shadow: 0 0 25px rgba(76,175,80,0.7); }
}

.opponent-panel.active-turn::after {
  content: '▼';
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--green);
  font-size: 20px;
  animation: bounce-arrow 1s infinite;
}

@keyframes bounce-arrow {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -5px); }
}

.effect-banner {
  padding: 8px 20px;
  border-radius: 12px;
  font-weight: 900;
  font-size: 1.3rem;
  color: #ff5252;
  background: rgba(20, 0, 0, 0.8);
  border: 2px solid #ff5252;
  text-transform: uppercase;
  letter-spacing: 2px;
  box-shadow: 0 0 15px rgba(255, 82, 82, 0.6);
  text-shadow: 0 0 5px rgba(255, 82, 82, 0.8);
}

/* ── HAND CARDS ────────────────────────────────────────── */
#player-area {
  display: flex; flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 16px;
  z-index: 10;
  border-radius: 20px;
  transition: box-shadow 0.3s;
  position: relative;
}
#player-area.active-turn {
  box-shadow: 0 0 40px rgba(76,175,80,0.4) inset;
  background: rgba(76,175,80,0.05);
  border: 1px solid rgba(76,175,80,0.3);
}

#penalty-preview {
  position: absolute;
  bottom: 100%; top: auto; margin-bottom: 20px;
  right: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: slideIn 0.3s var(--ease-spring);
  z-index: 30;
}
#drawn-card-preview.hidden, #penalty-preview.hidden { display: none; }

#penalty-preview {
  bottom: 100%; margin-bottom: 20px; top: auto;
  border: 1px solid rgba(255, 82, 82, 0.5);
  box-shadow: 0 8px 30px rgba(255, 82, 82, 0.3);
}

.preview-title {
  font-size: 0.8rem; font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
}
.drawn-actions {
  display: flex; gap: 6px;
}
.drawn-actions button { padding: 4px 12px; font-size: 0.85rem; }

#player-hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 160px;
  perspective: 800px;
  flex-wrap: nowrap;
  overflow: visible;
  max-width: 95%;
  padding: 80px 20px 20px;
}

.hand-card {
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.25s var(--ease-spring), filter 0.25s, z-index 0s;
  z-index: 1;
  margin: 0 -10px;
  touch-action: none;
}

.hand-card:hover {
  transform: translateY(-22px) scale(1.05);
  z-index: 50;
  filter: brightness(1.05);
}

.hand-card.selected {
  transform: translateY(-50px) scale(1.1);
  z-index: 60;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.hand-card.selected .card-face {
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 3px var(--green), 0 8px 25px var(--green-glow);
}

.hand-card.touch-active {
  transform: translateY(-20px) scale(1.05) !important;
  z-index: 50 !important;
  filter: brightness(1.1) !important;
  transition: transform 0.1s var(--ease-out), filter 0.1s;
}

.selection-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--gold);
  color: #000;
  font-weight: bold;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.new-card-glow .card-face {
  box-shadow: 0 0 25px #00e5ff;
  border-color: #00e5ff;
}

.hand-card.invalid {
  filter: brightness(0.55) saturate(0.4);
  cursor: not-allowed;
}
.hand-card.invalid:hover {
  transform: none;
  filter: brightness(0.55) saturate(0.4);
  z-index: 1;
}

.hand-card.drawn-card .card-face {
  box-shadow: 0 0 0 3px var(--gold), 0 8px 25px var(--gold-glow);
  animation: drawnPulse 1.5s ease-in-out infinite;
}

@keyframes drawnPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--gold), 0 8px 20px var(--gold-glow); }
  50% { box-shadow: 0 0 0 3px var(--gold), 0 8px 35px rgba(212,167,69,0.6); }
}

/* ── PLAYER ACTIONS ────────────────────────────────────── */
#player-actions {
  display: flex; gap: 10px; align-items: center;
  flex-wrap: nowrap; justify-content: center;
}

/* ── GAME INFO / EFFECTS ───────────────────────────────── */
#game-info {
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  pointer-events: none;
  z-index: 100;
  width: max-content;
}

.effect-banner {
  padding: 10px 24px;
  border-radius: 12px;
  font-weight: 800; font-size: 1.1rem;
  text-align: center;
  animation: bannerPulse 2s ease-in-out infinite;
  pointer-events: auto;
  color: #fff;
  background: rgba(0, 0, 0, 0.85);
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  text-transform: uppercase;
}

.effect-banner.attack {
  border: 2px solid #ef5350;
  background: rgba(180, 40, 40, 0.9);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.effect-banner.wait {
  border: 2px solid #ff9800;
  background: rgba(200, 100, 0, 0.9);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.effect-banner.demand {
  border: 2px solid #42a5f5;
  background: rgba(30, 100, 200, 0.9);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.effect-banner.suit-demand {
  border: 2px solid #ab47bc;
  background: rgba(120, 40, 150, 0.9);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

@keyframes bannerPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(0.97); }
}

.turn-banner {
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  padding: 8px 24px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.turn-banner.my-turn {
  color: #fff;
  background: rgba(30, 130, 35, 0.9);
  border: 2px solid #4caf50;
  box-shadow: 0 4px 20px rgba(76, 175, 80, 0.6);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.hidden { display: none !important; }

/* ── ACTION LOG ────────────────────────────────────────── */
#action-log {
  position: fixed;
  bottom: 160px; left: 12px;
  width: 250px; max-height: 180px;
  overflow-y: auto;
  padding: 10px 14px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  z-index: 5;
  opacity: 0.7;
  transition: opacity 0.3s;
}
#action-log:hover { opacity: 1; }

.log-entry {
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ═══════════════════════════════════════════════════════════
   ACTION PANELS (IN-GAME MODALS)
   ═══════════════════════════════════════════════════════════ */
.action-overlay {
  position: absolute;
  top: 40%;
  transform: translateY(-50%);
  left: 0; right: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 90;
  pointer-events: none;
}
.action-overlay:not(.hidden) > * {
  pointer-events: auto;
}

.action-panel {
  padding: 20px 30px;
  text-align: center;
  animation: slideUp 0.4s var(--ease-spring);
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
  border-radius: 20px;
  max-width: 95vw;
  box-sizing: border-box;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(40px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══════════════════════════════════════════════════════════
   GAME OVER MODALS
   ═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s;
}

.modal {
  padding: 32px;
  text-align: center;
  animation: modalIn 0.35s var(--ease-spring);
  max-width: 90vw;
}

.modal h3, .action-panel h3 {
  margin-bottom: 24px;
  font-size: 1.2rem; font-weight: 700;
  color: var(--gold);
  white-space: normal;
  word-break: break-word;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Suit choices */
.suit-choices {
  display: flex; gap: 12px; justify-content: center;
  flex-wrap: wrap;
}

.suit-btn {
  width: 72px; height: 72px;
  border-radius: 14px;
  border: 2px solid var(--glass-border);
  background: var(--bg-surface);
  cursor: pointer; font-size: 2rem;
  transition: all 0.25s var(--ease-spring);
  display: flex; align-items: center; justify-content: center;
}
.suit-btn:hover {
  transform: translateY(-4px) scale(1.1);
  border-color: var(--gold);
  background: rgba(212,167,69,0.1);
}

/* Value choices */
.value-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
  gap: 10px; margin-bottom: 16px;
}

.value-btn {
  padding: 14px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 900; font-size: 1.4rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9);
  cursor: pointer;
  transition: all 0.25s var(--ease-spring);
  font-family: inherit;
}
.value-btn:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
  background: rgba(212,167,69,0.3);
}

.no-demand-btn {
  margin-top: 8px;
  font-family: inherit;
}

/* Joker modal */
.joker-modal { max-width: 420px; }

.joker-section {
  margin-bottom: 20px;
}
.joker-section label {
  display: block; margin-bottom: 10px;
  font-size: 0.8rem; font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 1px;
}

.joker-values {
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: center;
}

.jv-btn, .js-btn {
  padding: 10px 14px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 900; font-size: 1.1rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9);
  cursor: pointer;
  transition: all 0.2s var(--ease-spring);
  font-family: inherit;
}
.jv-btn:hover, .js-btn:hover {
  border-color: var(--gold);
  background: rgba(212,167,69,0.3);
}
.jv-btn.active, .js-btn.active {
  border-color: var(--gold);
  background: rgba(212,167,69,0.5);
  color: var(--gold);
  box-shadow: 0 0 15px var(--gold-glow);
}

.joker-suits {
  display: flex; gap: 10px; justify-content: center;
}

.js-btn {
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}

/* ── SUIT SYMBOLS ──────────────────────────────────────── */
.suit-symbol.red { color: var(--card-red); }
.suit-symbol.black { color: var(--card-black); }

/* ═══════════════════════════════════════════════════════════
   GAME OVER
   ═══════════════════════════════════════════════════════════ */
.game-over-modal {
  position: relative; overflow: hidden;
  min-width: 340px;
}

.game-over-modal h2 {
  font-size: 1.1rem; font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 4px;
  margin-bottom: 16px;
}

#winner-display {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; margin-bottom: 24px;
}

.winner-emoji { font-size: 2.5rem; animation: bounce 1s ease infinite; }

#winner-name {
  font-size: 1.8rem; font-weight: 800;
  background: linear-gradient(135deg, var(--gold), #f0d078);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

#standings-list {
  display: flex; flex-direction: column;
  gap: 6px; margin-bottom: 24px;
}

.standing-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-radius: 8px;
  background: var(--bg-surface);
  font-size: 0.9rem;
}
.standing-rank { font-weight: 800; color: var(--gold); width: 24px; }
.standing-name { flex: 1; font-weight: 500; }
.standing-cards { color: var(--text-secondary); font-size: 0.8rem; }

.game-over-actions {
  display: flex; gap: 12px; justify-content: center;
  flex-wrap: nowrap;
}

/* ── CONFETTI ──────────────────────────────────────────── */
#confetti-container {
  position: absolute; inset: 0;
  overflow: hidden; pointer-events: none;
}

.confetti {
  position: absolute;
  width: 8px; height: 8px;
  top: -10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(400px) rotate(720deg); opacity: 0; }
}

/* ── TOAST NOTIFICATIONS ───────────────────────────────── */
#toast-container {
  position: fixed; top: 60px; right: 16px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: 10px;
  background: rgba(15, 15, 25, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 0.95rem; font-weight: 600;
  animation: toastIn 0.4s var(--ease-spring), toastOut 0.4s var(--ease-out) forwards;
  animation-delay: 0s, 3s;
  max-width: 300px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.8);
}

.toast.makao {
  border-color: var(--gold);
  background: rgba(40, 30, 10, 0.95);
  color: var(--gold);
  font-weight: 800; font-size: 1.1rem;
}

.toast.error {
  border-color: #ff5252;
  background: rgba(50, 10, 10, 0.95);
  color: #ff5252;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(60px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(60px); }
}

/* ═══════════════════════════════════════════════════════════
   DRAG AND DROP
   ═══════════════════════════════════════════════════════════ */
.hand-card.dragging {
  opacity: 0.25;
  transform: scale(0.92) !important;
  filter: brightness(0.5) !important;
}

.drag-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.92;
  transform: rotate(-4deg) scale(1.12);
  filter: drop-shadow(0 12px 28px rgba(0,0,0,0.5));
  transition: none;
}

#discard-pile-wrapper.drop-hover {
  position: relative;
}
#discard-pile-wrapper.drop-hover::after {
  content: '';
  position: absolute;
  inset: -14px;
  border: 2.5px dashed var(--green);
  border-radius: 18px;
  box-shadow: 0 0 24px var(--green-glow);
  pointer-events: none;
  animation: dropPulse 1s ease-in-out infinite;
}

@keyframes dropPulse {
  0%, 100% { box-shadow: 0 0 16px var(--green-glow); }
  50% { box-shadow: 0 0 32px rgba(76,175,80,0.5); }
}

/* ═══════════════════════════════════════════════════════════
   DRAW ANIMATION
   ═══════════════════════════════════════════════════════════ */
.draw-anim-card {
  position: fixed;
  z-index: 9999;
  width: var(--card-w);
  height: var(--card-h);
  transition: transform 1.2s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 1.2s ease;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root {
    --card-w: 72px;
    --card-h: 104px;
  }

  .logo-title { font-size: 2.6rem; }
  .lobby-panel, .room-panel { padding: 24px; }
  .room-code-display span { font-size: 2rem; letter-spacing: 5px; }

  #table-center { gap: 20px; }

  #action-log { display: none; }

  .hand-card { margin: 0 -18px; }
  .hand-card:hover { transform: translateY(-16px) scale(1.04); }
  .hand-card.selected { transform: translateY(-24px) scale(1.06); }

  .card-corner-value { font-size: 14px; }
  .card-corner-suit { font-size: 11px; }
  .card-center { font-size: 30px; }

  .modal { padding: 24px; }
  .suit-btn { width: 60px; height: 60px; font-size: 1.6rem; }
  .value-btn { padding: 10px; font-size: 1rem; }
  .opponent-panel { padding: 6px 12px; min-width: 80px; }
  .opponent-name { font-size: 0.75rem; }
}

@media (max-width: 480px) {
  :root {
    --card-w: 58px;
    --card-h: 84px;
  }

  .logo-title { font-size: 2rem; }
  #opponents-area { gap: 6px; padding: 4px; min-height: 70px; }

  #table-center { gap: 15px; }
  .pile-wrapper { gap: 4px; }

  #player-hand { 
    padding: 20px 10px 30px; 
    min-height: 120px; 
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    width: 100vw;
    margin-left: -8px;
    perspective: none;
    scrollbar-width: none;
  }
  #player-hand::-webkit-scrollbar {
    display: none;
  }
  #player-area { padding: 4px 8px 8px; gap: 8px; }

  .hand-card { margin: 0 -5px; }
  .card-center { font-size: 22px; }
  .card-corner-value { font-size: 12px; }
  .card-corner-suit { font-size: 10px; }
  
  .btn { padding: 8px 16px; font-size: 0.85rem; }
}

@media (max-height: 700px) {
  #table-center { gap: 15px; }
  #player-hand { padding-top: 30px; min-height: 110px; }
  #player-area { padding-bottom: 8px; }
  .pile-label { display: none; }
  :root {
    --card-w: 64px;
    --card-h: 92px;
  }
}

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

/* Drag state */
.dragging { opacity: 0.5 !important; }
.dragging-touch {
  position: fixed !important;
  z-index: 9999 !important;
  pointer-events: none !important;
  box-shadow: 0 15px 35px rgba(0,0,0,0.6) !important;
  opacity: 0.9 !important;
  margin: 0 !important;
  transition: none !important;
}

#table-center.drop-hover { box-shadow: inset 0 0 50px rgba(76, 175, 80, 0.3); border-radius: 30px; }

.new-card-highlight { box-shadow: 0 0 20px 5px rgba(0, 150, 255, 0.8) !important; border: 2px solid #0096ff; animation: popIn 0.5s var(--ease-spring); }
@keyframes popIn { 0% { transform: scale(0); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

#drawn-card-preview { display: flex; flex-direction: column; align-items: center; gap: 8px; background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); padding: 12px; border-radius: 12px; border: 1px solid var(--glass-border); box-shadow: 0 8px 24px rgba(0,0,0,0.5); margin-left: 20px; z-index: 10; transform: scale(0.9); }
#drawn-card-preview.hidden { display: none; }

/* ── EFFECTS BADGE ──────────────────────────────────────── */
#table-effect-badge {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 5.5rem;
  font-weight: 900;
  z-index: 10;
  pointer-events: none;
  animation: popAndGlow 2s infinite;
  text-shadow: 0 0 30px rgba(255, 0, 0, 0.8), 0 0 60px rgba(255, 0, 0, 0.5);
}
#table-effect-badge.hidden { display: none; }
#table-effect-badge.red { color: #ff5252; text-shadow: 0 0 30px rgba(255, 82, 82, 0.8), 0 0 60px rgba(255, 82, 82, 0.5); }
#table-effect-badge.black { color: #212121; text-shadow: 0 0 30px rgba(255, 255, 255, 0.8), 0 0 60px rgba(255, 255, 255, 0.5); }
#table-effect-badge.gold { color: #ffd700; text-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 215, 0, 0.5); }
#table-effect-badge.blue { color: #448aff; text-shadow: 0 0 30px rgba(68, 138, 255, 0.8), 0 0 60px rgba(68, 138, 255, 0.5); }

@keyframes popAndGlow {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.85; }
  50% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
}

/* ── IN-GAME CHAT ────────────────────────────────────── */
#chat-toggle-btn {
  position: fixed;
  bottom: 20px; left: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 1.5rem;
  display: flex; justify-content: center; align-items: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  cursor: pointer;
  z-index: 1000;
  border: none;
  transition: all 0.2s;
}
#chat-toggle-btn:hover {
  transform: scale(1.1);
}
#chat-unread-badge {
  position: absolute;
  top: -5px; right: -5px;
  background: #ff5252;
  color: white;
  font-size: 0.75rem; font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  display: none;
}
#chat-panel {
  position: fixed;
  bottom: 90px; left: 20px;
  width: 320px; height: 400px;
  background: rgba(15, 15, 25, 0.4);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  display: flex; flex-direction: column;
  z-index: 999;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  transform-origin: bottom left;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
}
#chat-panel.hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat-msg {
  background: rgba(255,255,255,0.05);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.3;
  word-break: break-word;
}
.chat-msg.system {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  background: rgba(255,255,255,0.02);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.8rem;
}
.chat-msg.system.attack {
  color: #ff5252;
  font-weight: 700;
  font-style: normal;
  background: rgba(255, 82, 82, 0.15);
  border: 1px solid rgba(255, 82, 82, 0.3);
}
.chat-msg.system.demand {
  color: var(--gold);
  font-weight: 700;
  font-style: normal;
  background: rgba(212, 167, 69, 0.15);
  border: 1px solid rgba(212, 167, 69, 0.3);
}
.chat-msg .chat-author {
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 2px;
  display: block;
  font-size: 0.8rem;
}
.chat-msg.self {
  background: rgba(76, 175, 80, 0.15);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-msg.other {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
#chat-input-container {
  display: flex;
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,0.1);
  gap: 8px;
}
#chat-input {
  flex: 1;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  border-radius: 20px;
  padding: 8px 12px;
  font-size: 0.9rem;
  outline: none;
}
#chat-input:focus { border-color: var(--primary); }
#chat-send-btn {
  background: var(--primary);
  border: none; color: white;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; justify-content: center; align-items: center;
}
@media (max-width: 480px) {
  #chat-toggle-btn, #chat-panel {
    display: none !important;
  }
}
