/* Tower of Luck - Responsive CSS */

/* Mobile First Approach - Base styles are for mobile */

/* Viewport Meta Tag Optimization */
@media screen and (max-width: 480px) {
  /* Ensure proper viewport handling */
  html {
    font-size: 14px;
  }
}

/* Enhanced Mobile Optimizations */
@media screen and (max-width: 768px) {
  html {
    font-size: 16px;
  }

  body {
    /* Prevent horizontal scroll */
    overflow-x: hidden;
    /* Optimize for touch */
    touch-action: pan-y pinch-zoom;
  }

  /* Ensure game fits in viewport */
  .screen {
    min-height: 100%;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Optimize slot machine for mobile */
  .slot-machine {
    max-width: 100vw;
    margin: 0 auto;
    padding: 8px;
  }

  /* Make symbols smaller on mobile */
  .symbol {
    font-size: 1.2rem !important;
    min-height: 40px;
    max-height: 50px;
  }

  /* Adjust reel height for mobile */
  .reel-container {
    height: 150px !important;
    max-height: 40vh;
  }

  /* Optimize spin button for touch */
  .spin-btn {
    min-height: 60px;
    min-width: 120px;
    font-size: 1.1rem;
    padding: 12px 20px;
    /* Better touch target */
    touch-action: manipulation;
  }

  /* Stack controls vertically on mobile */
  .slot-controls {
    flex-direction: column;
    gap: 12px;
    align-items: center;
  }

  .auto-spin-controls {
    flex-direction: row;
    gap: 8px;
    justify-content: center;
  }

  /* Optimize bonus game for mobile */
  #bonus-canvas {
    max-width: 100vw;
    max-height: 50vh;
    width: 100%;
    height: auto;
  }

  /* Adjust modals for mobile */
  .modal-content {
    max-width: 95vw;
    max-height: 90vh;
    margin: 5vh auto;
    padding: 16px;
  }
}

/* Small Mobile Devices (320px - 480px) */
@media (max-width: 480px) {
  /* Header adjustments */
  .game-header {
    padding: var(--spacing-sm);
    min-height: 60px;
  }

  .logo-text {
    display: none;
  }

  .player-stats {
    gap: var(--spacing-sm);
  }

  .stat-item {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.8rem;
  }

  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  /* XP Bar */
  .xp-text {
    font-size: 0.7rem;
  }

  /* Slot Machine */
  .slot-machine {
    padding: var(--spacing-sm);
    margin: var(--spacing-sm);
  }

  .slot-header h2 {
    font-size: 1.2rem;
  }

  .symbol {
    font-size: 1.6rem !important;
    min-height: 50px;
  }

  .reel-container {
    height: 180px !important;
  }

  .spin-btn {
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1.1rem;
    min-width: 120px;
    min-height: 50px;
  }

  .auto-spin-controls {
    flex-direction: column;
    gap: var(--spacing-xs);
  }

  /* Win Display */
  .win-amount {
    font-size: 1.8rem;
  }

  .win-message {
    font-size: 0.9rem;
  }

  /* Bonus Game */
  #bonus-canvas {
    width: 100%;
    height: auto;
    max-height: 250px;
  }

  .bonus-header h2 {
    font-size: 1.3rem;
  }

  .bonus-stats {
    flex-direction: column;
    gap: var(--spacing-sm);
    font-size: 0.9rem;
  }

  /* Collection Screen */
  .collection-content {
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
  }

  .chicken-sprite {
    width: 60px;
    height: 60px;
    font-size: 2.5rem;
  }

  .skins-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: var(--spacing-sm);
  }

  .skin-sprite {
    font-size: 1.8rem;
  }

  .skin-name {
    font-size: 0.7rem;
  }

  /* Stats Screen */
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--spacing-md);
  }

  .stat-number {
    font-size: 1.8rem;
  }

  .stat-label {
    font-size: 0.8rem;
  }

  /* Modal adjustments */
  .modal-content {
    width: 95%;
    margin: 5% auto;
    max-height: 85vh;
  }

  .modal-header {
    padding: var(--spacing-md);
  }

  .modal-body {
    padding: var(--spacing-md);
  }

  /* Bottom Navigation */
  .nav-icon {
    font-size: 1.1rem;
  }

  .nav-label {
    font-size: 0.6rem;
  }
}

/* Large Mobile Devices (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
  /* Slot Machine */
  .symbol {
    font-size: 2rem !important;
  }

  .reel-container {
    height: 200px !important;
  }

  .spin-btn {
    font-size: 1.2rem;
    min-width: 140px;
    min-height: 55px;
  }

  /* Bonus Game */
  #bonus-canvas {
    max-height: 350px;
  }

  .bonus-stats {
    gap: var(--spacing-lg);
  }

  /* Collection */
  .chicken-sprite {
    width: 80px;
    height: 80px;
    font-size: 3rem;
  }

  .skins-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }

  .skin-sprite {
    font-size: 2rem;
  }

  /* Stats */
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .stat-number {
    font-size: 2rem;
  }
}

/* Tablet Devices (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  /* Header */
  .game-header {
    padding: var(--spacing-lg);
  }

  .player-stats {
    gap: var(--spacing-xl);
  }

  /* Slot Machine */
  .slot-container {
    max-width: 700px;
  }

  .symbol {
    font-size: 2.5rem !important;
  }

  .reel-container {
    height: 220px !important;
  }

  /* Bonus Game */
  #bonus-canvas {
    max-height: 450px;
  }

  .bonus-header h2 {
    font-size: 2rem;
  }

  /* Collection */
  .collection-content {
    grid-template-columns: 1fr 2fr;
  }

  .skins-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  /* Stats */
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

/* Desktop Devices (1025px+) */
@media (min-width: 1025px) {
  /* Full desktop experience - base styles apply */

  /* Enhanced hover effects for desktop */
  .slot-machine:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px var(--shadow-color);
  }

  .stat-card:hover {
    transform: translateY(-8px);
  }

  .skin-item:hover {
    transform: translateY(-8px);
  }

  /* Larger canvas for desktop */
  #bonus-canvas {
    max-height: 600px;
  }

  /* Better spacing for large screens */
  .game-main {
    padding: var(--spacing-xl);
  }

  .collection-content {
    gap: var(--spacing-xl) * 1.5;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-xl);
  }
}

/* Landscape Orientation Adjustments for Mobile */
@media (orientation: landscape) and (max-height: 600px) {
  /* Compact layout for landscape mobile */
  .game-header {
    min-height: 35px;
    padding: 2px 6px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
  }

  .xp-container {
    display: none;
  }

  .game-main {
    padding: 2px;
    margin-top: 35px;
    height: calc(100% - 35px);
    display: flex;
    flex-direction: column;
  }

  .slot-machine {
    padding: 4px;
    margin: 2px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
  }

  .slot-header h2 {
    font-size: 0.9rem;
    margin-bottom: 2px;
    text-align: center;
  }

  .symbol {
    font-size: 1rem !important;
    min-height: 25px;
    max-height: 30px;
  }

  .reel-container {
    height: 80px !important;
    max-height: 25vh;
  }

  .slot-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    padding: 4px 8px;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
  }

  .bet-info {
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .spin-btn {
    padding: 6px 12px;
    font-size: 0.9rem;
    min-height: 35px;
    min-width: 80px;
    flex-shrink: 0;
  }

  .auto-spin-controls {
    display: flex;
    gap: 4px;
    align-items: center;
  }

  .auto-btn,
  .auto-select {
    padding: 4px 8px;
    font-size: 0.8rem;
    min-height: 30px;
  }

  #bonus-screen {
    padding: 4px;
    margin-top: 35px;
  }

  .bonus-header {
    padding: 2px 4px;
    position: fixed;
    top: 35px;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    z-index: 99;
  }

  .bonus-header h2 {
    font-size: 1rem;
  }

  .bonus-stats {
    font-size: 0.8rem;
    gap: 8px;
  }

  #bonus-canvas {
    max-height: calc(100% - 120px);
    margin-top: 60px;
  }

  .bonus-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    padding: 4px 8px;
    z-index: 100;
  }

  .control-instructions p {
    font-size: 0.7rem;
    margin: 1px 0;
  }

  .bonus-exit-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    min-height: 35px;
  }

  /* Hide non-essential elements */
  .logo-text {
    display: none;
  }

  .player-stats {
    gap: 4px;
  }

  .stat-item {
    padding: 2px 4px;
    font-size: 0.7rem;
  }

  .icon-btn {
    width: 24px;
    height: 24px;
    font-size: 0.7rem;
  }

  /* Optimize win display */
  .win-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
  }

  .win-amount {
    font-size: 1.2rem;
  }

  .win-message {
    font-size: 0.8rem;
  }

  /* Optimize bonus trigger */
  .bonus-trigger {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
  }

  .bonus-content h3 {
    font-size: 1rem;
  }

  .bonus-content p {
    font-size: 0.8rem;
  }

  .bonus-start-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    min-height: 35px;
  }
}

/* Landscape Orientation Adjustments for Tablet */
@media (orientation: landscape) and (min-height: 601px) and (max-height: 800px) {
  .slot-machine {
    padding: var(--spacing-md);
  }

  .symbol {
    font-size: 2.2rem !important;
  }

  .reel-container {
    height: 180px !important;
  }

  .spin-btn {
    font-size: 1.2rem;
    min-height: 50px;
  }
}

/* Ultra-compact layout for very low landscape screens (like 800x400) */
@media (orientation: landscape) and (max-height: 450px) {
  .game-header {
    min-height: 25px;
    padding: 1px 4px;
  }

  .game-main {
    margin-top: 25px;
    height: calc(100% - 25px);
  }

  .slot-machine {
    padding: 2px;
    margin: 1px;
    justify-content: flex-start !important;
    align-items: center !important;
  }

  .slot-header h2 {
    font-size: 0.7rem;
    margin-bottom: 1px;
  }

  .symbol {
    font-size: 0.8rem !important;
    min-height: 20px;
    max-height: 25px;
  }

  .reel-container {
    height: 60px !important;
    max-height: 20vh;
  }

  .slot-controls {
    padding: 2px 4px;
    gap: 4px;
  }

  .bet-info {
    font-size: 0.6rem;
  }

  .spin-btn {
    padding: 4px 8px;
    font-size: 0.7rem;
    min-height: 25px;
    min-width: 60px;
  }

  .auto-btn,
  .auto-select {
    padding: 2px 6px;
    font-size: 0.6rem;
    min-height: 25px;
  }

  .bonus-header {
    top: 25px;
    padding: 1px 2px;
  }

  .bonus-header h2 {
    font-size: 0.8rem;
  }

  .bonus-stats {
    font-size: 0.6rem;
    gap: 4px;
  }

  #bonus-canvas {
    max-height: calc(100% - 80px);
    margin-top: 40px;
  }

  .bonus-controls {
    padding: 2px 4px;
  }

  .control-instructions p {
    font-size: 0.5rem;
    margin: 0;
  }

  .bonus-exit-btn {
    padding: 4px 8px;
    font-size: 0.6rem;
    min-height: 25px;
  }

  .stat-item {
    padding: 1px 2px;
    font-size: 0.5rem;
  }

  .icon-btn {
    width: 20px;
    height: 20px;
    font-size: 0.5rem;
  }

  .win-amount {
    font-size: 1rem;
  }

  .win-message {
    font-size: 0.6rem;
  }

  .bonus-content h3 {
    font-size: 0.8rem;
  }

  .bonus-content p {
    font-size: 0.6rem;
  }

  .bonus-start-btn {
    padding: 4px 8px;
    font-size: 0.6rem;
    min-height: 25px;
  }
}

/* Portrait Orientation Adjustments for Mobile */
@media (orientation: portrait) and (max-width: 480px) {
  .slot-machine {
    padding: var(--spacing-md);
  }

  .symbol {
    font-size: 1.8rem !important;
  }

  .reel-container {
    height: 200px !important;
  }

  .spin-btn {
    font-size: 1.2rem;
    min-height: 55px;
  }
}

/* Enhanced Portrait Mode Optimizations */
@media (orientation: portrait) {
  /* Optimize for vertical screens */
  .game-header {
    min-height: 50px;
    padding: 8px 12px;
  }

  .player-stats {
    gap: 8px;
  }

  .stat-item {
    padding: 4px 8px;
    font-size: 0.8rem;
  }

  .icon-btn {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }

  /* Optimize slot machine for portrait */
  .slot-machine {
    margin: 8px;
    padding: 12px;
  }

  .slot-header h2 {
    font-size: 1.1rem;
    margin-bottom: 8px;
  }

  /* Adjust symbols for portrait */
  .symbol {
    font-size: 1.3rem !important;
    min-height: 45px;
    max-height: 55px;
  }

  /* Optimize reel height for portrait */
  .reel-container {
    height: 180px !important;
    max-height: 35vh;
  }

  /* Make spin button more accessible in portrait */
  .spin-btn {
    min-height: 55px;
    min-width: 130px;
    font-size: 1.2rem;
    padding: 12px 24px;
    margin: 8px 0;
  }

  /* Optimize controls layout for portrait */
  .slot-controls {
    gap: 12px;
  }

  .bet-info {
    font-size: 0.9rem;
  }

  .auto-spin-controls {
    gap: 8px;
  }

  .auto-btn,
  .auto-select {
    padding: 8px 12px;
    font-size: 0.9rem;
  }

  /* Optimize bonus game for portrait */
  #bonus-canvas {
    max-height: 45vh;
    width: 100%;
  }

  .bonus-header h2 {
    font-size: 1.2rem;
  }

  .bonus-stats {
    font-size: 0.9rem;
    gap: 8px;
  }

  /* Optimize win display for portrait */
  .win-amount {
    font-size: 1.6rem;
  }

  .win-message {
    font-size: 0.9rem;
  }

  /* Optimize modals for portrait */
  .modal-content {
    max-width: 95vw;
    max-height: 85vh;
    margin: 7.5vh auto;
    padding: 16px;
  }

  .modal-header h3 {
    font-size: 1.1rem;
  }

  .modal-body {
    font-size: 0.9rem;
  }
}

/* Remove vertical centering for screens below 900px width */
@media screen and (max-width: 900px) {
  .game-main {
    justify-content: flex-start !important;
    align-items: flex-start !important;
  }

  .slot-machine {
    justify-content: flex-start !important;
    align-items: center !important;
    margin-top: 0 !important;
  }

  .slot-container {
    justify-content: flex-start !important;
    align-items: center !important;
  }

  /* Move game to top of screen */
  .game-main {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }

  /* Ensure proper spacing from header */
  .slot-machine {
    margin-top: 10px !important;
  }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Sharper text rendering */
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* Crisper borders */
  .slot-machine,
  .stat-card,
  .skin-item {
    border-width: 1px;
  }
}

/* Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
  /* Disable animations for users who prefer reduced motion */
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .chicken-logo,
  .bonus-header h2,
  .chicken-sprite {
    animation: none !important;
  }

  .reel.spinning .reel-symbols {
    animation: none !important;
  }
}

/* Dark Mode Support (if system preference) */
@media (prefers-color-scheme: dark) {
  /* Note: This is optional since the game has a bright, cheerful theme
       But we can provide subtle dark mode adjustments */

  :root {
    --background-color: #1a2e1a;
    --text-color: #ecf0f1;
    --border-color: #2d4a2d;
    --shadow-color: rgba(0, 0, 0, 0.3);
  }

  body {
    background: linear-gradient(135deg, #1a2e1a 0%, #2d4a2d 100%);
  }

  .modal-content,
  .stat-card,
  .current-chicken,
  .available-skins {
    background: #2d4a2d;
    color: #ecf0f1;
  }

  .slot-machine {
    background: linear-gradient(135deg, #2d4a2d 0%, #1a2e1a 100%);
  }
}

/* Print Styles (hide game elements) */
@media print {
  body * {
    visibility: hidden;
  }

  .stats-content,
  .stats-content * {
    visibility: visible;
  }

  .stats-content {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }

  .game-header,
  .bottom-nav,
  .modal,
  .btn {
    display: none !important;
  }
}

/* Touch Device Optimizations */
@media (pointer: coarse) {
  /* Larger touch targets */
  .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .nav-btn {
    min-height: 60px;
  }

  .spin-btn {
    min-height: 60px;
    min-width: 160px;
  }

  .skin-item {
    min-height: 100px;
  }

  /* Remove hover effects on touch devices */
  .slot-machine:hover,
  .stat-card:hover,
  .skin-item:hover {
    transform: none;
  }

  /* Add active states instead */
  .spin-btn:active {
    transform: scale(0.98);
  }

  .nav-btn:active {
    background: rgba(74, 124, 89, 0.2);
  }

  .skin-item:active {
    transform: scale(0.98);
  }
}

/* Very Large Screens (1440px+) */
@media (min-width: 1440px) {
  .slot-container {
    max-width: 800px;
  }

  .symbol {
    font-size: 3rem !important;
  }

  .reel-container {
    height: 260px !important;
  }

  .game-main {
    padding: var(--spacing-xl) * 2;
  }

  .modal-content {
    max-width: 600px;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 900px;
    margin: 0 auto;
  }
}

/* Ultra-wide Screens (1920px+) */
@media (min-width: 1920px) {
  .slot-container {
    max-width: 1000px;
  }

  .symbol {
    font-size: 3.5rem !important;
  }

  .reel-container {
    height: 300px !important;
  }

  .collection-content,
  .stats-content {
    max-width: 1200px;
    margin: 0 auto;
  }
}

/* Extra Small Mobile Devices (320px and below) */
@media (max-width: 320px) {
  .game-header {
    padding: var(--spacing-xs);
    min-height: 50px;
  }

  .stat-item {
    padding: var(--spacing-xs);
    font-size: 0.7rem;
  }

  .icon-btn {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }

  .symbol {
    font-size: 1.4rem !important;
    min-height: 45px;
  }

  .reel-container {
    height: 160px !important;
  }

  .spin-btn {
    font-size: 1rem;
    min-width: 100px;
    min-height: 45px;
  }

  .bonus-header h2 {
    font-size: 1.1rem;
  }

  .win-amount {
    font-size: 1.5rem;
  }

  .win-message {
    font-size: 0.8rem;
  }
}

/* Ensure buttons are always visible and accessible */
.spin-btn,
.auto-btn,
.bonus-start-btn,
.back-btn {
  position: relative;
  z-index: 10;
  /* Ensure minimum touch target size */
  min-height: 44px;
  min-width: 44px;
}

/* Prevent buttons from being hidden behind other elements */
.slot-controls {
  position: relative;
  z-index: 5;
}

/* Ensure proper spacing for touch targets */
@media (max-width: 768px) {
  .slot-controls {
    gap: var(--spacing-lg);
  }

  .auto-spin-controls {
    gap: var(--spacing-md);
  }
}

/* Background image optimization */
body {
  background-image: url("../bg.jpg");
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* Ensure proper viewport handling */
@media screen and (max-width: 480px) {
  html {
    font-size: 14px;
  }
}

@media screen and (min-width: 481px) and (max-width: 768px) {
  html {
    font-size: 15px;
  }
}

@media screen and (min-width: 769px) {
  html {
    font-size: 16px;
  }
}
