/**
 * Nu, Pogodi! Game Styles
 * Classic USSR Elektronika IM-02 aesthetic with modern responsive design
 */

/* ============================================
   CSS VARIABLES & THEME
   ============================================ */
:root {
    /* LCD Screen Colors */
    --lcd-bg: #9cb84a;
    --lcd-dark: #2d5016;
    --lcd-light: #c4d68f;
    --lcd-off: rgba(45, 80, 22, 0.1);
    
    /* UI Colors */
    --ui-bg: #1a1a1a;
    --ui-text: #ffffff;
    --ui-accent: #4CAF50;
    --ui-danger: #f44336;
    --ui-warning: #ff9800;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.3);
    --shadow-inset: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Courier New', monospace;
    background: var(--ui-bg);
    color: var(--ui-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================
   GAME CONTAINER
   ============================================ */
#game-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

/* ============================================
   GAME SCREEN
   ============================================ */
#game-screen {
    position: relative;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 4 / 3;
    background: var(--lcd-bg);
    border: 8px solid #333;
    border-radius: var(--radius-lg);
    box-shadow: 
        var(--shadow-lg),
        inset 0 0 20px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ============================================
   GAME INFO OVERLAY
   ============================================ */
#game-info {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-md);
    right: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    pointer-events: none;
    z-index: 10;
}

.info-row {
    display: flex;
    justify-content: space-between;
    gap: var(--spacing-md);
}

.info-item {
    background: rgba(0, 0, 0, 0.3);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.info-label {
    font-size: 12px;
    font-weight: bold;
    color: var(--lcd-light);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.info-value {
    font-size: 16px;
    font-weight: bold;
    color: var(--lcd-dark);
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.3);
}

/* ============================================
   MOBILE CONTROLS (Portrait)
   ============================================ */
#mobile-controls {
    display: none;
    width: 100%;
    max-width: 500px;
    padding: var(--spacing-lg);
    gap: var(--spacing-md);
    flex-direction: column;
}

.control-row {
    display: flex;
    gap: var(--spacing-md);
    justify-content: space-between;
}

.control-btn {
    flex: 1;
    aspect-ratio: 1;
    min-height: 80px;
    background: linear-gradient(145deg, #2d2d2d, #1a1a1a);
    border: 3px solid #444;
    border-radius: var(--radius-lg);
    color: var(--ui-text);
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    position: relative;
    overflow: hidden;
}

.control-btn small {
    font-size: 14px;
    opacity: 0.7;
}

.control-btn:active {
    transform: scale(0.95);
    background: linear-gradient(145deg, #1a1a1a, #2d2d2d);
    box-shadow: var(--shadow-inset);
}

.control-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.control-btn:active::before {
    width: 100%;
    height: 100%;
}

/* ============================================
   TOUCH ZONES (Landscape)
   ============================================ */
#touch-zones {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.touch-zone {
    position: absolute;
    width: 50%;
    height: 50%;
    pointer-events: all;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.touch-zone[data-position="top-left"] {
    top: 0;
    left: 0;
}

.touch-zone[data-position="top-right"] {
    top: 0;
    right: 0;
}

.touch-zone[data-position="bottom-left"] {
    bottom: 0;
    left: 0;
}

.touch-zone[data-position="bottom-right"] {
    bottom: 0;
    right: 0;
}

.touch-zone:active {
    background: rgba(255, 255, 255, 0.1);
}

/* ============================================
   OVERLAYS
   ============================================ */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
    padding: var(--spacing-lg);
    overflow-y: auto;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

.menu-content {
    background: linear-gradient(145deg, #2d2d2d, #1a1a1a);
    border: 4px solid #444;
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    max-width: 600px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: slideIn var(--transition-normal);
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============================================
   MENU ELEMENTS
   ============================================ */
.game-title {
    font-size: 48px;
    text-align: center;
    margin-bottom: var(--spacing-sm);
    color: var(--ui-accent);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
}

.game-subtitle {
    font-size: 18px;
    text-align: center;
    margin-bottom: var(--spacing-xl);
    color: #999;
    font-style: italic;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.menu-btn {
    padding: var(--spacing-md) var(--spacing-lg);
    background: linear-gradient(145deg, #2d2d2d, #1a1a1a);
    border: 2px solid #444;
    border-radius: var(--radius-md);
    color: var(--ui-text);
    font-size: 18px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
}

.menu-btn small {
    font-size: 12px;
    opacity: 0.7;
    font-weight: normal;
}

.menu-btn:hover {
    background: linear-gradient(145deg, #3d3d3d, #2a2a2a);
    border-color: #666;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.menu-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-inset);
}

.menu-btn.primary {
    background: linear-gradient(145deg, var(--ui-accent), #3d8b40);
    border-color: var(--ui-accent);
}

.menu-btn.primary:hover {
    background: linear-gradient(145deg, #5cb85f, var(--ui-accent));
}

.high-score-display {
    text-align: center;
    padding: var(--spacing-md);
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-md);
    font-size: 20px;
}

.high-score-display span {
    color: var(--ui-accent);
    font-weight: bold;
}

/* ============================================
   INSTRUCTIONS
   ============================================ */
.instructions {
    text-align: left;
    margin-bottom: var(--spacing-lg);
}

.instructions h3 {
    color: var(--ui-accent);
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
    font-size: 20px;
}

.instructions p {
    margin-bottom: var(--spacing-md);
    line-height: 1.6;
    color: #ccc;
}

.instructions ul {
    list-style: none;
    padding-left: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.instructions li {
    margin-bottom: var(--spacing-sm);
    color: #ccc;
}

.instructions kbd {
    display: inline-block;
    padding: 2px 8px;
    background: #333;
    border: 1px solid #555;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: var(--ui-accent);
}

.control-info {
    background: rgba(0, 0, 0, 0.3);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
}

/* ============================================
   GAME OVER
   ============================================ */
.final-score {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-md);
}

.final-score p {
    margin-bottom: var(--spacing-sm);
    color: #999;
}

.score-big {
    font-size: 64px;
    font-weight: bold;
    color: var(--ui-accent);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.new-record {
    color: var(--ui-warning);
    font-size: 24px;
    font-weight: bold;
    animation: pulse 1s infinite;
}

.new-record.hidden {
    display: none;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Mobile Portrait */
@media (max-width: 768px) and (orientation: portrait) {
    #game-screen {
        max-width: 100%;
        border-width: 4px;
    }
    
    #mobile-controls {
        display: flex;
    }
    
    .mobile-only {
        display: flex !important;
    }
    
    .game-title {
        font-size: 36px;
    }
    
    .menu-content {
        padding: var(--spacing-lg);
    }
}

/* Mobile Landscape */
@media (max-width: 896px) and (orientation: landscape) {
    #game-container {
        flex-direction: row;
    }
    
    #game-screen {
        max-width: none;
        max-height: 100%;
        width: auto;
        height: 100%;
        border-width: 4px;
    }
    
    #touch-zones {
        display: block;
    }
    
    .landscape-only {
        display: block !important;
    }
    
    #game-info {
        top: var(--spacing-sm);
        left: var(--spacing-sm);
        right: var(--spacing-sm);
    }
    
    .info-item {
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    .info-label {
        font-size: 10px;
    }
    
    .info-value {
        font-size: 14px;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1024px) {
    #game-screen {
        max-width: 90%;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    #game-screen {
        max-width: 800px;
    }
    
    .control-btn:hover {
        background: linear-gradient(145deg, #3d3d3d, #2a2a2a);
        border-color: #666;
    }
}

/* 4K and Ultra-wide */
@media (min-width: 2560px) {
    #game-screen {
        max-width: 1200px;
    }
    
    .game-title {
        font-size: 64px;
    }
    
    .menu-btn {
        font-size: 24px;
        padding: var(--spacing-lg) var(--spacing-xl);
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.hidden {
    display: none !important;
}

.mobile-only {
    display: none;
}

.landscape-only {
    display: none;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus-visible {
    outline: 3px solid var(--ui-accent);
    outline-offset: 2px;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    body {
        background: white;
    }
    
    #game-container {
        display: none;
    }
}
