.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;
}

.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;
}

.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.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  padding: 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%;
}

/* 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;
  }
}
