/* ============================================
   TYPEBLASTER - RESPONSIVE STYLES
   Mobile, Tablet, and Desktop Breakpoints
   ============================================ */

/* ============================================
   TABLET BREAKPOINT (768px - 1023px)
   ============================================ */
@media screen and (max-width: 1023px) {
    .game-container {
        grid-template-columns: 200px 1fr 0; /* Removing the ad column space */
    }
    
    .stats-panel {
        padding: var(--spacing-sm);
    }
    
    .game-title {
        font-size: 1.1rem;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .controls-info {
        display: none;
    }
    
    .cyber-btn {
        font-size: 0.65rem;
        padding: 10px 14px;
    }
    
    /* Hide ad panel as 200px is too narrow for standard ads (250px min) */
    .ad-panel {
        display: none;
    }
}

/* ============================================
   MOBILE BREAKPOINT (< 768px)
   Stacked Layout
   ============================================ */
@media screen and (max-width: 767px) {
    .game-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
    }
    
    /* Stats Panel becomes top bar */
    .stats-panel {
        grid-column: 1;
        grid-row: 1;
        flex-direction: row;
        align-items: center;
        padding: var(--spacing-sm);
        border-right: none;
        border-bottom: 1px solid var(--neon-cyan);
        overflow-x: auto;
        overflow-y: hidden;
        min-height: 70px;
        max-height: 70px;
    }
    
    .panel-header {
        display: flex;
        align-items: center;
        gap: var(--spacing-sm);
        padding: 0;
        border: none;
        margin: 0;
        margin-right: var(--spacing-md);
        white-space: nowrap;
    }
    
    .game-title {
        font-size: 1rem;
    }
    
    .version {
        display: none;
    }
    
    .stats-grid {
        display: flex;
        flex-direction: row;
        gap: var(--spacing-sm);
        margin: 0;
        flex: 1;
    }
    
    .stat-card {
        min-width: 70px;
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    .stat-label {
        font-size: 0.5rem;
    }
    
    .stat-value {
        font-size: 1rem;
    }
    
    .controls-info,
    .game-controls {
        display: none;
    }
    
    /* Game Panel takes full space */
    .game-panel {
        grid-column: 1;
        grid-row: 2;
    }
    
    /* Ad Panel hidden on mobile (or shown as bottom banner) */
    .ad-panel {
        display: none;
    }
    
    /* Mobile Input always visible on mobile */
    .mobile-input-overlay {
        display: block;
    }
    
    .mobile-input {
        width: 240px;
        font-size: 1rem;
        padding: 10px 16px;
    }
    
    .current-input-display {
        font-size: 1.2rem;
        bottom: 70px;
    }
}

/* ============================================
   SMALL MOBILE BREAKPOINT (< 480px)
   ============================================ */
@media screen and (max-width: 479px) {
    .stats-panel {
        min-height: 60px;
        max-height: 60px;
        padding: var(--spacing-xs);
    }
    
    .game-title {
        font-size: 0.85rem;
    }
    
    .stat-card {
        min-width: 55px;
        padding: var(--spacing-xs);
    }
    
    .stat-label {
        font-size: 0.45rem;
        letter-spacing: 1px;
    }
    
    .stat-value {
        font-size: 0.9rem;
    }
    
    .mobile-input {
        width: 200px;
        font-size: 0.9rem;
    }
    
    .current-input-display {
        font-size: 1rem;
        bottom: 60px;
    }
}

/* ============================================
   LANDSCAPE MOBILE
   ============================================ */
@media screen and (max-width: 767px) and (orientation: landscape) {
    .game-container {
        grid-template-columns: 160px 1fr;
        grid-template-rows: 1fr;
    }
    
    .stats-panel {
        grid-column: 1;
        grid-row: 1;
        flex-direction: column;
        border-bottom: none;
        border-right: 1px solid var(--neon-cyan);
        min-height: auto;
        max-height: none;
        overflow-x: hidden;
        overflow-y: auto;
    }
    
    .panel-header {
        flex-direction: column;
        margin: 0;
        margin-bottom: var(--spacing-sm);
    }
    
    .game-title {
        font-size: 0.9rem;
    }
    
    .stats-grid {
        flex-direction: column;
    }
    
    .stat-card {
        min-width: auto;
    }
    
    .game-panel {
        grid-column: 2;
        grid-row: 1;
    }
    
    .mobile-input {
        width: 200px;
    }
}

/* ============================================
   LARGE DESKTOP (> 1400px)
   ============================================ */
@media screen and (min-width: 1400px) {
    .game-container {
        grid-template-columns: 320px 1fr 320px;
    }
    
    .stats-panel {
        padding: var(--spacing-lg);
    }
    
    .game-title {
        font-size: 1.8rem;
    }
    
    .stat-value {
        font-size: 1.8rem;
    }
    
    .controls-info h3 {
        font-size: 0.9rem;
    }
    
    .controls-info li {
        font-size: 0.8rem;
    }
    
    .cyber-btn {
        font-size: 0.85rem;
        padding: 14px 24px;
    }
}

/* ============================================
   ULTRAWIDE (> 1920px)
   ============================================ */
@media screen and (min-width: 1920px) {
    .game-container {
        grid-template-columns: 360px 1fr 360px;
    }
    
    .canvas-container canvas {
        max-width: 1200px;
    }
}

/* ============================================
   TOUCH DEVICE OPTIMIZATIONS
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .cyber-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .stat-card {
        min-height: 44px;
    }
    
    /* Remove hover effects on touch */
    .cyber-btn:hover {
        transform: none;
        background: transparent;
        color: var(--neon-cyan);
    }
    
    .cyber-btn:active {
        background: var(--neon-cyan);
        color: var(--bg-primary);
    }
    
    /* Prevent text selection */
    body {
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Prevent callout on long press */
    * {
        -webkit-touch-callout: none;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    body::after {
        display: none;
    }
    
    .game-panel {
        animation: none;
    }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */
@media (prefers-contrast: high) {
    :root {
        --neon-cyan: #00ffff;
        --neon-magenta: #ff00ff;
        --neon-green: #00ff00;
        --bg-primary: #000000;
        --bg-panel: #000000;
        --text-primary: #ffffff;
    }
    
    .stat-card,
    .controls-info,
    .cyber-btn {
        border-width: 2px;
    }
}

/* ============================================
   DARK MODE (already dark, but explicit)
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* Already optimized for dark mode */
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .stats-panel,
    .ad-panel,
    .mobile-input-overlay {
        display: none;
    }
    
    .game-panel {
        width: 100%;
        height: 100%;
    }
}

/* ============================================
   FULLSCREEN SPECIFIC
   ============================================ */
:fullscreen .game-container {
    grid-template-columns: 280px 1fr 280px;
}

:fullscreen .stats-panel,
:fullscreen .ad-panel {
    background: rgba(15, 15, 26, 0.98);
}

/* Webkit fullscreen */
:-webkit-full-screen .game-container {
    grid-template-columns: 280px 1fr 280px;
}

/* Firefox fullscreen */
:-moz-full-screen .game-container {
    grid-template-columns: 280px 1fr 280px;
}

/* ============================================
   ORIENTATION LOCK PROMPT (Mobile)
   ============================================ */
.orientation-prompt {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--spacing-lg);
}

.orientation-prompt .icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
    animation: rotatePhone 2s ease-in-out infinite;
}

@keyframes rotatePhone {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

/* Show prompt on mobile portrait if desired */
/* Uncomment to force landscape on mobile */
/*
@media screen and (max-width: 767px) and (orientation: portrait) {
    .orientation-prompt {
        display: flex;
    }
    
    .game-container {
        display: none;
    }
}
*/
