/* Number Oracle - Mystical Number Guessing Game */

/* Override body centering for game page */
main[data-page="games"] {
    width: 100%;
    max-width: none;
    align-self: stretch;
}

/* Main container - fits within fixed CRT screen */
.oracle-container {
    width: 100%;
    height: 100%;
    padding: 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    overflow: hidden;
}

/* ============ TITLE SCREEN ============ */
.title-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 20px;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

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

.title-ascii {
    font-size: 10px;
    line-height: 1.1;
    color: var(--border-accent);
    margin: 0 0 10px 0;
    white-space: pre;
    overflow-x: auto;
    max-width: 100%;
    text-shadow: 0 0 10px var(--border-accent);
    animation: titleGlow 3s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    from { text-shadow: 0 0 10px var(--border-accent); }
    to { text-shadow: 0 0 20px var(--border-accent), 0 0 30px var(--border-accent); }
}

.title-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    letter-spacing: 6px;
    margin-bottom: 20px;
    animation: subtitleFade 2s ease-in-out infinite alternate;
}

@keyframes subtitleFade {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

.oracle-art {
    font-size: 14px;
    line-height: 1.2;
    color: var(--text-primary);
    white-space: pre;
    margin: 10px 0 20px 0;
    animation: float 4s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.title-description {
    margin-bottom: 30px;
}

.title-description p {
    margin: 8px 0;
    color: var(--text-primary);
    font-size: 16px;
}

/* Difficulty Selection */
.difficulty-select {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
}

.difficulty-label {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 5px;
}

/* Button fix: apply known-issues pattern + override global button styles */
.difficulty-button {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: max-content;
    width: 200px;
    height: auto;
    padding: 12px 20px;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 0;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    margin: 0;
    font-size: 16px;
}

.difficulty-button::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transition: left 0.5s ease;
}

.difficulty-button:hover::before {
    left: 100%;
}

.difficulty-button:hover {
    border-color: var(--border-accent);
    background-color: var(--bg-color);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4), 0 0 10px var(--border-accent);
    transform: translateY(-2px);
}

.difficulty-button:hover .diff-name {
    color: var(--border-accent);
    text-shadow: 0 0 8px var(--border-accent);
}

.difficulty-button:active {
    transform: translateY(0);
}

.diff-name {
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.diff-range {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* How to Play */
.how-to-play {
    max-width: 400px;
    margin-bottom: 30px;
    text-align: center;
    padding: 15px;
    border: 1px dashed var(--border-color);
    background-color: rgba(0, 0, 0, 0.2);
}

.how-title {
    color: var(--border-accent);
    font-size: 14px;
    margin-bottom: 10px;
}

.how-to-play p {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 5px 0;
}

/* Leaderboard */
.leaderboard-section {
    width: 100%;
    max-width: 350px;
    margin-top: 10px;
}

.leaderboard-title {
    color: var(--border-accent);
    font-size: 14px;
    margin-bottom: 10px;
    text-align: center;
}

.leaderboard-list {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 10px;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.leaderboard-entry:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.leaderboard-entry:last-child {
    border-bottom: none;
}

.lb-rank {
    color: var(--border-accent);
    min-width: 30px;
    font-weight: bold;
}

.lb-name {
    flex: 1;
    color: var(--text-primary);
    padding: 0 10px;
}

.lb-score {
    color: var(--text-secondary);
    font-family: monospace;
}

.no-scores,
.loading {
    color: var(--text-secondary);
    text-align: center;
    padding: 15px;
    font-style: italic;
}

/* ============ GAME SCREEN ============ */
.game-screen {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 0.3s ease;
    flex: 1;
    min-height: 0;
}

/* Terminal Frame */
.terminal-frame {
    border: 2px solid var(--border-accent);
    background-color: var(--bg-secondary);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5),
                inset 0 0 50px rgba(0, 0, 0, 0.3),
                0 0 15px var(--border-accent);
    position: relative;
}

.terminal-frame::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.03),
        rgba(0, 0, 0, 0.03) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1;
}

.terminal-frame > * {
    position: relative;
    z-index: 2;
}

.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-color);
}

.terminal-title {
    font-size: 14px;
    color: var(--border-accent);
    letter-spacing: 2px;
    text-shadow: 0 0 5px var(--border-accent);
}

.game-info {
    display: flex;
    gap: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.range-display,
.guess-count {
    font-family: monospace;
}

.terminal-body {
    padding: 30px 20px;
    text-align: center;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.1) 0%, transparent 70%);
}

/* Oracle Display */
.oracle-display {
    font-size: 16px;
    line-height: 1.2;
    color: var(--text-primary);
    white-space: pre;
    margin: 0 0 20px 0;
    transition: all 0.3s ease;
}

.oracle-display.glowing {
    color: var(--border-accent);
    text-shadow: 0 0 10px var(--border-accent), 0 0 20px var(--border-accent);
    animation: glow 1s ease-in-out infinite alternate;
}

.oracle-display.pulsing {
    animation: pulse 0.8s ease-in-out infinite;
    color: #fa0;
}

@keyframes glow {
    from { text-shadow: 0 0 10px var(--border-accent), 0 0 20px var(--border-accent); }
    to { text-shadow: 0 0 20px var(--border-accent), 0 0 40px var(--border-accent), 0 0 60px var(--border-accent); }
}

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

.oracle-message {
    font-size: 18px;
    color: var(--text-primary);
    line-height: 1.6;
    max-width: 400px;
    min-height: 50px;
    animation: messageAppear 0.4s ease;
}

@keyframes messageAppear {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.terminal-footer {
    padding: 15px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-color);
}

/* Input Area */
.input-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-prompt {
    color: var(--border-accent);
    font-size: 18px;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.guess-input {
    flex: 1;
    padding: 12px 15px;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    font-size: 18px;
    outline: none;
    transition: all 0.3s ease;
}

.guess-input:focus {
    border-color: var(--border-accent);
    box-shadow: 0 0 10px var(--border-accent);
}

.guess-input.shake {
    animation: shake 0.5s ease;
    border-color: #f55;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.guess-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Remove number input spinners */
.guess-input::-webkit-outer-spin-button,
.guess-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.guess-input[type=number] {
    -moz-appearance: textfield;
}

/* Button fix: apply known-issues pattern + override global button styles */
.guess-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: max-content;
    width: auto;
    height: auto;
    padding: 12px 24px;
    background-color: transparent;
    border: 2px solid var(--border-accent);
    border-radius: 0;
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: none;
    white-space: nowrap;
    margin: 0;
}

.guess-button:hover {
    background-color: var(--border-accent);
    color: var(--bg-color);
    box-shadow: 0 0 15px var(--border-accent);
    transform: translateY(-1px);
}

.guess-button:active {
    transform: translateY(0);
}

/* Guess History */
.guess-history-container {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.history-title {
    color: var(--border-accent);
    font-size: 14px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.guess-history {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.history-empty {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 10px;
}

.history-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    animation: slideIn 0.3s ease;
}

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

.history-entry:last-child {
    border-bottom: none;
}

.history-number {
    font-size: 18px;
    color: var(--text-primary);
    font-weight: bold;
    font-family: monospace;
    min-width: 50px;
}

.history-result {
    font-size: 14px;
    padding: 4px 10px;
    border-radius: 3px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.history-result.higher {
    color: #5af;
    background-color: rgba(85, 170, 255, 0.15);
    border: 1px solid rgba(85, 170, 255, 0.3);
}

.history-result.lower {
    color: #fa0;
    background-color: rgba(255, 170, 0, 0.15);
    border: 1px solid rgba(255, 170, 0, 0.3);
}

.history-result.correct {
    color: #4a9;
    background-color: rgba(68, 170, 153, 0.15);
    border: 1px solid rgba(68, 170, 153, 0.3);
    animation: correctPulse 0.5s ease;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ============ RESULT SCREEN ============ */
.result-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 150px);
    text-align: center;
    animation: fadeIn 0.5s ease;
    position: relative;
    z-index: 1;
}

.oracle-reveal {
    font-size: 12px;
    line-height: 1.3;
    color: var(--border-accent);
    white-space: pre;
    margin-bottom: 20px;
    position: relative;
}

.reveal-number {
    font-size: 72px;
    font-weight: bold;
    color: var(--border-accent);
    margin-bottom: 15px;
    text-shadow: 0 0 20px var(--border-accent);
    font-family: monospace;
    position: relative;
}

.result-message {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 30px;
}

.result-stats {
    width: 100%;
    max-width: 300px;
    margin-bottom: 30px;
    display: block;
    position: relative;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 16px;
}

.stat-row span:first-child {
    color: var(--text-secondary);
}

.stat-row span:last-child {
    color: var(--text-primary);
    font-family: monospace;
}

.stat-row.final-score {
    border-bottom: none;
    margin-top: 10px;
    padding-top: 20px;
    border-top: 2px solid var(--border-accent);
}

.stat-row.final-score span:last-child {
    color: var(--border-accent);
    font-size: 28px;
    text-shadow: 0 0 10px var(--border-accent);
}

.result-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    position: relative;
    z-index: 10;
    margin-top: 10px;
}

/* Button fix: apply known-issues pattern + override global button styles */
.action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: max-content;
    width: auto;
    height: auto;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-accent);
    border-radius: 0;
    color: var(--text-primary);
    padding: 14px 32px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: none;
    white-space: nowrap;
    position: relative;
    z-index: 2;
    margin: 0;
}

.action-button:hover {
    background-color: var(--border-accent);
    color: var(--bg-color);
    box-shadow: 0 0 20px var(--border-accent);
    transform: translateY(-2px);
}

.action-button:active {
    transform: translateY(0);
}

.back-link {
    display: inline-block;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 16px;
    transition: all 0.2s ease;
    padding: 10px 20px;
    position: relative;
    z-index: 1;
}

.back-link:hover {
    color: var(--border-accent);
    text-shadow: 0 0 5px var(--border-accent);
}

/* Decorative stars removed - was causing layout issues */

/* ============ RESPONSIVE ============ */
@media (max-width: 600px) {
    .oracle-container {
        padding: 15px 10px;
    }

    .title-ascii {
        font-size: 7px;
    }

    .title-subtitle {
        font-size: 12px;
        letter-spacing: 4px;
    }

    .oracle-art {
        font-size: 12px;
    }

    .difficulty-button {
        width: 180px;
        padding: 10px 15px;
    }

    .diff-name {
        font-size: 16px;
    }

    .terminal-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .game-info {
        width: 100%;
        justify-content: space-between;
    }

    .oracle-display {
        font-size: 12px;
    }

    .oracle-message {
        font-size: 16px;
    }

    .input-area {
        flex-wrap: wrap;
    }

    .guess-input {
        flex: 1 1 100%;
        order: 1;
    }

    .input-prompt {
        display: none;
    }

    .guess-button {
        flex: 1;
        order: 2;
        margin-top: 10px;
        width: 100%;
    }

    .reveal-number {
        font-size: 56px;
    }

    .result-message {
        font-size: 16px;
    }

    .stat-row {
        font-size: 14px;
    }

    .stat-row.final-score span:last-child {
        font-size: 24px;
    }
}

/* ============ SCROLLBAR STYLING ============ */
.guess-history::-webkit-scrollbar {
    width: 6px;
}

.guess-history::-webkit-scrollbar-track {
    background: var(--bg-color);
}

.guess-history::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.guess-history::-webkit-scrollbar-thumb:hover {
    background: var(--border-accent);
}
