:root {
    --primary-color: #4cc9f0;
    --secondary-color: #f72585;
    --bg-color: #1a1a2e;
    --card-bg: #16213e;
    --text-color: #e94560;
    --text-white: #ffffff;
    --key-bg: #2a2a4e;
    --key-active: #3a3a5e;
    --success: #4cc9f0;
    --error: #f72585;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-white);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 480px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.highlight {
    color: var(--primary-color);
}

.subtitle {
    color: #a0a0b0;
    font-size: 0.9rem;
}

main {
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none; /* Prevent clicks on hidden screens */
    transition: opacity 0.3s ease;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.icon-box {
    font-size: 4rem;
    margin-bottom: 20px;
}

.rules-list {
    text-align: left;
    margin: 20px 0 30px;
    padding-left: 20px;
    color: #cfcfcf;
    line-height: 1.6;
}

/* Buttons */
.btn {
    padding: 15px 40px;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    width: 100%;
}

.btn:active {
    transform: scale(0.98);
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary-color), #4895ef);
    color: #fff;
    box-shadow: 0 4px 15px rgba(76, 201, 240, 0.4);
}

.secondary-btn {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

/* Game Interface */
#game-screen {
    justify-content: flex-start;
}

.status-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}

.display-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
    min-height: 150px;
}

.number-container {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--text-white);
    letter-spacing: 5px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    height: 80px; /* Fixed height to prevent jumps */
    display: flex;
    justify-content: center;
    align-items: center;
}

.message {
    margin-top: 10px;
    color: #a0a0b0;
    font-size: 1rem;
    animation: fadeIn 0.5s;
}

.hidden {
    visibility: hidden;
    opacity: 0;
}

.input-feedback {
    font-size: 2rem;
    letter-spacing: 3px;
    margin-bottom: 20px;
    color: var(--primary-color);
    height: 40px; /* placeholder height */
    min-height: 40px;
    text-align: center;
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    width: 100%;
    max-width: 350px;
    margin-bottom: 20px;
}

.key {
    background-color: var(--key-bg);
    border: none;
    border-radius: 15px;
    padding: 20px;
    font-size: 1.5rem;
    color: var(--text-white);
    cursor: pointer;
    box-shadow: 0 4px 0 #1e1e38;
    transition: all 0.1s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.key:active {
    background-color: var(--key-active);
    box-shadow: 0 0 0 #1e1e38;
    transform: translateY(4px);
}

.key.action {
    color: var(--secondary-color);
    font-weight: bold;
}

/* Result Screen */
.score-box {
    margin: 20px 0;
}

.score-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary-color);
}

.score-label {
    font-size: 1rem;
    color: #a0a0b0;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.3s ease-in-out;
    color: var(--error) !important;
}

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

/* Landscape / Desktop Support */
@media (min-width: 768px) and (orientation: landscape) {
    .app-container {
        max-width: 900px;
    }

    #game-screen {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto 1fr auto;
        grid-template-areas: 
            "status status"
            "display keypad"
            "input keypad";
        gap: 30px;
        align-items: center;
        justify-items: center;
        padding-top: 20px;
    }

    .status-bar {
        grid-area: status;
        width: 100%;
        padding: 0 40px;
    }

    .display-area {
        grid-area: display;
        margin-bottom: 0;
        justify-content: flex-end; /* Align closer to center vertically */
        padding-bottom: 20px;
    }

    .input-feedback {
        grid-area: input;
        margin-bottom: 0;
        justify-content: flex-start; /* Align closer to center vertically */
    }

    .keypad {
        grid-area: keypad;
        margin-bottom: 0;
        height: 100%;
        align-content: center;
    }
}
