/* ============================================================
   DOMINO.CSS — Estilos del juego de dominó
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --table-green: #1a5e2e;
  --table-felt:  #1e6e36;
  --table-edge:  #8B4513;
  --tile-bg:     #f5f0e8;
  --tile-shadow: rgba(0,0,0,0.5);
  --pip-color:   #1a1a1a;
  --pip-red:     #c0392b;
  --gold:        #fde047;
  --dark-bg:     #111727;
  --panel-bg:    rgba(17,23,39,0.92);
  --border:      rgba(255,255,255,0.08);
  --text:        #f3f4f6;
  --text-dim:    #9ca3af;
}

/* ── Layout ──────────────────────────────────────────────── */

/* Remove tap highlight on all domino interactive elements */
#domino-root *,
#view-domino * {
  -webkit-tap-highlight-color: transparent;
}

#domino-root {
  display: flex;
  flex-direction: column;
  background: var(--dark-bg);
  font-family: 'Inter', sans-serif;
  color: var(--text);
  overflow: hidden;
  min-height: 80vh;
  border-radius: 12px;
}

/* Safe area insets for devices with notch/home indicator (iPhone X+) */
#my-hand-area {
  padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
}

#game-hud {
  padding-top: max(8px, env(safe-area-inset-top, 8px));
}

/* Prevent double-tap zoom on game tiles */
.domino-tile,
.side-btn,
.btn-domino {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

/* Scrollable hand area — smooth momentum on iOS */
#my-hand-area {
  -webkit-overflow-scrolling: touch;
}

/* ── Lobby ───────────────────────────────────────────────── */
#domino-lobby {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2rem;
  overflow-y: auto;
  background: radial-gradient(ellipse at 50% 0%, rgba(30,110,54,0.2) 0%, transparent 70%), var(--dark-bg);
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.lobby-header h1 {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fde047, #fb923c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.lobby-actions {
  display: flex;
  gap: 1rem;
}

.btn-domino {
  padding: 0.65rem 1.5rem;
  border-radius: 12px;
  border: none;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-domino:active { transform: scale(0.96); }

.btn-create {
  background: linear-gradient(135deg, #fde047, #fb923c);
  color: #111;
}

.btn-create:hover { filter: brightness(1.1); }

.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: rgba(255,255,255,0.14); }

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.3);
}

.btn-danger:hover { background: rgba(239,68,68,0.25); }

.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 0.8rem 1.5rem;
  transition: all 0.2s;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.room-row:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.1);
  transform: translateX(5px);
}

.room-row-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex: 1;
}

.room-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  background: #374151;
}

.room-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.room-title-group {
  display: flex;
  flex-direction: column;
  min-width: 140px;
  flex: 1;
}

.room-title {
  font-weight: 800;
  color: #fff;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.room-subtitle {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.room-divider {
  color: #4b5563;
  margin: 0 0.5rem;
  font-size: 0.6rem;
}

.room-value {
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  justify-content: center;
}

.room-host-av {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  background: #374151;
}

.room-badge-join {
  background: rgba(34,197,94,0.15);
  color: #4ade80;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.8rem;
  border: 1px solid rgba(34,197,94,0.3);
}

.room-badge-full {
  background: rgba(107,114,128,0.15);
  color: #9ca3af;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.8rem;
  border: 1px solid rgba(107,114,128,0.3);
}

@media (max-width: 900px) {
  .room-row {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    padding: 1rem;
  }
  .room-row-left {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .room-title-group {
    flex: 1 1 100%;
    margin-bottom: 0.5rem;
  }
  .room-divider {
    display: none;
  }
  .room-value {
    flex: 1 1 45%;
    justify-content: flex-start;
  }
  .room-badge-join, .room-badge-full {
    width: 100%;
    text-align: center;
  }
}

.room-info span { display: flex; align-items: center; gap: 0.3rem; }

.room-host {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.room-host img, .room-host .avatar-placeholder {
  width: 28px; height: 28px;
  border-radius: 6px;
  object-fit: cover;
  background: #374151;
}

/* ── Modal ───────────────────────────────────────────────── */
.domino-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.domino-modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.domino-modal {
  background: #1a1d27;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  width: 420px;
  max-width: 95vw;
  transform: translateY(20px);
  transition: transform 0.2s;
}

.domino-modal-overlay.active .domino-modal {
  transform: translateY(0);
}

.domino-modal h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.form-group input:focus, .form-group select:focus {
  border-color: rgba(253,224,71,0.5);
}

.form-group select option { background: #1a1d27; }

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.modal-actions .btn-domino { flex: 1; padding: 0.75rem; }

/* ── Table / Game ────────────────────────────────────────── */
#domino-game {
  flex: 1;
  display: none;
  position: relative;
  overflow: hidden;
}

#domino-game.active { display: flex; flex-direction: column; }

/* Felt texture */
#game-table {
  flex: 1;
  background: #145228;
  position: relative;
  overflow: hidden;
}

/* La imagen de fondo ya trae su propio marco ornamentado, así que el borde
   de madera dibujado con CSS ya no hace falta. Va en su propia capa (::after)
   para poder rotarla en móvil sin tocar el color de respaldo de arriba. */
#game-table::before {
  content: none;
}

#game-table::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('../img/domino_table_bg.png');
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
}

@media (max-width: 1024px) and (orientation: portrait) {
  /* En pantallas angostas en retrato el tablero es más alto que ancho:
     rotamos la imagen 90° para que la veta de madera corra vertical. */
  #game-table::after {
    inset: auto;
    top: 50%;
    left: 50%;
    width: var(--gt-h, 100%);
    height: var(--gt-w, 100%);
    background-size: cover;
    transform: translate(-50%, -50%) rotate(90deg);
  }
}

/* ── Player Corners ──────────────────────────────────────── */
.player-corner {
  position: absolute;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  z-index: 10;
  padding: 0;
  background: none;
  backdrop-filter: none;
  border-radius: 0;
  border: none;
  min-width: auto;
  transition: all 0.3s;
}

.player-corner.active-turn .corner-name {
  color: var(--gold);
  text-shadow: 0 0 8px rgba(253,224,71,0.6);
}

/* seat-0 = yo (abajo, encima de las fichas) */
.player-corner.seat-0 { bottom: 160px; left: 50%; transform: translateX(-50%); }
/* seat-1 = arriba al centro */
.player-corner.seat-1 { top: 20px; left: 50%; transform: translateX(-50%); }
/* seat-2 = izquierda */
.player-corner.seat-2 { top: 50%; left: 20px; transform: translateY(-50%); }
/* seat-3 = derecha */
.player-corner.seat-3 { top: 50%; right: 20px; transform: translateY(-50%); }

.corner-avatar {
  width: 32px; height: 32px;
  border-radius: 6px;
  object-fit: cover;
  border: none;
}

.corner-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}

.corner-tiles-count {
  font-size: 0.72rem;
  color: var(--gold);
  font-weight: 600;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
}

.corner-status {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}

.corner-status.disconnected { background: #ef4444; }
.corner-status.waiting      { background: #fbbf24; }

/* ── Board Area ──────────────────────────────────────────── */
#board-area {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  z-index: 5;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Domino Tile ─────────────────────────────────────────── */
.domino-tile {
  display: inline-flex;
  flex-direction: column;
  background: var(--tile-bg);
  border-radius: 5px;
  box-shadow: 2px 3px 8px var(--tile-shadow), inset 0 1px 0 rgba(255,255,255,0.8);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: default;
  border: 1px solid rgba(0,0,0,0.15);
}

.domino-tile.horizontal {
  flex-direction: row;
  width: 60px;
  height: 30px;
}

.domino-tile.vertical {
  flex-direction: column;
  width: 30px;
  height: 60px;
}

.domino-tile.board-tile {
  position: absolute;
  width: 50px;
  height: 26px;
  /* Origin top-left makes math easier */
  transform-origin: top left;
  /* We use top and left properties in JS, and transition them */
  transition: top 0.3s ease, left 0.3s ease, transform 0.3s ease, box-shadow 0.15s;
  animation: tileFadeIn 0.3s ease;
}

.domino-tile.board-tile.vertical {
  width: 26px;
  height: 50px;
}

@keyframes tileFadeIn {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

.domino-tile.hand-tile {
  flex-direction: column !important;
  width: 44px;
  height: 86px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.domino-tile.hand-tile:hover {
  transform: translateY(-12px) scale(1.05);
  box-shadow: 4px 8px 20px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.8);
  z-index: 10;
}

.domino-tile.hand-tile.selected {
  transform: translateY(-18px) scale(1.08);
  box-shadow: 0 0 0 3px var(--gold), 4px 8px 20px rgba(0,0,0,0.6);
  z-index: 11;
}

.domino-tile.hand-tile.invalid-tile {
  animation: tileShake 0.4s ease;
}

@keyframes tileShake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-6px) rotate(-2deg); }
  40%     { transform: translateX(6px) rotate(2deg); }
  60%     { transform: translateX(-4px) rotate(-1deg); }
  80%     { transform: translateX(4px) rotate(1deg); }
}

.domino-tile.hand-tile.valid-highlight {
  box-shadow: 0 0 0 2px #4ade80, 2px 3px 8px var(--tile-shadow);
}

.tile-half {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 4px;
  position: relative;
}

.board-tile .tile-half { padding: 2px; }

/* Separador central */
.tile-half:first-child::after {
  content: '';
  position: absolute;
  background: rgba(0,0,0,0.25);
}

.domino-tile.vertical .tile-half:first-child::after {
  bottom: 0; left: 10%; right: 10%;
  height: 1px;
}

.domino-tile.horizontal .tile-half:first-child::after {
  right: 0; top: 10%; bottom: 10%;
  width: 1px;
}

/* Pips */
.pip {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pip::before {
  content: '';
  width: 65%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: var(--pip-color);
  display: block;
}

.pip.pip-blank::before { display: none; }

.hand-tile .pip::before  { width: 60%; }
.board-tile .pip::before { width: 55%; }

/* ── My Hand Area ────────────────────────────────────────── */
#my-hand-area {
  position: absolute;
  bottom: 54px; /* espacio para el HUD en desktop */
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 12px 20px;
  background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
  border-radius: 0;
  z-index: 20;
  overflow-x: auto;
  max-width: 90%;
  scrollbar-width: none;
}

#my-hand-area::-webkit-scrollbar { display: none; }

/* ── Side selection buttons ──────────────────────────────── */
#side-selector {
  position: absolute;
  bottom: 165px; /* hand(54px) + HUD(54px) + margen */
  left: 50%;
  transform: translateX(-50%);
  display: none;
  gap: 1rem;
  z-index: 30;
}

#side-selector.visible { display: flex; }

.side-btn {
  padding: 0.5rem 1.5rem;
  border-radius: 10px;
  border: 2px solid var(--gold);
  background: rgba(0,0,0,0.7);
  color: var(--gold);
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
}

.side-btn:hover { background: var(--gold); color: #111; }

/* ── Game HUD (barra inferior, dentro de #game-table, cubierta por overlays) */
#game-hud {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  transform: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 10px 24px;
  height: 54px;
  box-sizing: border-box;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255,255,255,0.08);
  border-radius: 0;
  z-index: 20;
}

.hud-pot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--gold);
}

.hud-turn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

#btn-pass {
  padding: 0.4rem 1.2rem;
  border-radius: 20px;
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.4);
  color: #f87171;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

#btn-pass:hover { background: rgba(239,68,68,0.3); }
#btn-pass:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Your Turn Banner ────────────────────────────────────── */
#your-turn-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: linear-gradient(135deg, #fde047, #fb923c);
  color: #111;
  padding: 1rem 2.5rem;
  border-radius: 20px;
  font-size: 1.4rem;
  font-weight: 800;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  box-shadow: 0 8px 32px rgba(253,224,71,0.5);
  text-align: center;
  white-space: nowrap;
}

#your-turn-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ── Game Over Screen ────────────────────────────────────── */
#game-over-screen {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}

#game-over-screen.show {
  opacity: 1;
  pointer-events: all;
}

.game-over-card {
  background: #1a1d27;
  border: 1px solid rgba(253,224,71,0.3);
  border-radius: 24px;
  padding: 2.5rem;
  text-align: center;
  max-width: 420px;
  width: 95%;
  animation: gameOverReveal 0.5s ease forwards;
}

@keyframes gameOverReveal {
  from { transform: scale(0.8) translateY(30px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.game-over-emoji { font-size: 4rem; margin-bottom: 0.5rem; }
.game-over-title { font-size: 2rem; font-weight: 800; margin-bottom: 0.5rem; }
.game-over-title.win { background: linear-gradient(135deg, #fde047, #fb923c); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.game-over-title.lose { color: #9ca3af; }

.game-over-payout {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  margin: 1rem 0;
}

.game-over-detail { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 0.3rem; }

/* ── Event Log ───────────────────────────────────────────── */
#event-log {
  position: absolute;
  bottom: 170px; /* encima del hand area */
  right: 8px;
  width: auto;
  max-width: 210px;
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  scrollbar-width: none;
  z-index: 15;
}

#event-log::-webkit-scrollbar { display: none; }

.log-entry {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.85);
  background: none;
  backdrop-filter: none;
  border: none;
  border-radius: 0;
  padding: 1px 0;
  text-align: right;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.95), 0 0 6px rgba(0,0,0,0.8);
  animation: logFadeIn 0.3s ease;
  white-space: nowrap;
}

@keyframes logFadeIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Wait Room ───────────────────────────────────────────── */
#wait-room {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  z-index: 50;
}

.wait-room-card {
  background: #1a1d27;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.5rem;
  text-align: center;
  width: 420px;
  max-width: 95vw;
}

.wait-room-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.wait-room-code {
  font-size: 2rem;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 4px;
  margin: 1rem 0;
  font-family: monospace;
}

.wait-players-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1.5rem 0;
  text-align: left;
}

.wait-player-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  font-size: 0.9rem;
}

.wait-player-item img {
  width: 32px; height: 32px;
  border-radius: 7px;
  object-fit: cover;
}

.wait-empty-slot {
  border: 1px dashed rgba(255,255,255,0.15);
  color: var(--text-dim);
  justify-content: center;
}

.pulse-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #4ade80;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.85); }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — Mobile-first adaptation for Dominó
   ══════════════════════════════════════════════════════════ */

/* ── Tablet (≤900px) ─────────────────────────────────────── */
@media (max-width: 900px) {
  #domino-root {
    min-height: 100dvh;
    border-radius: 0;
  }

  #domino-lobby {
    padding: 1.25rem;
  }

  .lobby-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
  }

  .lobby-header h1 {
    font-size: 1.6rem;
  }

  .lobby-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.6rem;
  }

  .lobby-actions .btn-domino {
    flex: 1;
    min-width: 100px;
    text-align: center;
    padding: 0.7rem 0.8rem;
    font-size: 0.9rem;
  }
}

/* ── Mobile (≤640px) ─────────────────────────────────────── */
@media (max-width: 640px) {

  /* ── LOBBY ───────────────────────────────────────────────── */
  #domino-lobby {
    padding: 1rem;
  }

  .lobby-header h1 {
    font-size: 1.4rem;
  }

  .lobby-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  /* Button that goes back (icon-only) takes its own row */
  .lobby-actions .btn-domino:last-child {
    grid-column: 1 / -1;
  }

  .room-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
  }

  .room-row-left {
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
  }
  .room-divider {
    display: none;
  }

  .room-title-group {
    min-width: 0;
  }

  .room-title {
    font-size: 0.88rem;
  }

  .room-value {
    font-size: 0.88rem;
    justify-content: flex-start;
  }

  .room-badge-join,
  .room-badge-full {
    width: 100%;
    text-align: center;
    padding: 0.55rem 0;
    font-size: 0.9rem;
    border-radius: 10px;
  }

  /* ── GAME CONTAINER ──────────────────────────────────────── */
  #view-domino {
    margin-bottom: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    min-height: 100dvh !important;
  }

  #domino-game {
    height: 100dvh;
  }

  #game-table {
    /* No extra border div on mobile – handled by ::before */
  }

  /* Thinner wooden border on mobile */
  #game-table::before {
    inset: 4px;
    border-width: 3px;
    border-radius: 12px;
  }

  /* ── HUD ─────────────────────────────────────────────────── */
  #game-hud {
    top: 10px;
    left: 8px;
    right: 8px;
    transform: none;
    padding: 6px 10px;
    border-radius: 14px;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: center;
    font-size: 0.8rem;
  }

  /* Pot amount – keep it visible and compact */
  #game-hud > div:first-child {
    font-size: 0.85rem;
  }

  /* Turn info text */
  #hud-turn-info {
    font-size: 0.75rem;
    text-align: center;
    flex: 1;
    min-width: 80px;
  }

  /* Pass button – bigger touch target */
  #btn-pass {
    padding: 0.45rem 1rem;
    font-size: 0.8rem;
    border-radius: 16px;
    min-height: 38px;
  }

  /* Exit button */
  #game-hud > button:last-child {
    padding: 0.45rem 0.7rem;
    font-size: 0.75rem;
    min-height: 38px;
  }

  /* ── PLAYER CORNERS ──────────────────────────────────────── */
  .player-corner {
    padding: 6px 8px;
    min-width: 68px;
    gap: 4px;
    border-radius: 12px;
  }

  .corner-avatar {
    width: 32px;
    height: 32px;
    border-radius: 7px;
  }

  .corner-name {
    font-size: 0.68rem;
    max-width: 64px;
  }

  .corner-tiles-count {
    font-size: 0.62rem;
  }

  /* Seat positions – tighter to edges, clear of HUD */
  .player-corner.seat-0 {
    /* Me – bottom center, above hand */
    bottom: 108px;
    left: 50%;
    transform: translateX(-50%);
  }

  .player-corner.seat-1 {
    /* Opponent top */
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
  }

  .player-corner.seat-2 {
    /* Left */
    top: 50%;
    left: 4px;
    transform: translateY(-50%);
  }

  .player-corner.seat-3 {
    /* Right */
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
  }

  /* ── MY HAND AREA ────────────────────────────────────────── */
  #my-hand-area {
    padding: 8px 12px 12px;
    gap: 5px;
    left: 0;
    width: 100vw;
    transform: none;
    justify-content: flex-start;
    box-sizing: border-box;
    /* Slight scroll hint */
    padding-right: 20px;
  }

  /* Hand tiles – larger for touch */
  .domino-tile.hand-tile {
    width: 40px;
    height: 78px;
    flex-shrink: 0;
  }

  .domino-tile.hand-tile:hover {
    transform: translateY(-10px) scale(1.04);
  }

  .domino-tile.hand-tile.selected {
    transform: translateY(-16px) scale(1.06);
  }

  /* Board tiles slightly smaller */
  .domino-tile.board-tile {
    width: 36px;
    height: 19px;
  }

  .domino-tile.board-tile.vertical {
    width: 19px;
    height: 36px;
  }

  /* ── SIDE SELECTOR ───────────────────────────────────────── */
  #side-selector {
    bottom: 100px;
    gap: 0.6rem;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
  }

  .side-btn {
    padding: 0.6rem 1.4rem;
    font-size: 0.9rem;
    min-height: 44px;
    border-radius: 12px;
  }

  /* ── EVENT LOG ───────────────────────────────────────────── */
  #event-log {
    /* Move to top-right, below HUD */
    bottom: auto;
    top: 72px;
    right: 8px;
    width: 160px;
    max-height: 120px;
  }

  .log-entry {
    font-size: 0.65rem;
    padding: 3px 6px;
  }

  /* ── YOUR TURN BANNER ────────────────────────────────────── */
  #your-turn-banner {
    font-size: 1.1rem;
    padding: 0.8rem 1.8rem;
    border-radius: 16px;
  }

  /* ── WAIT ROOM ───────────────────────────────────────────── */
  .wait-room-card {
    padding: 1.5rem;
    width: calc(100vw - 2rem);
    max-width: 100%;
    border-radius: 16px;
  }

  .wait-room-card h2 {
    font-size: 1.2rem;
  }

  .wait-room-code {
    font-size: 1.6rem;
    letter-spacing: 3px;
    margin: 0.75rem 0;
  }

  .wait-players-list {
    margin: 1rem 0;
  }

  /* ── GAME OVER CARD ──────────────────────────────────────── */
  .game-over-card {
    padding: 1.75rem 1.25rem;
    border-radius: 18px;
    width: calc(100vw - 2rem);
    max-width: 100%;
  }

  .game-over-emoji { font-size: 3rem; }
  .game-over-title { font-size: 1.6rem; }
  .game-over-payout { font-size: 1.25rem; }

  /* ── MODALS ──────────────────────────────────────────────── */
  .domino-modal {
    width: calc(100vw - 1.5rem);
    padding: 1.5rem;
    border-radius: 16px;
  }

  .domino-modal h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
  }

  .modal-actions {
    flex-direction: column;
    gap: 0.6rem;
  }

  .modal-actions .btn-domino {
    width: 100%;
    padding: 0.8rem;
    font-size: 0.95rem;
    min-height: 46px;
  }

  .form-group input,
  .form-group select {
    font-size: 1rem; /* prevents zoom on iOS */
    min-height: 46px;
  }

  /* ── PROFILE CORNER IN LOBBY ─────────────────────────────── */
  #domino-lobby .lobby-header p {
    font-size: 0.8rem;
  }
}

/* ── Extra-small (≤380px – small phones) ─────────────────── */
@media (max-width: 380px) {
  .domino-tile.hand-tile {
    width: 35px;
    height: 68px;
  }

  .player-corner {
    min-width: 58px;
    padding: 4px 6px;
  }

  .corner-avatar {
    width: 26px;
    height: 26px;
  }

  .corner-name {
    font-size: 0.6rem;
    max-width: 52px;
  }

  #game-hud {
    padding: 5px 8px;
    font-size: 0.75rem;
  }

  .lobby-header h1 {
    font-size: 1.2rem;
  }
}

/* ── Disconnect Warning Countdown ────────────────────────── */
.dc-warning-box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(20, 15, 5, 0.92);
  border: 2px solid #fbbf24;
  border-radius: 16px;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: #f3f4f6;
  z-index: 50;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 30px rgba(251,191,36,0.25), 0 4px 20px rgba(0,0,0,0.6);
  animation: dcWarningPulse 1.5s ease-in-out infinite;
  pointer-events: none;
  white-space: nowrap;
}

/* Stack multiple warnings vertically */
.dc-warning-box + .dc-warning-box {
  margin-top: 60px;
}

.dc-warning-box.dc-urgent {
  border-color: #ef4444;
  box-shadow: 0 0 30px rgba(239,68,68,0.4), 0 4px 20px rgba(0,0,0,0.6);
  animation: dcUrgentPulse 0.6s ease-in-out infinite;
}

.dc-warning-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.dc-warning-name {
  font-weight: 700;
  color: #fbbf24;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dc-warning-box.dc-urgent .dc-warning-name {
  color: #f87171;
}

.dc-warning-text {
  color: #9ca3af;
  font-size: 0.82rem;
}

.dc-warning-timer {
  background: rgba(251,191,36,0.2);
  color: #fbbf24;
  font-weight: 800;
  font-size: 1rem;
  padding: 0.2rem 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(251,191,36,0.4);
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: center;
  transition: background 0.3s, color 0.3s;
}

.dc-warning-box.dc-urgent .dc-warning-timer {
  background: rgba(239,68,68,0.25);
  color: #f87171;
  border-color: rgba(239,68,68,0.5);
}

@keyframes dcWarningPulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.75; }
}

@keyframes dcUrgentPulse {
  0%,100% { box-shadow: 0 0 30px rgba(239,68,68,0.4); }
  50%      { box-shadow: 0 0 50px rgba(239,68,68,0.7); }
}

/* Timer badge inside player corner */
.corner-dc-timer {
  font-size: 0.65rem;
  font-weight: 800;
  color: #fbbf24;
  background: rgba(251,191,36,0.15);
  border: 1px solid rgba(251,191,36,0.35);
  border-radius: 6px;
  padding: 1px 5px;
  font-variant-numeric: tabular-nums;
  animation: dcWarningPulse 1s ease-in-out infinite;
}

/* Dimmed corner for disconnected player */
.player-corner.player-disconnected {
  opacity: 0.75;
  border-color: #ef4444;
  box-shadow: 0 0 14px rgba(239,68,68,0.25);
}

/* ── Landscape mobile (short height) ─────────────────────── */
@media (max-height: 500px) and (max-width: 900px) {
  #game-hud {
    top: 6px;
    padding: 4px 10px;
    font-size: 0.72rem;
  }

  #btn-pass, #game-hud > button:last-child {
    padding: 0.3rem 0.7rem;
    min-height: 32px;
    font-size: 0.72rem;
  }

  .domino-tile.hand-tile {
    width: 32px;
    height: 62px;
  }

  #my-hand-area {
    padding: 5px 10px 8px;
    gap: 4px;
  }

  .player-corner {
    padding: 4px;
    min-width: 60px;
  }

  .player-corner.seat-0 {
    bottom: 78px;
  }

  .player-corner.seat-1 {
    top: 52px;
  }

  #event-log {
    top: 54px;
    max-height: 90px;
    width: 140px;
  }

  #side-selector {
    bottom: 74px;
  }
}


/* MOBILE REDESIGN FROM MOCKUP */
.domino-mobile-bar { display: none; }

@media (max-width: 1024px) {
  #game-hud { display: none !important; }

  #game-table {
    position: relative !important;
    flex: 1 !important;
  }

  #game-table::before {
    inset: 0 !important;
    border-radius: 0 !important;
    border-width: 4px !important;
  }

  #domino-game {
    flex-direction: column;
  }

  .domino-mobile-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #11141c;
    height: 60px;
    padding: 0 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    z-index: 50;
  }
  
  .d-mob-exit {
    background: #d32f2f;
    color: white;
    border: none;
    border-radius: 8px;
    width: 45px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
  }
  
  .d-mob-status {
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    flex: 1;
    text-align: center;
  }
  
  .d-mob-chat {
    background: transparent;
    color: #fde047;
    border: none;
    position: relative;
    font-size: 2rem;
  }
  
  .d-mob-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f44336;
    color: white;
    font-size: 0.75rem;
    border-radius: 50%;
    padding: 2px 6px;
    font-weight: bold;
  }
  
  .btn-pass-mobile {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.95);
    color: white;
    border: 2px solid #ef4444;
    padding: 0.8rem 2.5rem;
    border-radius: 30px;
    font-weight: 700;
    font-size: 1.2rem;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  }
  .btn-pass-mobile:disabled {
    display: none !important;
  }

  #my-hand-area {
    bottom: 10px !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    justify-content: center;
    background: transparent !important;
  }

  .player-corner {
    position: absolute !important;
    background: transparent !important;
    backdrop-filter: none !important;
    border: none !important;
    min-width: 0 !important;
    padding: 0 !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
  }

  .corner-avatar {
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    border: 2px solid var(--gold) !important;
  }
  
  .corner-name {
    font-size: 1.1rem !important;
    max-width: 120px !important;
    font-weight: 800 !important;
    color: white !important;
  }
  
  .corner-tiles-count {
    font-size: 1.1rem !important;
    color: var(--gold) !important;
  }

  .player-corner.seat-0 {
    bottom: 90px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
  }

  .player-corner.seat-1 {
    top: 25px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
  }

  .player-corner.seat-2 {
    top: 50% !important;
    left: -50px !important;
    transform: translateY(-50%) rotate(-90deg) !important;
  }

  .player-corner.seat-3 {
    top: 50% !important;
    right: -50px !important;
    left: auto !important;
    transform: translateY(-50%) rotate(-90deg) !important;
  }

  #event-log {
    bottom: 80px !important;
    right: 15px !important;
    top: auto !important;
    text-align: right !important;
    width: 160px !important;
    max-height: 120px !important;
    background: transparent !important;
  }
  .event-log-entry {
    background: transparent !important;
    color: white !important;
    font-weight: 600 !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    border: none !important;
    justify-content: flex-end !important;
  }

  /* Hide subnav */
  .sub-nav { display: none !important; }
}
