:root {
    --bg-primary: #000000;
    --bg-secondary: #111111;
    --bg-tertiary: #222222;
    --text-primary: #ffffff;
    --text-secondary: #999999;
    --text-muted: #666666;
    --accent: #ffffff;
    --accent-hover: #cccccc;
    --success: #00ff00;
    --warning: #ffff00;
    --error: #ff0000;
    --burning: #ff0000;
    --warm: #ff8c00;
    --cold: #00ccff;
    --freezing: #ff00ff;
    --digit-correct: #4caf50;
    --digit-absent: #333333;
    --border-radius: 4px;
    --shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: Verdana, Arial, Helvetica, 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: 28px;
    font-weight: bold;
    color: #fff;
    text-decoration: none;
    letter-spacing: -1.5px;
    transition: all 0.2s;
}

.logo span {
    color: #fff;
    animation: rainbow 4s infinite linear;
}

.logo:hover {
    transform: scale(1.05);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

@keyframes rainbow {
    0% {
        color: #ff0000;
    }

    20% {
        color: #ffcc00;
    }

    40% {
        color: #ffff00;
    }

    60% {
        color: #00ff00;
    }

    80% {
        color: #0000ff;
    }

    100% {
        color: #ff00ff;
    }
}

.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 {
    flex: 1;
    background: #fff;
    color: #000;
    border: none;
    padding: 15px;
    border-radius: var(--border-radius);
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.submit-btn:hover {
    background: #ccc;
    transform: translateY(-2px);
}

.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);
    color: #000;
}

.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;
}

/* Digit tiles (Wordle-style) */
.digit-tiles {
    display: flex;
    gap: 4px;
}

.digit-tile {
    width: 28px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    border-radius: 4px;
    animation: flipIn 0.3s ease;
}

@keyframes flipIn {
    0% {
        transform: scaleY(0);
    }

    100% {
        transform: scaleY(1);
    }
}

.digit-tile.correct {
    background-color: var(--digit-correct);
    border-color: var(--digit-correct);
    color: #fff;
}

.digit-tile.absent {
    background-color: var(--digit-absent);
    border-color: var(--digit-absent);
    color: #fff;
}

.digit-tile.empty {
    visibility: hidden;
}

.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;
    padding: 10px 20px;
    background: #fff;
    color: #000;
    text-decoration: none;
    border-radius: var(--border-radius);
    font-weight: bold;
}

.end-game .loop-link:hover {
    background: #ccc;
}

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

.share-btn:hover {
    background: #eee;
    animation: rainbow-bg 4s infinite linear;
}

@keyframes rainbow-bg {
    0% {
        background-color: #ff0000;
    }

    20% {
        background-color: #ffcc00;
    }

    40% {
        background-color: #ffff00;
    }

    60% {
        background-color: #00ff00;
    }

    80% {
        background-color: #0000ff;
    }

    100% {
        background-color: #ff00ff;
    }
}

.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);
    }
}

/* XP Toast Notifications (Community Style) */
.xp-toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.xp-toast {
    background: linear-gradient(135deg, #2e7d32, #1b5e20);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    font-weight: bold;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInXp 0.3s ease-out, fadeOutXp 0.5s ease-in 4.5s forwards;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.xp-toast::before {
    content: '⚡';
    font-size: 1.2rem;
}

@keyframes slideInXp {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOutXp {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* Login Gate */
.thumbnail-placeholder.gate {
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    color: var(--text-muted);
}

.login-gate h2 {
    font-size: 20px;
    color: #fff;
}

.login-gate p {
    font-size: 14px;
}

.login-gate .share-btn:hover {
    transform: scale(1.02);
}