/* ==========================================
   Shared Styles - Games Repository
   ========================================== */

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Screens */
.screen {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: center;
}

.screen.active {
    display: flex;
}

/* Typography */
h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #e74c3c, #f39c12, #2ecc71, #3498db);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

h2 {
    font-size: 1.5rem;
    color: #eee;
    margin-bottom: 15px;
}

h3 {
    font-size: 1.2rem;
    color: #aaa;
    margin-bottom: 10px;
}

.subtitle {
    color: #888;
    margin-bottom: 30px;
    text-align: center;
    font-size: 0.9rem;
}

/* Cards */
.card {
    background: #16213e;
    border-radius: 16px;
    padding: 25px;
    width: 100%;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, #e94560, #c73e54);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(233, 69, 96, 0.4);
}

.btn-primary:disabled {
    background: #333;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: #16213e;
    color: #aaa;
    border: 2px solid #0f3460;
}

.btn-secondary:hover {
    background: #1a2744;
    color: #fff;
}

/* Inputs */
input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #0f3460;
    border-radius: 10px;
    font-size: 16px;
    background: #0f3460;
    color: #fff;
    text-align: center;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: #e94560;
}

input[type="text"]::placeholder {
    color: #666;
}

/* Labels */
label {
    display: block;
    margin-bottom: 8px;
    color: #aaa;
    font-size: 14px;
}

/* Range Slider */
.slider-container {
    margin: 25px 0;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    color: #aaa;
    font-size: 14px;
}

.slider-value {
    color: #e94560;
    font-weight: bold;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #0f3460;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e94560;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(233, 69, 96, 0.5);
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e94560;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 10px rgba(233, 69, 96, 0.5);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
    display: inline-block;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0f3460;
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .toggle-slider {
    background: #e94560;
}

input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

/* Settings Toggle Row */
.settings-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-top: 1px solid #0f3460;
    margin-top: 10px;
}

.settings-toggle:first-of-type {
    border-top: none;
    margin-top: 0;
}

/* Mode Buttons */
.mode-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.mode-btn {
    flex: 1;
    padding: 14px;
    border: 2px solid #0f3460;
    border-radius: 10px;
    background: transparent;
    color: #aaa;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn.active {
    background: #e94560;
    border-color: #e94560;
    color: white;
}

.mode-btn:hover:not(.active) {
    border-color: #e94560;
    color: #fff;
}

/* Display Options */
.display-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #0f3460;
}

.display-section-title {
    color: #aaa;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.display-options {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.display-option-btn {
    flex: 1;
    min-width: 70px;
    padding: 10px 8px;
    border: 2px solid #0f3460;
    border-radius: 8px;
    background: transparent;
    color: #aaa;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.display-option-btn.active {
    background: #e94560;
    border-color: #e94560;
    color: white;
}

.display-option-btn:hover:not(.active) {
    border-color: #e94560;
    color: #fff;
}

/* Language Switch */
.lang-switch {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 5px;
}

.lang-btn {
    background: #16213e;
    border: 1px solid #0f3460;
    color: #aaa;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.lang-btn.active {
    background: #e94560;
    color: white;
    border-color: #e94560;
}

.lang-btn:hover:not(.active) {
    border-color: #e94560;
}

/* Stats */
.stat {
    background: #16213e;
    padding: 10px 20px;
    border-radius: 10px;
    text-align: center;
    min-width: 80px;
}

.stat-label {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 20px;
    font-weight: bold;
    color: #e94560;
}

/* Timer */
.timer {
    color: #2ecc71;
}

.timer.warning {
    color: #f39c12;
}

.timer.danger {
    color: #e74c3c;
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Game Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.game-info {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Game Footer */
.game-footer {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 600px;
}

/* Game Tools */
.game-tools {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 600px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.tool-btn {
    flex: 1;
    min-width: 80px;
    padding: 10px;
    border: 2px solid #0f3460;
    border-radius: 8px;
    background: #16213e;
    color: #aaa;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.tool-btn:hover:not(:disabled) {
    border-color: #e94560;
    color: #fff;
}

.tool-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tool-btn.used {
    border-color: #f39c12;
    color: #f39c12;
}

/* Tool Buttons - Compact variant */
.tool-btn.compact {
    min-width: 60px;
    padding: 8px;
    font-size: 11px;
}

/* Error Messages */
.error-msg {
    color: #e74c3c;
    font-size: 12px;
    margin-top: 8px;
    display: none;
}

.error-msg.show {
    display: block;
}

/* Hint Text */
.hint {
    color: #666;
    font-size: 12px;
    text-align: center;
    margin-top: 10px;
}

/* Result Screen */
.result-screen {
    text-align: center;
    padding: 20px;
}

.result-score {
    font-size: 48px;
    font-weight: bold;
    color: #e94560;
    margin: 20px 0;
}

.result-label {
    color: #666;
    font-size: 14px;
}

.win-message {
    color: #2ecc71;
    font-size: 24px;
    margin-bottom: 10px;
}

.lose-message {
    color: #e74c3c;
    font-size: 24px;
    margin-bottom: 10px;
}

/* Leaderboard */
.leaderboard {
    width: 100%;
    max-width: 400px;
    margin-top: 30px;
}

.leaderboard h3 {
    margin-bottom: 15px;
    text-align: center;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.leaderboard-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.leaderboard-tab {
    background: transparent;
    border: 1px solid #0f3460;
    color: #aaa;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.leaderboard-tab.active {
    background: #e94560;
    border-color: #e94560;
    color: white;
}

.leaderboard-tab:hover:not(.active) {
    border-color: #e94560;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #16213e;
    border-radius: 8px;
    margin-bottom: 8px;
}

.leaderboard-rank {
    color: #f39c12;
    font-weight: bold;
    width: 30px;
}

.leaderboard-nickname {
    flex: 1;
    text-align: left;
    padding-left: 10px;
    letter-spacing: 3px;
}

.leaderboard-difficulty {
    color: #666;
    font-size: 11px;
    margin-right: 10px;
}

.leaderboard-score {
    color: #e94560;
    font-weight: bold;
}

.leaderboard-empty {
    text-align: center;
    color: #666;
    padding: 20px;
}

.leaderboard-extras {
    font-size: 10px;
    color: #666;
    margin-left: 5px;
}

.leaderboard-extras span {
    margin-right: 5px;
}

.leaderboard-extras .hint-used {
    color: #f39c12;
}

.leaderboard-extras .undo-used {
    color: #e74c3c;
}

/* Board Indicator */
.board-indicator {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.board-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #0f3460;
    transition: all 0.2s;
}

.board-dot.active {
    background: #e94560;
}

.board-dot.completed {
    background: #2ecc71;
}

/* Challenge Info */
.challenge-info {
    background: #0f3460;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    color: #aaa;
    margin-bottom: 20px;
    display: none;
}

.challenge-info.visible {
    display: block;
}

/* High Brightness */
.cell.high-brightness {
    filter: brightness(1.3);
}

/* Black & White Mode */
.cell.bw-mode {
    filter: grayscale(100%) contrast(1.2);
}

/* Compact Grid */
#game-grid.compact {
    gap: 0;
    padding: 0;
}

#game-grid.compact .cell {
    border-radius: 0;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.scale-in {
    animation: scaleIn 0.2s ease forwards;
}

/* Responsive */
@media (max-width: 600px) {
    .app-container {
        padding: 15px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .card {
        padding: 20px;
    }
    
    .game-header {
        justify-content: center;
    }
    
    .game-info {
        width: 100%;
        justify-content: center;
    }
    
    .mode-buttons {
        flex-direction: column;
    }
    
    .display-options {
        flex-direction: column;
    }
    
    .display-option-btn {
        min-width: 100%;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }

.hidden { display: none !important; }
.visible { display: block !important; }

/* Back Button */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #aaa;
    text-decoration: none;
    font-size: 14px;
    padding: 10px 15px;
    margin-bottom: 20px;
    transition: color 0.2s;
    cursor: pointer;
    background: none;
    border: none;
}

.back-btn:hover {
    color: #e94560;
}

.back-btn::before {
    content: "←";
}
