/* ========================================
   Responsive Design
   ======================================== */

/* Landscape Orientation (Mobile) */
@media (max-height: 500px) and (orientation: landscape) {
  .tab-navigation {
    top: 15px;
    /* Increased from 5px to avoid notch/cutoff */
    padding: 3px 8px;
    min-width: 160px;
    gap: 4px;
  }

  .tab-button {
    padding: 6px 18px;
    font-size: 14px;
    min-width: 40px;
    border-radius: 20px;
  }

  #galleryTab,
  #settingsTab {
    margin-top: 0;
    padding-top: 70px;
  }

  .camera-controls {
    bottom: 8px;
  }

  /* Camera Controls Landscape Layout */
  #cameraTab .controls {
    width: auto !important;
    height: 100%;
    right: 0;
    left: auto;
    bottom: 0 !important;
    align-items: center;
    pointer-events: none;
  }

  #cameraTab .controls .controls_layout {
    flex-direction: column !important;
    width: auto !important;
    height: 100%;
    justify-content: flex-end !important;
    gap: 20px;
    padding-right: 25px;
    padding-bottom: 40px;
    pointer-events: auto;
  }

  /* Hide Logo/Beta in landscape */
  .logo-beta-container {
    display: none !important;
  }

  /* Reset flex for button containers */
  #cameraTab .controls_layout>div {
    flex: 0 0 auto !important;
    width: auto !important;
    padding: 0 !important;
  }

  .camera-switch-container {
    justify-content: center !important;
  }


  /* Banner adjustments for landscape to prevent overlap */
  .manner-mode-banner .banner-content,
  .startup-upgrade-banner .banner-content {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    gap: 12px;
  }

}

/* Very Small Landscape (iPhone SE横など) */
@media (max-height: 400px) and (orientation: landscape) {
  .tab-navigation {
    top: 10px;
    /* Increased from 3px */
    padding: 2px 6px;
    min-width: 120px;
    gap: 3px;
  }

  #galleryTab,
  #settingsTab {
    margin-top: 0;
    padding-top: 60px;
  }

  .camera-controls {
    bottom: 6px;
  }

  .settings-content {
    padding-top: 0;
  }
}

/* Mobile Base Styles */
@media (max-width: 700px) {
  body.front-page {
    display: block;
    overflow: hidden;
    margin: 0;
    padding: 0;
  }

  #app {
    position: relative;
    flex-direction: column;
    gap: 15px;
    padding: 10px;
    height: 100vh;
    max-width: 100%;
    width: 100%;
  }

  /* Mobile Tab Navigation */
  .tab-navigation {
    order: 1;
    margin-bottom: 0;
    padding: 6px;
    gap: 10px;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    top: 15px;
    min-width: 220px;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .tab-button {
    padding: 8px 16px;
    font-size: 10px;
    min-width: 50px;
    border-radius: 16px;
  }

  .tab-content.active {
    flex-direction: column;
    gap: 15px;
    width: 100%;
  }

  /* Mobile Camera */
  #cameraTab {
    order: 2;
    width: 100%;
    padding: 0;
  }

  #galleryTab {
    order: 3;
    width: 100%;
    margin-top: 70px;
    padding-bottom: 60px !important;
    /* スマホでの見切れ防止（適量に） */
  }

  #settingsTab {
    order: 3;
    width: 100%;
    margin-top: 70px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: calc(100vh - 140px);
    /* タブナビゲーションとマージンを除いた高さ */
  }



  .webcam {
    order: 1;
    width: 100%;
    max-width: 100%;
  }

  .buttons {
    order: 2;
    justify-content: center;
    width: 100%;
    padding: 0 10px;
  }

  .photo-gallery {
    order: 3;
    width: 100%;
    padding-bottom: 0;
    margin-bottom: 0;
  }

  .gallery-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding-bottom: 0;
    margin-bottom: 0;
  }

  .settings-content {
    order: 3;
    min-width: auto;
    padding: 20px;
    width: 100%;
  }

  .camera-controls {
    bottom: 20px;
  }

  .shutter-button {
    width: 60px;
    height: 60px;
  }

  .shutter-button img {
    width: 100%;
    height: 100%;
  }

  .sound-dialog-content {
    width: 95%;
    margin: 20px;
  }

  /* Mobile Navigation Buttons */
  .nav-btn {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .prev-btn {
    left: -10px;
    /* レスポンシブでは適度に外側に */
  }

  .next-btn {
    right: -10px;
    /* レスポンシブでは適度に外側に */
  }



  /* Mobile Expression Display */
  .expression-display {
    bottom: 100px;
    padding: 12px 20px;
    min-width: 130px;
    font-size: 16px;
  }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
  #app {
    padding: 5px;
    gap: 10px;
  }

  .tab-navigation {
    margin-bottom: 0;
    padding: 4px;
    border-radius: 50px;
    top: 10px;
    min-width: 240px;
    gap: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .tab-button {
    padding: 8px 12px;
    font-size: 12px;
    min-width: 60px;
    border-radius: 14px;
  }

  #galleryTab {
    margin-top: 60px;
    padding-bottom: 80px !important;
  }

  #settingsTab {
    margin-top: 60px;
  }

  .buttons {
    padding: 0 5px;
  }

  .webcam {
    margin: 0;
  }

  .camera-controls {
    bottom: 20px;
  }

  .shutter-button {
    width: 60px;
    height: 60px;
  }

  .shutter-button img {
    width: 100%;
    height: 100%;
  }

  .sound-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .manner-mode-banner .banner-content {
    padding: 8px 16px;
    gap: 12px;
  }
}

/* 横向き画面での右端縦並びレイアウト（responsive.css） */
@media (orientation: landscape) and (min-width: 768px) and (max-height: 600px) {

  .powered-by-text {
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 14px !important;
    background: rgba(0, 0, 0, 0.2);
  }
}

/* Tablet and Medium Devices */
@media (max-width: 768px) {
  .tab-content.active {
    gap: 20px;
  }

  .settings-content {
    padding: 20px 15px;
    min-width: 280px;
  }

  .sound-selection,
  .stamp-selection {
    padding: 0px 0px 0px;
  }

  .photo-gallery {
    padding: 15px 15px 0 15px;
    margin-bottom: 0;
  }

  .gallery-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding-bottom: 60px;
    margin-bottom: 0;
  }

  .sound-list {
    /* grid-template-columns: repeat(2, 1fr); Removed to allow 4 cols on tablet */
    gap: 15px;
  }

  .sound-list .sound-option {
    padding: 15px;
  }

  .sound-list .sound-image {
    width: 60px;
    height: 60px;
  }

  /* Mobile Default Sound Setting */
  .default-sound-setting {
    padding: 20px;
    margin-top: 30px;
  }

  .default-sound-controls {
    flex-direction: column;
    gap: 10px;
  }

  .default-sound-btn {
    min-width: auto;
  }
}