/* ========================================
   MAHJONG - CSS STYLES
   Inspired by traditional Chinese aesthetics
   ======================================== */

:root {
  /* Color Palette - Rich Imperial Theme */
  --bg-dark: #0a0f0d;
  --bg-table: #1a2f23;
  --bg-table-gradient: linear-gradient(135deg, #1a2f23 0%, #0d1a14 50%, #1a2f23 100%);
  
  --jade: #2d6a4f;
  --jade-light: #40916c;
  --jade-glow: #52b788;
  
  --gold: #d4a574;
  --gold-bright: #e9c46a;
  --gold-dark: #8b6914;
  
  --red-imperial: #9d0208;
  --red-bright: #dc2f02;
  --red-soft: #6a040f;
  
  --ivory: #faf3e0;
  --ivory-dark: #e8dcc4;
  
  --text-primary: #faf3e0;
  --text-secondary: #a0a0a0;
  --text-muted: #606060;
  
  /* Tile Colors */
  --tile-bg: linear-gradient(145deg, #fefefe 0%, #e8e0d0 100%);
  --tile-border: #c4b8a8;
  --tile-shadow: rgba(0, 0, 0, 0.4);
  --tile-selected: #52b788;
  
  /* Typography */
  --font-chinese: 'Ma Shan Zheng', cursive;
  --font-main: 'Noto Sans', sans-serif;
  
  /* Spacing & Sizing - LARGER for better visibility */
  --tile-width: 52px;
  --tile-height: 72px;
  --tile-gap: 5px;
  
  /* Animations */
  --transition-fast: 0.15s ease;
  --transition-medium: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-main);
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
}

/* Background Pattern */
.bg-pattern {
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(circle at 20% 80%, rgba(45, 106, 79, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(157, 2, 8, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(212, 165, 116, 0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Corner Decorations */
.corner-decoration {
  position: fixed;
  width: 120px;
  height: 120px;
  pointer-events: none;
  z-index: 1;
  opacity: 0.3;
}

.corner-decoration::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border: 2px solid var(--gold);
}

.top-left { top: 20px; left: 20px; }
.top-left::before { border-right: none; border-bottom: none; }

.top-right { top: 20px; right: 20px; }
.top-right::before { border-left: none; border-bottom: none; }

.bottom-left { bottom: 20px; left: 20px; }
.bottom-left::before { border-right: none; border-top: none; }

.bottom-right { bottom: 20px; right: 20px; }
.bottom-right::before { border-left: none; border-top: none; }

/* Screens */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 10;
}

.screen.active {
  display: flex;
  animation: fadeIn 0.5s ease;
}

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

/* ========================================
   LOBBY SCREEN
   ======================================== */
#lobby {
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lobby-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.logo-section {
  text-align: center;
  animation: floatIn 0.8s ease;
}

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

.logo-tile {
  display: flex;
  justify-content: center;
  filter: drop-shadow(0 0 20px rgba(212, 165, 116, 0.4));
  animation: pulse 3s ease-in-out infinite;
}

.logo-tile .tile-image {
  width: 60px;
  height: 80px;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.game-title {
  font-family: var(--font-chinese);
  font-size: 72px;
  color: var(--gold);
  text-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(212, 165, 116, 0.3);
  margin-top: 8px;
}

.subtitle {
  font-size: 24px;
  color: var(--text-secondary);
  letter-spacing: 8px;
  text-transform: uppercase;
}

/* Lobby Card */
.lobby-card {
  background: linear-gradient(145deg, rgba(26, 47, 35, 0.9), rgba(13, 26, 20, 0.95));
  border: 1px solid var(--jade);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: slideUp 0.6s ease 0.2s backwards;
}

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

.input-group {
  margin-bottom: 24px;
}

.input-group label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.input-group input,
.join-section input {
  width: 100%;
  padding: 14px 18px;
  font-size: 18px;
  font-family: var(--font-main);
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--jade);
  border-radius: 8px;
  color: var(--text-primary);
  transition: var(--transition-fast);
}

.input-group input:focus,
.join-section input:focus {
  outline: none;
  border-color: var(--jade-light);
  box-shadow: 0 0 20px rgba(82, 183, 136, 0.2);
}

.input-group input::placeholder,
.join-section input::placeholder {
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 32px;
  font-size: 18px;
  font-weight: 600;
  font-family: var(--font-main);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--jade-light) 0%, var(--jade) 100%);
  color: var(--text-primary);
  box-shadow: 
    0 4px 15px rgba(45, 106, 79, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 6px 25px rgba(45, 106, 79, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: var(--bg-dark);
  font-weight: 700;
}

.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(212, 165, 116, 0.4);
}

.btn-icon {
  font-size: 20px;
}

.divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
  color: var(--text-muted);
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--jade), transparent);
}

.divider span {
  padding: 0 16px;
  font-size: 14px;
  text-transform: uppercase;
}

.join-section {
  display: flex;
  gap: 12px;
}

.join-section input {
  flex: 1;
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 4px;
  font-weight: 700;
}

/* How to Play */
.how-to-play {
  background: rgba(26, 47, 35, 0.5);
  border-radius: 12px;
  padding: 24px;
  animation: slideUp 0.6s ease 0.4s backwards;
}

.how-to-play h3 {
  color: var(--gold);
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 16px;
}

.how-to-play ul {
  list-style: none;
}

.how-to-play li {
  position: relative;
  padding-left: 24px;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 8px;
}

.how-to-play li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--jade-glow);
}

/* ========================================
   WAITING ROOM
   ======================================== */
#waitingRoom {
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.waiting-container {
  width: 100%;
  max-width: 700px;
  text-align: center;
}

.room-header {
  margin-bottom: 40px;
}

.room-header h2 {
  font-size: 32px;
  color: var(--gold);
  margin-bottom: 24px;
}

.room-code-display {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  background: rgba(26, 47, 35, 0.8);
  border: 2px solid var(--jade);
  border-radius: 12px;
  padding: 16px 24px;
  margin-bottom: 16px;
}

.room-code-display .label {
  color: var(--text-secondary);
  font-size: 14px;
  text-transform: uppercase;
}

.room-code-display .code {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--gold-bright);
  font-family: monospace;
}

.copy-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  opacity: 0.7;
  transition: var(--transition-fast);
}

.copy-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

.share-url {
  color: var(--text-muted);
  font-size: 12px;
  word-break: break-all;
}

.share-url span {
  color: var(--jade-glow);
}

/* Players Grid */
.players-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.player-slot {
  background: rgba(26, 47, 35, 0.6);
  border: 2px solid var(--jade);
  border-radius: 16px;
  padding: 24px;
  transition: var(--transition-medium);
}

.player-slot.filled {
  border-color: var(--gold);
  background: rgba(45, 106, 79, 0.3);
}

.player-slot.ready {
  border-color: var(--jade-glow);
  box-shadow: 0 0 20px rgba(82, 183, 136, 0.3);
}

.wind-label {
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.player-avatar {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
  opacity: 0.5;
  transition: var(--transition-fast);
}

.player-slot.filled .player-avatar {
  opacity: 1;
}

.player-slot .player-name {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.player-slot.filled .player-name {
  color: var(--text-primary);
  font-weight: 600;
}

.ready-status {
  font-size: 14px;
  color: var(--text-muted);
  transition: var(--transition-fast);
}

.ready-status.ready {
  color: var(--jade-glow);
  font-weight: 600;
}

/* Waiting Actions */
.waiting-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 24px;
}

.btn-ready {
  background: linear-gradient(135deg, rgba(45, 106, 79, 0.3), rgba(45, 106, 79, 0.1));
  border: 2px solid var(--jade);
  color: var(--text-primary);
  padding: 16px 40px;
}

.btn-ready:hover {
  background: linear-gradient(135deg, rgba(45, 106, 79, 0.5), rgba(45, 106, 79, 0.3));
  transform: translateY(-2px);
}

.btn-ready.ready {
  background: linear-gradient(135deg, var(--jade-glow), var(--jade));
  border-color: var(--jade-glow);
  box-shadow: 0 0 20px rgba(82, 183, 136, 0.4);
}

.btn-start {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: var(--bg-dark);
  font-weight: 700;
  padding: 16px 40px;
}

.btn-start:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-start:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(212, 165, 116, 0.5);
}

.ready-icon {
  font-weight: bold;
}

/* Waiting Status */
.waiting-status {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Host Controls */
.host-controls {
  margin-top: 24px;
  padding: 20px;
  background: rgba(26, 47, 35, 0.6);
  border: 1px solid var(--jade);
  border-radius: 12px;
}

.host-controls.hidden {
  display: none;
}

.host-controls h4 {
  color: var(--gold);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 16px;
}

.bot-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-bot {
  background: linear-gradient(135deg, #5c6bc0, #3949ab);
  color: white;
  padding: 12px 24px;
  font-size: 14px;
}

.btn-bot:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(92, 107, 192, 0.4);
}

.btn-bot:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-bot-remove {
  background: linear-gradient(135deg, #e57373, #c62828);
  color: white;
  padding: 12px 24px;
  font-size: 14px;
}

.btn-bot-remove:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(198, 40, 40, 0.4);
}

.btn-bot-remove:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Bot player slot styling */
.player-slot.bot {
  border-color: #5c6bc0;
  background: rgba(92, 107, 192, 0.2);
}

.player-slot.bot .ready-status.ready {
  color: #7986cb;
}

/* ========================================
   GAME SCREEN
   ======================================== */
#gameScreen {
  background: var(--bg-table-gradient);
  overflow: hidden;
  height: 100vh;
}

.game-container {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-areas:
    "left top right"
    "left center right"
    "bottom bottom bottom";
  grid-template-columns: 120px 1fr 120px;
  grid-template-rows: auto 1fr auto;
  padding: 10px;
  gap: 8px;
}

/* Player Areas */
.player-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.top-player { grid-area: top; }
.left-player { 
  grid-area: left; 
  justify-content: flex-start;
  align-items: flex-start;
  overflow: visible;
}
.right-player { 
  grid-area: right; 
  justify-content: flex-start;
  align-items: flex-end;
  overflow: visible;
}
.bottom-player { 
  grid-area: bottom;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  border: 1px solid rgba(82, 183, 136, 0.2);
  max-height: fit-content;
}

/* Player sections layout */
.player-left-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 180px;
  max-width: 280px;
}

.player-center-section {
  display: flex;
  flex-direction: row;
  gap: 10px;
  flex: 1;
  min-width: 0;
  align-items: center;
  justify-content: center;
}

.player-right-section {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 120px;
}

/* Player Info */
.player-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 20px;
  font-size: 15px;
}

.player-info.you {
  background: linear-gradient(135deg, rgba(45, 106, 79, 0.6), rgba(45, 106, 79, 0.3));
  border: 1px solid var(--jade-light);
}

.player-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
}

.player-indicator.active {
  background: var(--jade-glow);
  box-shadow: 0 0 10px var(--jade-glow);
  animation: glow 1.5s ease-in-out infinite alternate;
}

@keyframes glow {
  from { box-shadow: 0 0 5px var(--jade-glow); }
  to { box-shadow: 0 0 20px var(--jade-glow); }
}

.tile-count {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Opponent Hands (Hidden Tiles) */
.opponent-hand {
  display: flex;
  gap: 2px;
  justify-content: center;
  align-items: center;
}

.opponent-hand.top {
  flex-direction: row;
}

.opponent-hand.left {
  flex-direction: row;
}

.opponent-hand.right {
  flex-direction: row;
}

/* Hidden tiles using SVG */
.hidden-tile {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden-tile-normal svg {
  width: 38px;
  height: 52px;
}

.hidden-tile-small svg {
  width: 30px;
  height: 42px;
}

.hidden-tile-mini svg {
  width: 24px;
  height: 32px;
}

/* Player Melds */
.player-melds {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.right-player .player-melds {
  justify-content: flex-end;
}

.left-player .player-melds {
  justify-content: flex-start;
}

.meld {
  display: flex;
  gap: 2px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  border: 1px solid rgba(82, 183, 136, 0.3);
}

.opponent-meld {
  padding: 4px;
  gap: 1px;
}

.opponent-meld .tile-mini .tile-image {
  width: 32px !important;
  height: 48px !important;
}

/* Center Area */
.center-area {
  grid-area: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  padding-top: 10px;
}

.game-info {
  display: flex;
  gap: 28px;
  margin-bottom: 15px;
}

/* Scoreboard */
.scoreboard {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.score-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.4);
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 12px;
}

.score-item.you {
  border: 1px solid var(--jade-glow);
}

.score-name {
  color: var(--text-secondary);
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-points {
  color: var(--gold);
  font-weight: 700;
}

.wall-count, .current-turn {
  background: rgba(0, 0, 0, 0.5);
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 16px;
}

.wall-count .label {
  color: var(--text-secondary);
  margin-right: 8px;
}

#wallCount {
  color: var(--gold);
  font-weight: 700;
}

#turnIndicator {
  color: var(--jade-glow);
}

/* Discard Pile */
.discard-pile {
  width: 100%;
  max-width: 100%;
  min-height: 90px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(45, 106, 79, 0.3);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-start;
  align-content: flex-start;
}

/* Claim Actions */
.claim-actions {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(145deg, rgba(26, 47, 35, 0.95), rgba(13, 26, 20, 0.98));
  border: 2px solid var(--gold);
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  animation: popIn 0.3s ease;
  z-index: 100;
}

.claim-actions.hidden {
  display: none;
}

/* Chow Selection Popup */
.chow-selection {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(145deg, rgba(26, 47, 35, 0.98), rgba(13, 26, 20, 0.99));
  border: 2px solid var(--jade-glow);
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  animation: popIn 0.3s ease;
  z-index: 110;
}

.chow-selection.hidden {
  display: none;
}

.chow-selection-title {
  text-align: center;
  font-size: 16px;
  color: var(--jade-glow);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.chow-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.chow-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(82, 183, 136, 0.3);
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.chow-option:hover {
  background: rgba(82, 183, 136, 0.15);
  border-color: var(--jade-glow);
  transform: translateY(-2px);
}

.chow-option .tile {
  pointer-events: none;
}

.cancel-chow-btn {
  width: 100%;
  padding: 10px;
  background: rgba(139, 69, 69, 0.3);
  border: 1px solid rgba(220, 100, 100, 0.5);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.cancel-chow-btn:hover {
  background: rgba(180, 80, 80, 0.4);
  color: var(--text-primary);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

.claim-title {
  text-align: center;
  font-size: 16px;
  color: var(--gold);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.claim-buttons {
  display: flex;
  gap: 10px;
}

.claim-btn {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.claim-btn.win-btn {
  background: linear-gradient(135deg, var(--red-bright), var(--red-imperial));
  color: white;
}

.claim-btn.kong-btn,
.claim-btn.pong-btn {
  background: linear-gradient(135deg, var(--jade-light), var(--jade));
  color: white;
}

.claim-btn.chow-btn {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--bg-dark);
}

.claim-btn.skip-btn {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.claim-btn:hover {
  transform: translateY(-2px);
}

.claim-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Your Hand */
.your-hand {
  display: flex;
  gap: var(--tile-gap);
  justify-content: center;
  align-items: center;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  min-height: 80px;
  flex-wrap: wrap;
  max-width: 100%;
  overflow: visible;
}

/* Your melds container */
#yourMelds {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-start;
  max-width: 350px;
}

/* Drawn Tile Staging Area - positioned inline with hand */
.drawn-tile-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(82, 183, 136, 0.4), rgba(45, 106, 79, 0.5));
  border: 2px dashed var(--jade-glow);
  border-radius: 10px;
  animation: pulseGlow 2s ease-in-out infinite;
  flex-shrink: 0;
}

.drawn-tile-area.hidden {
  display: none;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(82, 183, 136, 0.3); }
  50% { box-shadow: 0 0 25px rgba(82, 183, 136, 0.6); }
}

.drawn-tile-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.drawn-tile-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--jade-glow);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.drawn-tile-slot {
  padding: 4px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
}

.drawn-tile-slot .tile {
  box-shadow: 0 0 15px rgba(82, 183, 136, 0.5);
}

/* Selected tile in hand for discard */
.tile.selected-for-discard {
  transform: translateY(-15px) scale(1.05);
  outline: 3px solid var(--gold-bright);
  outline-offset: 3px;
  box-shadow: 0 0 20px rgba(233, 196, 106, 0.6);
  animation: selectedPulse 1s ease-in-out infinite;
}

@keyframes selectedPulse {
  0%, 100% { box-shadow: 0 0 15px rgba(233, 196, 106, 0.5); }
  50% { box-shadow: 0 0 30px rgba(233, 196, 106, 0.8); }
}

/* Discard button */
.action-btn.discard-btn {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: var(--bg-dark);
  font-weight: 700;
}

.action-btn.discard-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(233, 196, 106, 0.5);
}

.action-btn.discard-btn:disabled {
  background: linear-gradient(135deg, #666, #444);
  color: #999;
}

/* Audio Controls Container */
/* Inline audio controls in game UI */
.audio-controls-inline {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.audio-btn-small {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--jade);
  background: rgba(26, 47, 35, 0.9);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.audio-btn-small:hover {
  background: var(--jade);
  transform: scale(1.1);
}

.audio-btn-small.active {
  background: var(--jade-glow);
  box-shadow: 0 0 8px rgba(82, 183, 136, 0.5);
}

.audio-btn-small.muted {
  opacity: 0.5;
}

.volume-slider-inline {
  width: 50px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.volume-slider-inline::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  background: var(--jade-glow);
  border-radius: 50%;
  cursor: pointer;
}

.volume-slider-inline::-moz-range-thumb {
  width: 10px;
  height: 10px;
  background: var(--jade-glow);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* Hide the old fixed audio controls */
.audio-controls {
  display: none;
}

.audio-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--jade);
  background: rgba(26, 47, 35, 0.9);
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.audio-btn:hover {
  background: rgba(45, 106, 79, 0.9);
  transform: scale(1.1);
}

.audio-btn.muted {
  opacity: 0.5;
  border-color: var(--text-muted);
}

.audio-btn.fart-btn {
  border-color: #8b4513;
  background: rgba(139, 69, 19, 0.7);
}

.audio-btn.fart-btn:hover {
  background: rgba(139, 69, 19, 0.9);
  transform: scale(1.15);
}

.audio-btn.fart-btn:active {
  transform: scale(0.95);
}

.audio-btn.fart-btn.playing {
  animation: fartPulse 0.5s ease-in-out;
}

@keyframes fartPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

/* Audio control group with volume popup */
.audio-control-group {
  position: relative;
}

.audio-control-group:hover .volume-popup {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

.volume-popup {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26, 47, 35, 0.98);
  border: 1px solid var(--jade);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 10px;
  display: block;
  opacity: 0;
  pointer-events: none;
  z-index: 1001;
  transition: opacity 0.15s ease;
}

/* Bridge element to prevent gap issues */
.volume-popup::before {
  content: '';
  position: absolute;
  bottom: -15px;
  left: 0;
  width: 100%;
  height: 20px;
}

/* Opponent tile stack with count badge */
.opponent-tile-stack {
  position: relative;
  display: inline-block;
}

.tile-count-badge {
  position: absolute;
  bottom: -8px;
  right: -8px;
  background: linear-gradient(135deg, #e9c46a, #d4a84b);
  color: #1a1a1a;
  font-size: 14px;
  font-weight: 700;
  min-width: 24px;
  height: 24px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  border: 2px solid #fff;
}

.volume-slider {
  width: 100px;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--jade-glow);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 5px rgba(82, 183, 136, 0.5);
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--jade-glow);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* Turn notification overlay */
.turn-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, rgba(45, 106, 79, 0.95), rgba(26, 47, 35, 0.98));
  border: 3px solid var(--gold);
  border-radius: 20px;
  padding: 30px 50px;
  z-index: 500;
  text-align: center;
  animation: turnNotifyIn 0.4s ease;
}

@keyframes turnNotifyIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.turn-notification h2 {
  font-size: 28px;
  color: var(--gold);
  margin-bottom: 10px;
}

.turn-notification p {
  font-size: 16px;
  color: var(--text-secondary);
}

/* ========================================
   TILES - SVG Based
   ======================================== */
.tile {
  cursor: pointer;
  transition: var(--transition-fast);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.tile:hover {
  transform: translateY(-8px);
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.4));
}

.tile.selected {
  transform: translateY(-12px);
  outline: 3px solid var(--tile-selected);
  outline-offset: 2px;
  filter: drop-shadow(0 0 15px rgba(82, 183, 136, 0.5));
}

.tile.disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.tile.disabled:hover {
  transform: none;
  filter: none;
}

.tile svg {
  display: block;
}

/* Tile sizes - LARGER for better visibility */
.tile-normal .tile-image {
  width: 48px;
  height: 72px;
  object-fit: contain;
  object-position: center top;
}

.tile-small .tile-image {
  width: 44px;
  height: 67px;
  object-fit: contain;
  object-position: center top;
}

.tile-mini .tile-image {
  width: 42px;
  height: 64px;
  object-fit: contain;
  object-position: center top;
}

/* Tile inner container for overlays */
.tile-inner {
  position: relative;
  display: inline-block;
  background: linear-gradient(to bottom, #fffff8 0%, #f5f0e1 100%);
  border-radius: 8px;
  padding: 3px;
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  border: 1px solid #a89880;
}

.tile-image {
  display: block;
  border-radius: 4px;
}

/* Number/Direction indicator overlay */
.tile-indicator {
  position: absolute;
  top: 6px;
  left: 6px;
  font-family: 'Arial Black', Arial, sans-serif;
  font-weight: 900;
  text-shadow: 
    1px 1px 0 #fff,
    -1px -1px 0 #fff,
    1px -1px 0 #fff,
    -1px 1px 0 #fff,
    0 1px 0 #fff,
    0 -1px 0 #fff,
    1px 0 0 #fff,
    -1px 0 0 #fff;
  pointer-events: none;
  z-index: 5;
  background: rgba(255, 255, 255, 0.85);
  padding: 1px 3px;
  border-radius: 3px;
  line-height: 1;
}

/* Back tile styling */
.tile-back .tile-inner {
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
}

.tile-back .tile-image,
.tile-back svg.tile-image {
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  display: block;
}

/* Discarded Tiles */
.discard-pile .tile {
  cursor: default;
}

.discard-pile .tile {
  flex-shrink: 0;
}

.discard-pile .tile .tile-inner {
  padding: 3px;
}

.discard-pile .tile.tile-small .tile-image {
  width: 50px !important;
  height: 76px !important;
}

.discard-pile .tile:hover {
  transform: none;
  filter: none;
}

.discard-pile .tile.last-discarded {
  outline: 4px solid #ffd700;
  outline-offset: 3px;
  animation: pulse-yellow 0.8s ease-in-out infinite;
  position: relative;
  z-index: 10;
  transform: scale(1.25);
  margin: 8px 12px;
}

.discard-pile .tile.last-discarded::before {
  content: '⬇ LAST ⬇';
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #ffd700, #ffb800);
  color: #1a1a1a;
  font-size: 9px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.6);
  letter-spacing: 0.5px;
}

@keyframes pulse-yellow {
  0%, 100% { 
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.7);
    outline-color: #ffd700;
  }
  50% { 
    box-shadow: 0 0 35px rgba(255, 215, 0, 1);
    outline-color: #ffed4a;
  }
}

/* Meld Tiles */
.meld .tile {
  cursor: default;
}

.meld .tile:hover {
  transform: none;
  filter: none;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.action-btn {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.action-btn.draw-btn {
  background: linear-gradient(135deg, var(--jade-light), var(--jade));
  color: white;
}

.action-btn.win-btn {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: var(--bg-dark);
}

.action-btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ========================================
   MODAL
   ======================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: linear-gradient(145deg, rgba(26, 47, 35, 0.98), rgba(13, 26, 20, 0.99));
  border: 2px solid var(--gold);
  border-radius: 24px;
  padding: 48px;
  text-align: center;
  max-width: 500px;
  animation: popIn 0.4s ease;
}

.modal-content.game-over-content {
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
}

/* Dice Roll Modal */
.modal-content.dice-roll-content {
  max-width: 600px;
  max-height: 90vh;
}

.dice-instruction {
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.dice-players {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.dice-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  border: 1px solid rgba(82, 183, 136, 0.2);
}

.dice-player-row.winner {
  border: 2px solid var(--gold);
  background: rgba(233, 196, 106, 0.15);
}

.dice-player-row.current {
  border: 2px solid var(--jade-glow);
  animation: dicePulse 1s ease-in-out infinite;
}

@keyframes dicePulse {
  0%, 100% { box-shadow: 0 0 5px rgba(82, 183, 136, 0.3); }
  50% { box-shadow: 0 0 15px rgba(82, 183, 136, 0.6); }
}

.dice-player-name {
  font-weight: 600;
}

.dice-player-result {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dice-player-dice {
  font-size: 24px;
}

.dice-player-total {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  min-width: 30px;
}

.dice-area {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-bottom: 24px;
}

.dice {
  font-size: 60px;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #fff, #e0e0e0);
  border-radius: 15px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s;
}

.dice.rolling {
  animation: diceRoll 0.15s ease-in-out infinite;
}

@keyframes diceRoll {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(15deg) scale(1.05); }
  50% { transform: rotate(0deg) scale(1); }
  75% { transform: rotate(-15deg) scale(1.05); }
  100% { transform: rotate(0deg) scale(1); }
}

.dice-roll-btn {
  font-size: 18px;
  padding: 15px 40px;
}

.dice-roll-btn:disabled {
  opacity: 0.5;
}

.dice-status {
  color: var(--text-secondary);
  margin-top: 16px;
  font-style: italic;
}

.winner-announcement {
  margin-bottom: 24px;
}

/* All Hands Display at Game Over */
.all-hands-display {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
  max-height: 400px;
  overflow-y: auto;
  padding: 10px;
}

.player-hand-display {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(82, 183, 136, 0.3);
}

.player-hand-display.winner {
  border: 2px solid var(--gold);
  background: rgba(233, 196, 106, 0.1);
}

.player-hand-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 600;
}

.player-hand-header .winner-badge {
  background: var(--gold);
  color: var(--bg-dark);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.player-hand-tiles {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.player-hand-melds {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255,255,255,0.2);
}

.trophy {
  font-size: 80px;
  margin-bottom: 16px;
  animation: bounce 0.6s ease infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-10px); }
}

.winner-announcement h2 {
  font-size: 36px;
  color: var(--gold);
  margin-bottom: 8px;
}

.winner-name {
  font-size: 24px;
  color: var(--text-primary);
}

.winner-points {
  font-size: 18px;
  color: var(--jade-glow);
  margin-top: 8px;
}

.score-summary {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  border: 1px solid rgba(82, 183, 136, 0.3);
}

.score-summary h3 {
  margin-bottom: 12px;
  color: var(--gold);
  font-size: 18px;
}

.score-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.score-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(26, 47, 35, 0.8);
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid rgba(82, 183, 136, 0.2);
}

.score-entry.is-winner {
  border-color: var(--gold);
  background: rgba(233, 196, 106, 0.15);
}

.score-entry-name {
  color: var(--text-secondary);
  font-size: 14px;
}

.score-entry-points {
  color: var(--gold);
  font-weight: 700;
  font-size: 16px;
}

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

.game-over-buttons .btn {
  min-width: 180px;
}

.winning-hand {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
  max-height: 300px;
  overflow: hidden;
}

.toast {
  background: linear-gradient(145deg, rgba(26, 47, 35, 0.95), rgba(13, 26, 20, 0.98));
  border: 1px solid var(--jade);
  border-radius: 10px;
  padding: 12px 18px;
  color: var(--text-primary);
  font-size: 13px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
  animation: slideInRight 0.3s ease;
  max-width: 280px;
  pointer-events: auto;
}

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

.toast.success {
  border-color: var(--jade-glow);
}

.toast.error {
  border-color: var(--red-bright);
}

.toast.info {
  border-color: var(--gold);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1100px) {
  .game-container {
    grid-template-columns: 100px 1fr 100px;
    grid-template-rows: auto 1fr auto;
  }
  
  .discard-pile {
    max-width: 450px;
    min-height: 140px;
    max-height: 160px;
  }
  
  .player-left-section {
    min-width: 140px;
    max-width: 200px;
  }
  
  .player-right-section {
    min-width: 100px;
  }
  
  .action-btn {
    padding: 10px 16px;
    font-size: 13px;
  }
  
  .tile-normal .tile-image {
    width: 48px;
    height: 73px;
  }
  
  .tile-small .tile-image {
    width: 36px;
    height: 55px;
  }
  
  .tile-inner {
    padding: 2px;
  }
  
  .tile-indicator {
    top: 4px;
    left: 4px;
    padding: 1px 2px;
  }
}

@media (max-width: 800px) {
  .game-container {
    grid-template-columns: 80px 1fr 80px;
    grid-template-rows: auto 1fr auto;
  }
  
  .tile-normal .tile-image {
    width: 42px;
    height: 64px;
  }
  
  .tile-small .tile-image {
    width: 32px;
    height: 49px;
  }
  
  .tile-inner {
    padding: 2px;
  }
  
  .discard-pile {
    max-width: 350px;
    min-height: 120px;
    max-height: 140px;
  }
  
  .discard-pile .tile.tile-small .tile-image {
    width: 46px !important;
    height: 70px !important;
  }
  
  .player-left-section {
    min-width: 100px;
    max-width: 150px;
  }
  
  .player-right-section {
    min-width: 80px;
  }
  
  .bottom-player {
    padding: 8px 10px;
    gap: 10px;
  }
  
  .tile-indicator {
    font-size: 10px !important;
    top: 3px;
    left: 3px;
    padding: 0px 2px;
  }
}

@media (max-width: 800px) {
  .drawn-tile-area {
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px;
  }
  
  .sound-toggle {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }
  
  .turn-notification {
    padding: 20px 30px;
  }
  
  .turn-notification h2 {
    font-size: 22px;
  }
}

@media (max-width: 600px) {
  .game-title {
    font-size: 48px;
  }
  
  .subtitle {
    font-size: 18px;
    letter-spacing: 4px;
  }
  
  .lobby-card {
    padding: 24px;
  }
  
  .players-grid {
    grid-template-columns: 1fr;
  }
  
  .waiting-actions {
    flex-direction: column;
  }
  
  .game-container {
    grid-template-columns: 60px 1fr 60px;
    grid-template-rows: auto 1fr auto;
  }
  
  .tile-normal .tile-image {
    width: 36px;
    height: 55px;
  }
  
  .tile-small .tile-image {
    width: 28px;
    height: 43px;
  }
  
  .tile-inner {
    padding: 2px;
  }
  
  .tile-indicator {
    font-size: 8px !important;
    top: 2px;
    left: 2px;
    padding: 0px 1px;
  }
  
  .bottom-player {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }
  
  .player-left-section {
    flex-direction: row;
    min-width: auto;
    max-width: none;
    width: 100%;
    justify-content: center;
  }
  
  .player-center-section {
    width: 100%;
  }
  
  .player-right-section {
    width: 100%;
    min-width: auto;
  }
  
  .action-buttons {
    flex-direction: row;
    gap: 6px;
  }
  
  .action-btn {
    padding: 8px 12px;
    font-size: 12px;
  }
  
  .discard-pile {
    max-width: 280px;
    min-height: 100px;
    max-height: 120px;
  }
  
  .discard-pile .tile.tile-small .tile-image {
    width: 42px !important;
    height: 64px !important;
  }
  
  .drawn-tile-area {
    padding: 8px;
    gap: 8px;
  }
  
  .drawn-tile-label {
    font-size: 9px;
  }
  
  .action-btn.discard-btn {
    font-size: 13px;
    padding: 10px 15px;
  }
  
  .sound-toggle {
    top: 10px;
    left: 10px;
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
  
  .turn-notification {
    padding: 15px 25px;
    border-radius: 12px;
  }
  
  .turn-notification h2 {
    font-size: 18px;
  }
  
  .turn-notification p {
    font-size: 14px;
  }
}
