.mobile-app {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-header {
  text-align: center;
  padding: 1rem 1rem 0.5rem;
}

.mobile-screen {
  margin: 0.75rem 1rem 1.5rem;
}

.mobile-screen.hidden {
  display: none !important;
}

.btn-block {
  display: block;
  width: 100%;
  margin: 0.5rem 0;
  padding: 0.85rem 1rem;
  font-size: 1rem;
}

.btn-small {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.join-divider {
  text-align: center;
  color: #8b949e;
  margin: 1.25rem 0 0.75rem;
  font-size: 0.9rem;
}

.room-list-status {
  font-size: 0.85rem;
  color: #8b949e;
  margin: 0.5rem 0 0.75rem;
  text-align: center;
}

.room-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem;
  max-height: 14rem;
  overflow-y: auto;
}

.room-list-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.room-list-item:active {
  background: rgba(63, 185, 80, 0.15);
  border-color: rgba(63, 185, 80, 0.45);
}

.room-list-item-host {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

.room-list-item-meta {
  font-size: 0.8rem;
  color: #8b949e;
}

.room-list-refresh {
  display: block;
  margin: 0 auto 0.25rem;
}

.join-code-input {
  width: 100%;
  font-size: 1.4rem;
  letter-spacing: 0.2em;
  text-align: center;
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 0.35rem;
}

.mobile-footer-hint {
  text-align: center;
  margin-top: 1.5rem;
}

.leaderboard-panel {
  margin-bottom: 1.25rem;
  padding: 0.85rem;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 8px;
}

.leaderboard-heading {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  text-align: center;
  font-family: var(--pc-font-display, Poppins, sans-serif);
  font-weight: 800;
}

.leaderboard-subtitle {
  text-align: center;
  margin: 0 0 0.65rem;
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 11rem;
  overflow-y: auto;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 1.75rem 1fr auto auto;
  gap: 0.35rem 0.5rem;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.85rem;
}

.leaderboard-rank {
  color: #8b949e;
  font-variant-numeric: tabular-nums;
}

.leaderboard-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-time {
  font-family: ui-monospace, monospace;
  font-weight: 700;
  color: #3fb950;
}

.leaderboard-speed {
  font-size: 0.7rem;
  color: #8b949e;
}

.leaderboard-empty {
  text-align: center;
  color: #8b949e;
  font-size: 0.85rem;
  padding: 0.5rem 0;
}

.heat-time {
  font-family: ui-monospace, monospace;
  font-weight: 600;
}

.lb-badge {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(63, 185, 80, 0.2);
  color: #3fb950;
  vertical-align: middle;
}

.lb-badge-personal {
  background: rgba(210, 168, 255, 0.15);
  color: #d2a8ff;
}

.heat-result-row {
  margin: 0.25rem 0;
}

.shop-bridge {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.shop-bridge-powered {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  color: #8b949e;
  letter-spacing: 0.03em;
}

.shop-bridge-powered strong {
  color: #f0c040;
  font-weight: 700;
}

.shop-bridge-cta {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 600;
  color: #3fb950;
  text-decoration: none;
  padding: 0.35rem 0.5rem;
}

.shop-bridge-cta:hover,
.shop-bridge-cta:active {
  text-decoration: underline;
}

.overlay-wait-host {
  margin: 0.75rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: #f0c040;
  line-height: 1.45;
}

.overlay-wait-host--host {
  color: #3fb950;
}

.overlay-wait-host strong {
  color: #e6edf3;
}

.color-picker-field {
  border: none;
  margin: 1rem 0;
  padding: 0;
}

.color-picker-field legend {
  font-size: 0.9rem;
  color: #8b949e;
  margin-bottom: 0.5rem;
}

.color-options {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.color-option {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.color-option.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.room-code-box {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  text-align: center;
}

.room-code-label {
  display: block;
  font-size: 0.8rem;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.room-code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.room-code-value {
  font-size: 2rem;
  letter-spacing: 0.15em;
  font-family: ui-monospace, monospace;
}

.lobby-players {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.lobby-players li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.95rem;
}

.lobby-players .swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.lobby-players .host-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: #d2a8ff;
  margin-left: auto;
}

.lobby-actions {
  margin-top: 1rem;
}

.game-layout {
  display: flex;
  flex-direction: column;
}

.game-play-column {
  min-width: 0;
}

.game-canvas-wrap {
  width: 100%;
  background: #0d1117;
  border-radius: 8px;
  overflow: hidden;
  line-height: 0;
}

.game-canvas-wrap canvas {
  width: 100%;
  height: auto;
  display: block;
}

.hud-mobile {
  padding: 0.65rem 0.25rem;
  font-size: 0.85rem;
  line-height: 1.45;
}

.touch-controls {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 0.75rem;
  padding: 0.5rem 0 1rem;
  touch-action: manipulation;
}

.speed-btn {
  min-height: 4.5rem;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: #e6edf3;
  font-size: 1.1rem;
  font-weight: 600;
}

.turn-btn {
  min-height: 4.5rem;
  border-radius: 12px;
  border: none;
  background: linear-gradient(180deg, #3fb950 0%, #238636 100%);
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.turn-btn:active,
.turn-btn.turning {
  background: linear-gradient(180deg, #56d364 0%, #2ea043 100%);
  transform: scale(0.98);
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.overlay-btn {
  width: 100%;
}

.reconnect-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0));
  background: rgba(22, 27, 34, 0.96);
  border-top: 1px solid #30363d;
  text-align: center;
}

.reconnect-banner.hidden {
  display: none !important;
}

.reconnect-banner p {
  margin: 0 0 0.75rem;
  color: #f0c040;
  font-size: 0.95rem;
}

.reconnect-dismiss {
  display: block;
  margin: 0.5rem auto 0;
  font-size: 0.8rem;
}

.lobby-players .offline-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: #8b949e;
  margin-left: auto;
}

.lobby-players .ready-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: #3fb950;
  margin-left: auto;
}

.lobby-players .not-ready-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: #8b949e;
  margin-left: 0.35rem;
}

.lobby-players .kick-btn {
  margin-left: auto;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  background: transparent;
  border: 1px solid rgba(255, 100, 100, 0.45);
  color: #ff7b72;
}

.lobby-host-teams label {
  display: block;
  margin-bottom: 0.65rem;
  font-size: 0.9rem;
}

.lobby-host-teams input {
  width: 100%;
  margin-top: 0.25rem;
}

.lobby-my-setup {
  margin: 1rem 0;
  padding: 0.85rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.lobby-my-setup h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.lobby-field-label {
  display: block;
  font-size: 0.85rem;
  color: #8b949e;
  margin-bottom: 0.35rem;
}

.lobby-team-btns {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.lobby-team-btn {
  flex: 1;
  padding: 0.65rem 0.5rem;
  font-size: 0.9rem;
}

.lobby-team-btn.selected {
  border-color: #3fb950;
  box-shadow: 0 0 0 2px rgba(63, 185, 80, 0.35);
}

.lobby-team-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#btn-lobby-ready.ready-active {
  background: linear-gradient(180deg, #56d364 0%, #2ea043 100%);
}

.lobby-speed-picker {
  margin-bottom: 0.85rem;
}

.lobby-speed-btn {
  width: 100%;
  min-height: 2.75rem;
}

.color-option.taken {
  opacity: 0.25;
  cursor: not-allowed;
  position: relative;
}

.color-option.taken::after {
  content: '✕';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  font-weight: bold;
}

.lobby-leave-btn {
  margin-top: 1rem;
}

.lobby-ready-status {
  margin: -0.35rem 0 0.5rem;
}

.lobby-players-heading {
  margin-bottom: 0.25rem;
}

/* Gra w poziomie: tor po lewej, SKRĘĆ po prawej */
@media (orientation: landscape) {
  .mobile-app:has(#screen-game:not(.hidden)) {
    max-width: none;
  }

  .mobile-app:has(#screen-game:not(.hidden)) .mobile-header {
    display: none;
  }

  #screen-game {
    margin: 0;
    min-height: 100dvh;
    min-height: 100vh;
  }

  #screen-game .game-layout {
    flex-direction: row;
    align-items: stretch;
    gap: 0.5rem;
    min-height: 100dvh;
    min-height: 100vh;
    padding:
      env(safe-area-inset-top, 0)
      env(safe-area-inset-right, 0)
      env(safe-area-inset-bottom, 0)
      env(safe-area-inset-left, 0);
  }

  #screen-game .game-play-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
  }

  #screen-game .game-canvas-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    min-height: 0;
  }

  #screen-game .game-canvas-wrap canvas {
    width: 100%;
    height: auto;
    max-height: 100%;
    object-fit: contain;
  }

  #screen-game .hud-mobile {
    flex-shrink: 0;
    padding: 0.35rem 0.5rem;
    font-size: 0.75rem;
  }

  #screen-game .touch-controls {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: clamp(7.5rem, 22vw, 9.5rem);
    padding: 0.5rem 0.5rem 0.5rem 0;
    justify-content: center;
    gap: 0.5rem;
  }

  #screen-game .speed-btn {
    min-height: 2.75rem;
    font-size: 0.95rem;
  }

  #screen-game .turn-btn {
    flex: 1;
    min-height: 6rem;
    font-size: 1.15rem;
  }
}

.playclub-home-link {
  display: inline-block;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--pc-green, #39ff14);
  text-decoration: none;
}

.playclub-home-link.hidden {
  display: none;
}

.playclub-home-link:hover {
  text-decoration: underline;
}
