:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #252525;
    --bg-tertiary: #333;
    --text-primary: #fff;
    --text-secondary: #aaa;
    --text-muted: #666;
    --accent: #ff6600;
    --accent-hover: #ff8833;
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
    --burning: #ff5722;
    --warm: #ff9800;
    --cold: #2196f3;
    --freezing: #9c27b0;
    --border-radius: 8px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--bg-tertiary);
    margin-bottom: 20px;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: var(--accent);
    text-decoration: none;
}

.logo span {
    color: var(--text-primary);
}

.header-buttons {
    display: flex;
    gap: 10px;
}

.header-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--bg-tertiary);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
}

.header-btn:hover {
    background: var(--bg-tertiary);
}

/* Puzzle Info */
.puzzle-info {
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.puzzle-number {
    font-size: 14px;
}

.attempts-counter {
    font-size: 18px;
    margin-top: 5px;
}

.attempts-counter .current {
    color: var(--accent);
    font-weight: bold;
}

/* Thumbnail Display */
.thumbnail-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumbnail {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: filter 0.5s ease;
}

.thumbnail.blur-4 { filter: blur(20px) saturate(0.5); }
.thumbnail.blur-8 { filter: blur(15px) saturate(0.6); }
.thumbnail.blur-16 { filter: blur(10px) saturate(0.7); }
.thumbnail.blur-32 { filter: blur(6px) saturate(0.8); }
.thumbnail.blur-64 { filter: blur(3px) saturate(0.9); }
.thumbnail.blur-0 { filter: none; }

.thumbnail-placeholder {
    color: var(--text-muted);
    text-align: center;
}

.thumbnail-placeholder i {
    font-size: 48px;
    margin-bottom: 10px;
}

/* Hints Display */
.hints-display {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 20px;
}

.hint-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--bg-tertiary);
}

.hint-row:last-child {
    border-bottom: none;
}

.hint-label {
    color: var(--text-secondary);
}

.hint-value {
    font-weight: bold;
}

.hint-value.hidden {
    color: var(--text-muted);
}

/* Input Area */
.input-area {
    margin-bottom: 20px;
}

.guess-input-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#guess-input {
    flex: 1;
    padding: 15px;
    font-size: 24px;
    text-align: center;
    background: var(--bg-secondary);
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    outline: none;
}

#guess-input:focus {
    border-color: var(--accent);
}

#guess-input::placeholder {
    color: var(--text-muted);
}

.submit-btn {
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    background: var(--accent);
    color: var(--text-primary);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.submit-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.submit-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Numpad */
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.numpad-btn {
    padding: 18px;
    font-size: 22px;
    font-weight: bold;
    background: var(--bg-secondary);
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.1s;
}

.numpad-btn:hover {
    background: var(--bg-tertiary);
}

.numpad-btn:active {
    background: var(--accent);
}

.numpad-btn.action {
    background: var(--bg-tertiary);
}

.numpad-btn.submit {
    background: var(--accent);
}

.numpad-btn.submit:hover {
    background: var(--accent-hover);
}

/* Guess History */
.guess-history {
    margin-bottom: 20px;
}

.guess-history h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.guess-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.guess-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    animation: slideIn 0.3s ease;
}

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

.guess-number {
    font-size: 20px;
    font-weight: bold;
}

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

.guess-direction {
    font-size: 24px;
}

.guess-direction.higher::after { content: '⬆️'; }
.guess-direction.lower::after { content: '⬇️'; }
.guess-direction.correct::after { content: '✅'; }

.guess-distance {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}

.guess-distance.burning { background: var(--burning); }
.guess-distance.warm { background: var(--warm); }
.guess-distance.cold { background: var(--cold); }
.guess-distance.freezing { background: var(--freezing); }
.guess-distance.correct { background: var(--success); }

/* End Game */
.end-game {
    text-align: center;
    padding: 30px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    margin-bottom: 20px;
}

.end-game h2 {
    font-size: 28px;
    margin-bottom: 10px;
}

.end-game.won h2 {
    color: var(--success);
}

.end-game.lost h2 {
    color: var(--error);
}

.end-game .target-loop {
    font-size: 48px;
    font-weight: bold;
    color: var(--accent);
    margin: 20px 0;
}

.end-game .loop-link {
    display: inline-block;
    margin: 15px 0;
    padding: 10px 20px;
    background: var(--accent);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--border-radius);
    font-weight: bold;
}

.end-game .loop-link:hover {
    background: var(--accent-hover);
}

.share-btn {
    display: block;
    width: 100%;
    padding: 15px;
    margin-top: 15px;
    font-size: 16px;
    font-weight: bold;
    background: var(--success);
    color: var(--text-primary);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background 0.2s;
}

.share-btn:hover {
    background: #45a049;
}

.share-btn.copied {
    background: var(--bg-tertiary);
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--bg-tertiary);
}

.modal-header h2 {
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

/* Stats Modal */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.distribution {
    margin-top: 20px;
}

.distribution h3 {
    font-size: 14px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.distribution-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.distribution-label {
    width: 20px;
    text-align: center;
    font-weight: bold;
}

.distribution-bar {
    flex: 1;
    height: 20px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    position: relative;
}

.distribution-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    min-width: 25px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    font-size: 12px;
    font-weight: bold;
}

/* Help Modal */
.help-section {
    margin-bottom: 20px;
}

.help-section h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: var(--accent);
}

.help-section p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 10px;
}

.help-example {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    margin: 10px 0;
}

.help-emoji {
    font-size: 24px;
}

/* Footer */
footer {
    margin-top: auto;
    padding: 20px;
    text-align: center;
    border-top: 1px solid var(--bg-tertiary);
}

footer a {
    color: var(--text-secondary);
    text-decoration: none;
    margin: 0 10px;
}

footer a:hover {
    color: var(--accent);
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 15px;
    }
    
    .logo {
        font-size: 20px;
    }
    
    .numpad-btn {
        padding: 15px;
        font-size: 20px;
    }
    
    #guess-input {
        font-size: 20px;
        padding: 12px;
    }
    
    .guess-number {
        font-size: 18px;
    }
}

/* Toast notifications */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--border-radius);
    z-index: 200;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

.toast.error {
    background: var(--error);
}

.toast.success {
    background: var(--success);
}

/* Loading state */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-secondary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
