/* Russian Lotto — retro casino theme, mobile-first */

:root {
  --felt: #1a5c3a;
  --felt-dark: #0f3d26;
  --wood: #5c3d1e;
  --wood-light: #8b5a2b;
  --gold: #d4af37;
  --gold-glow: #f0d060;
  --cream: #f5e6c8;
  --chip: #c41e3a;
  --text: #f8f4e8;
  --text-muted: #c8c0a8;
  --danger: #e74c3c;
  --success: #2ecc71;
  --shadow: rgba(0, 0, 0, 0.45);
  --radius: 8px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background-color: var(--felt-dark);
  background-image:
    url('../img/felt-bg.png'),
    radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 100%);
  background-size: cover, auto;
  background-position: center center, center center;
  background-repeat: no-repeat, no-repeat;
  background-attachment: fixed, fixed;
}

#app { min-height: 100vh; }

.screen {
  display: none;
  min-height: 100vh;
  padding: 1rem;
}
.screen.active { display: block; }

.panel {
  background: linear-gradient(145deg, var(--wood-light), var(--wood));
  border: 3px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px var(--shadow);
  padding: 1.25rem;
}

.logo-img {
  display: block;
  height: 120px;
  max-width: 80%;
  width: auto;
  margin: 0 auto 1rem;
  object-fit: contain;
  border: none;
  background: transparent;
  opacity: 0.85;
}
.logo-img.small { height: 48px; max-width: 120px; margin: 0; }

.logo-placeholder {
  height: 120px;
  max-width: 80%;
  margin: 0 auto 1rem;
  background: linear-gradient(135deg, var(--gold) 0%, var(--wood) 100%);
  border-radius: var(--radius);
  border: 2px dashed var(--cream);
  opacity: 0.85;
}
.logo-placeholder.small { height: 48px; max-width: 120px; margin: 0; }

h1, h2, h3 { margin: 0 0 0.75rem; color: var(--gold-glow); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.2rem;
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  background: var(--wood);
  color: var(--cream);
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(180deg, var(--gold-glow), var(--gold));
  color: var(--felt-dark);
  font-weight: 600;
}
.btn.small { padding: 0.35rem 0.75rem; font-size: 0.85rem; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--gold);
  border-radius: 50%;
  width: 2.25rem;
  height: 2.25rem;
  color: var(--cream);
  cursor: pointer;
  font-size: 1rem;
}

input, select {
  width: 100%;
  padding: 0.5rem;
  border: 2px solid var(--wood-light);
  border-radius: var(--radius);
  background: var(--cream);
  color: var(--felt-dark);
  font-size: 1rem;
}

label { display: block; margin-bottom: 0.75rem; }
label span { display: block; margin-bottom: 0.25rem; font-size: 0.9rem; color: var(--text-muted); }

.hidden { display: none !important; }

.message {
  margin-top: 0.75rem;
  padding: 0.5rem;
  border-radius: var(--radius);
  text-align: center;
  min-height: 1.5rem;
}
.message.error { background: rgba(231, 76, 60, 0.25); color: #ffb3aa; }
.message.success { background: rgba(46, 204, 113, 0.2); color: #a8f0c8; }

/* Auth */
.auth-panel { max-width: 420px; margin: 2rem auto; text-align: center; }
.lang-row { display: flex; gap: 0.5rem; justify-content: center; margin-bottom: 1rem; }
.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.tab {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--gold);
  background: var(--felt-dark);
  color: var(--cream);
  cursor: pointer;
  border-radius: var(--radius);
}
.tab.active { background: var(--gold); color: var(--felt-dark); font-weight: 600; }
.auth-form { text-align: left; }

/* Top bar */
.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--wood);
  border-bottom: 2px solid var(--gold);
  margin: -1rem -1rem 1rem;
}
.user-info { flex: 1; min-width: 0; }
#lobby-screen .top-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
#lobby-screen .user-info {
  flex: unset;
  justify-self: start;
}
#lobby-screen .top-bar-title {
  justify-self: center;
  text-align: center;
}
#lobby-screen .lang-row {
  justify-self: end;
  justify-content: flex-end;
  margin-bottom: 0;
}
.top-bar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold-glow);
  white-space: nowrap;
}
.coins::before { content: '🪙 '; }
html.has-chip-icon .coins::before {
  content: '';
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  margin-right: 0.15em;
  vertical-align: -0.2em;
  background: url('../img/chip.png') center / contain no-repeat;
}
.coins { color: var(--gold-glow); font-weight: 700; }

/* Lobby */
.lobby-main { max-width: 960px; margin: 0 auto; }
.lobby-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.sub-panel {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.sub-panel label { max-width: 240px; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th, .data-table td {
  padding: 0.5rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  text-align: left;
}
.data-table th { color: var(--gold); }
.data-table tr.room-row-current td { background: rgba(212, 175, 55, 0.12); }
.room-badge {
  font-size: 0.8rem;
  color: var(--gold-glow);
  font-weight: 600;
  white-space: nowrap;
}
.lobby-actions .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.join-room-panel { max-width: 22rem; width: 100%; }
.join-room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.join-room-header h3 { margin: 0; }
.join-room-hint { margin: 0.75rem 0 0.5rem; color: var(--text-muted); }
.join-room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}
.join-room-actions .btn { flex: 1; min-width: 6rem; }
.card-choice {
  display: flex;
  gap: 0.75rem;
}
.card-choice-btn {
  flex: 1;
  min-height: 3.25rem;
  padding: 0.75rem 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  background: var(--felt-dark);
  color: var(--cream);
  cursor: pointer;
  touch-action: manipulation;
}
.card-choice-btn.selected {
  background: var(--gold);
  color: var(--felt-dark);
}
.card-choice-btn:focus-visible {
  outline: 2px solid var(--gold-glow);
  outline-offset: 2px;
}

.players-list { list-style: none; padding: 0; margin: 0; }
.players-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 0.95rem;
}
.players-list li:last-child { border-bottom: none; }

/* Collapsible players list (room + in-game) */
.players-dropdown {
  margin-bottom: 0.75rem;
  border: 1px solid rgba(212, 175, 55, 0.45);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.players-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  touch-action: manipulation;
  font-weight: 600;
  color: var(--gold-glow);
}
.players-dropdown-toggle::-webkit-details-marker { display: none; }
.players-dropdown-toggle::after {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  margin-left: auto;
  border-right: 2px solid var(--gold);
  border-bottom: 2px solid var(--gold);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.players-dropdown[open] .players-dropdown-toggle::after {
  transform: rotate(-135deg);
  margin-top: 0.2rem;
}
.players-dropdown-label { flex: 1; }
.players-dropdown-badge {
  min-width: 1.5rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--gold);
  color: var(--felt-dark);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}
.players-dropdown-body {
  padding: 0 0.85rem 0.65rem;
  border-top: 1px solid rgba(212, 175, 55, 0.2);
}

.room-panel { padding: 0.85rem; }
.room-panel-head { margin-bottom: 0.65rem; }
.room-panel-title { margin-bottom: 0.5rem; font-size: 1.05rem; }
.room-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0;
}
.room-meta-item {
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
}
.room-meta-item dt {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.room-meta-item dd {
  margin: 0.15rem 0 0;
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.room-actions .btn { flex: 1; min-width: 0; }

.status-online { color: var(--success); }
.status-disconnected { color: var(--danger); }
.status-removed { color: var(--text-muted); font-style: italic; }

/* Game */
.game-layout {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-width: 1100px;
  margin: 0 auto;
}
.game-main { min-width: 0; }
.game-top-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  flex: 1;
  min-width: 0;
}
.game-top-stat {
  font-size: 0.82rem;
  line-height: 1.3;
}
.game-players-dropdown { margin-bottom: 0.5rem; }
.sound-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.sound-volume-slider {
  width: 4.5rem;
  height: 0.35rem;
  margin: 0;
  padding: 0;
  accent-color: var(--gold);
  cursor: pointer;
}

.game-top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.game-top { font-size: 0.9rem; align-items: flex-start; }

.win-chance {
  padding: 0.5rem 0.75rem;
  background: rgba(0,0,0,0.25);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}
.win-chance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}
.win-chance-track {
  height: 0.65rem;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  overflow: hidden;
}
.win-chance-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: rgb(139, 0, 0);
  transition: width 0.35s ease, background-color 0.35s ease;
}

.slot-machine {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 1rem 0;
}
.slot-window {
  width: 4.5rem;
  height: 4.5rem;
  background: var(--cream);
  border: 3px solid var(--gold);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.slot-num {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--felt-dark);
}
.slot-window.spinning .slot-num {
  animation: slotSpin 0.08s linear infinite;
}
.slot-window.spinning.decel .slot-num {
  animation: none;
}
.slot-window.reveal .slot-num {
  animation: goldPulse 0.5s ease;
}
@keyframes slotSpin {
  0% { transform: translateY(-70%); opacity: 0.35; }
  100% { transform: translateY(70%); opacity: 0.35; }
}
@keyframes goldPulse {
  0%, 100% { color: var(--felt-dark); }
  50% { color: var(--gold); text-shadow: 0 0 12px var(--gold-glow); }
}

/* AFK turn countdown (in-game drawer) */
.afk-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  margin: 0.75rem 0 0.5rem;
}
.afk-strikes {
  display: flex;
  gap: 0.5rem;
}
.afk-strike {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: rgba(0, 0, 0, 0.15);
  transition: background 0.25s, box-shadow 0.25s, transform 0.2s;
}
.afk-strike.active {
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold-glow);
  transform: scale(1.08);
}
.afk-strike.pending {
  opacity: 0.45;
}
.afk-countdown-ring {
  position: relative;
  width: 4.5rem;
  height: 4.5rem;
}
.afk-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.afk-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 6;
}
.afk-ring-progress {
  fill: none;
  stroke: var(--gold);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 263.89;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.2s linear, stroke 0.3s;
}
.afk-timer.phase-danger .afk-ring-progress,
.lobby-host-timer.phase-danger .afk-ring-progress {
  stroke: #e74c3c;
}
.lobby-host-timer {
  display: flex;
  justify-content: center;
  margin: 0.75rem 0;
}
.afk-countdown-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--cream);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.drawn-history {
  display: flex;
  width: 100%;
  height: 1.1rem;
  gap: 1px;
  margin-bottom: 0.75rem;
  border-radius: 2px;
  overflow: visible;
}
.drawn-segment {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: none;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.1);
  cursor: default;
  position: relative;
  outline: none;
}
.drawn-segment.drawn {
  background: var(--gold);
}
.drawn-segment.drawn.on-card {
  background: var(--chip);
}
.drawn-segment:focus-visible {
  outline: 2px solid var(--gold-glow);
  outline-offset: 1px;
  z-index: 1;
}
.drawn-segment::after {
  content: attr(data-num);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 5px);
  transform: translateX(-50%);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: var(--wood);
  border: 1px solid var(--gold);
  color: var(--cream);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
}
.drawn-segment:hover::after,
.drawn-segment:focus::after {
  opacity: 1;
  visibility: visible;
}
.drawn-chip {
  background: var(--chip);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
}

.cards-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  margin: 1rem 0;
  touch-action: pan-y;
}
.card-nav {
  background: var(--wood);
  border: 1px solid var(--gold);
  color: var(--cream);
  font-size: 1.5rem;
  width: 2rem;
  height: 3rem;
  cursor: pointer;
  border-radius: var(--radius);
}
.cards-stack {
  position: relative;
  width: 100%;
  max-width: 340px;
  min-height: 140px;
}
.lotto-card {
  direction: ltr;
  width: 100%;
  border-collapse: collapse;
  background: var(--cream);
  color: var(--felt-dark);
  font-size: 11px;
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  transition: transform 0.3s;
}
.lotto-card td {
  width: 11.11%;
  height: 2rem;
  text-align: center;
  border: 1px solid rgba(0,0,0,0.15);
  position: relative;
}
.lotto-card td.empty { background: rgba(0,0,0,0.06); }
.lotto-card td.marked::after {
  content: '';
  position: absolute;
  inset: 1px;
  background: url('../img/mark-cross.png') center / contain no-repeat;
  pointer-events: none;
  mix-blend-mode: multiply;
}
.lotto-card td.match-flash {
  animation: goldPulse 0.6s ease;
}
.lotto-card.stacked {
  position: absolute;
  top: 0;
  left: 0;
}

.turn-controls-active {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.turn-controls-active.hidden {
  display: none;
}

.turn-wait-msg {
  text-align: center;
  margin: 1rem auto;
  max-width: 320px;
  padding: 0.85rem 1rem;
  color: var(--text-muted, #9ca3af);
  font-size: 1.05rem;
  line-height: 1.4;
}

.turn-wait-msg.hidden {
  display: none;
}

#nudge-turn-btn {
  display: block;
  margin: 0 auto 1rem;
}

#nudge-turn-btn.hidden {
  display: none;
}

.draw-btn {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  font-size: 1.1rem;
  padding: 0.85rem;
}
.draw-btn.my-turn {
  animation: pulseBtn 1s ease infinite;
  box-shadow: 0 0 20px var(--gold-glow);
}
@keyframes pulseBtn {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.overlay .panel { max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; }

.rules-panel { background: #f5e6a8; color: #3d2b10; }
.rules-panel h2 { color: #5c3d1e; }
.rules-panel .icon-btn { color: var(--wood); }
.rules-content { font-size: 0.9rem; line-height: 1.5; }
.rules-content h4 { margin: 1rem 0 0.35rem; }

.apartment-panel { text-align: center; }
.apartment-timer {
  font-size: 2.5rem;
  color: var(--gold-glow);
  margin: 1rem 0;
}
.apartment-actions { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.apartment-actions .btn.selected { box-shadow: 0 0 0 2px var(--accent, #4a9eff); }

.game-over-panel { text-align: center; max-width: 560px; }
.game-over-chart-wrap {
  margin: 1rem 0;
  text-align: left;
}
.game-over-chart-wrap h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  text-align: center;
}
.game-over-chart {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  border-radius: var(--radius);
}
.win-chance-line-chart {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: center;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
}
.chart-legend li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.chart-legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.reconnect-panel { text-align: center; }
.session-superseded-panel {
  text-align: center;
  max-width: 420px;
  border-color: var(--danger, #c44);
}
.session-superseded-reason {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.session-superseded-wait {
  font-size: 0.95rem;
  opacity: 0.9;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 1rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--wood);
  border: 2px solid var(--gold);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  z-index: 200;
  max-width: 90%;
  text-align: center;
}

.admin-panel header { display: flex; justify-content: space-between; align-items: center; }
.admin-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.admin-row input { width: 100px; }
.admin-user-picker { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.75rem; }
.admin-user-search { width: 100%; max-width: 100%; }
.admin-filters { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; font-size: 0.85rem; }
.admin-filter { display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.admin-user-select {
  width: 100%;
  min-height: 10rem;
  font-family: inherit;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: var(--radius);
  padding: 0.35rem;
}
.admin-user-select option { padding: 0.25rem 0.35rem; }
.admin-user-info {
  margin: 0;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.85rem;
  line-height: 1.4;
}
.admin-actions { margin-top: 0.25rem; }
.logs-box {
  background: #111;
  color: #0f0;
  font-size: 0.75rem;
  max-height: 240px;
  overflow-y: auto;
  padding: 0.5rem;
  border-radius: var(--radius);
  white-space: pre-wrap;
}
.hint { font-size: 0.85rem; color: var(--text-muted); }

.lang-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; margin: 1rem 0; }
.lang-options button { width: 100%; }

/* Breakpoints */
@supports (padding: env(safe-area-inset-top)) {
  .screen {
    padding-left: calc(1rem + env(safe-area-inset-left));
    padding-right: calc(1rem + env(safe-area-inset-right));
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }
  .top-bar {
    margin-left: calc(-1rem - env(safe-area-inset-left));
    margin-right: calc(-1rem - env(safe-area-inset-right));
    padding-left: calc(0.75rem + env(safe-area-inset-left));
    padding-right: calc(0.75rem + env(safe-area-inset-right));
    padding-top: calc(0.65rem + env(safe-area-inset-top));
  }
  .toast {
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }
}

@media (max-width: 430px) {
  html { font-size: 15px; }
  .screen { padding-top: 0.5rem; }
  .lobby-actions .btn { flex: 1 1 calc(50% - 0.25rem); min-width: 0; }
  .lobby-actions .btn:first-child { flex-basis: 100%; }
  .data-table { font-size: 0.82rem; }
  .data-table th, .data-table td { padding: 0.4rem 0.35rem; }
  .slot-window { width: 4rem; height: 4rem; }
  .slot-num { font-size: 1.5rem; }
  .cards-stack { max-width: min(100%, 360px); }
  .lotto-card { font-size: 10px; }
  .lotto-card td { height: 1.85rem; }
  .draw-btn { max-width: 100%; }
  .room-panel { margin-bottom: 0.75rem; }
  .lobby-host-timer { margin-top: 0.5rem; }
}

@media (min-width: 768px) {
  .game-layout {
    display: grid;
    grid-template-columns: minmax(200px, 240px) 1fr;
    gap: 1rem;
    align-items: start;
  }
  .game-players-dropdown {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 0;
    position: sticky;
    top: 0.5rem;
  }
  .game-main {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }
  .lotto-card { font-size: 12px; }
  .lotto-card td { height: 2.25rem; }
  .cards-stack { max-width: 400px; }
}

@media (min-width: 1280px) {
  html { font-size: 17px; }
  .game-layout { grid-template-columns: 240px 1fr; }
  .cards-stack { max-width: 460px; }
}

@media (max-width: 280px) {
  .cards-container { overflow-x: auto; }
  .cards-stack { min-width: 280px; }
}
