/*==================================================
    MentalFluency Countdown
==================================================*/

:root{

    --mf-primary: #0F766E;
    --mf-primary-hover: #115E59;
    --mf-primary-light: #ECFDF5;

    --bg:#faf8f4;

    --surface:#ffffff;

    --border:#E5E7EB;

    --text:#222;

    --muted:#666;

    --primary:var(--mf-primary);

    --shadow:0 4px 12px rgba(0,0,0,.08);

}

*{

    box-sizing:border-box;

}

body{

    margin:0;

    background:var(--bg);

    font-family:Inter,system-ui,sans-serif;

    color:var(--text);

}

.game-shell{

    max-width:1100px;

    margin:auto;

    padding:40px 24px;

}

.countdown-game{

    display:flex;

    flex-direction:column;

    gap:36px;

}

/*==================================================
    Target
==================================================*/


.target-header{

    display:flex;

    justify-content:center;

    align-items:center;

    gap:12px;

}

.target-section{

    display:flex;

    flex-direction:column;

    align-items:center;

    gap:12px;

}

.target-label{

    font-family:Manrope,sans-serif;

    font-size:16px;

    font-weight:600;

    letter-spacing:.16em;

    text-transform:uppercase;

    color:var(--muted);

}

.target-card{

    min-width:180px;

    padding:18px 36px;

    background:white;

    border:1px solid var(--border);

    border-radius:16px;

    box-shadow:var(--shadow);

    text-align:center;

    font-size:40px;

    font-weight:700;

}

/*==================================================
    Rows
==================================================*/

.card-row{

    display:flex;

    justify-content:center;

    flex-wrap:nowrap;

    gap:8px;

    width:100%;

}

/*==================================================
    Cards
==================================================*/

.card{

    width:calc((100% - 5 * 12px) / 6);

    aspect-ratio:1;

    height:auto;

    font-size:26px;

    font-weight:600;

    display:flex;

    justify-content:center;

    align-items:center;

    background:white;

    border:1px solid var(--border);

    border-radius:14px;

    box-shadow:var(--shadow);

    cursor:pointer;

    user-select:none;

    touch-action:none;

    transition:all .15s ease;

}

.target-reached{

    border:3px solid #0F766E;

    box-shadow:0 0 24px rgba(15,118,110,.25);

}

.number{

    background:white;

    transition:all .2s;

}

.numbers-section{

    margin-bottom:26px;

}

.operators-section{
    margin-bottom:26px;
}

.result{

    width:calc((100% - 5 * 8px) / 3);

    aspect-ratio:1.85 / 1;

    max-width:none;

    padding:0 12px;

    display:flex;

    justify-content:center;

    align-items:center;

    font-size:20px;

    font-weight:600;

    white-space:nowrap;

    overflow:hidden;

    flex:0 0 auto;

}

.operator{

    width:calc((100% - 24px) / 4);

    height:60px;

    font-size:24px;

    background:var(--mf-primary-light);
}

/*==================================================
    Hover
==================================================*/

.card.hover{

    border-color:var(--primary);

    transform:scale(1.08);

    box-shadow:0 0 0 4px rgba(15,118,110,.18);

}

.card.selected{

    border-color:var(--primary);

    background:#ECFDF5;
}

/*==================================================
    Work
==================================================*/

.work-label{

    font-family:var(--mf-font-heading);

    font-size:20px;

    font-weight:700;

    letter-spacing:.03em;

    color:var(--mf-heading);
}

.work-stack{

    display:flex;

    flex-direction:column;

    gap:8px;

    max-height:520px;

    overflow-y:auto;

    padding-right:6px;

}

.work-card{

    min-height:44px;

    padding:10px 16px;

    background:white;

    border:1px solid var(--border);

    border-radius:10px;

    display:flex;

    align-items:center;

    justify-content:space-between;

    font-size:20px;

    font-weight:500;

    box-shadow:0 2px 6px rgba(0,0,0,.04);

}

.work-card{

    width:100%;

}

.work-current{

    border:2px solid var(--mf-primary);

    font-weight:600;

}

.work-step{

    color:#333;

}

.work-delete{

    flex:0 0 34px;

    width:34px;
    height:34px;

    padding:0;

    border:none;

    background:transparent;

    border-radius:8px;

    display:flex;

    justify-content:center;

    align-items:center;

    cursor:pointer;

    color:#9CA3AF;

    transition:all .18s ease;

}

.work-delete{

    display:flex !important;

    align-items:center;

    justify-content:center;

}

.work-delete svg{

    width:18px;

    height:18px;

}

.work-delete:active{

    transform:scale(.94);

}

.work-delete:hover{

    background:var(--mf-primary-light);

    color:var(--mf-primary);

}

.work-delete:focus-visible{

    outline:2px solid var(--mf-primary);

    outline-offset:2px;

}

.work-text{

    flex:1;

}

/*==================================================
    Controls
==================================================*/

.controls-section{

    display:flex;

    justify-content:center;

    align-items:center;

    gap:20px;

    flex-wrap:wrap;

}

.control-button:hover{

    background:var(--mf-primary-hover);

    transform:translateY(-2px);

    box-shadow:0 8px 18px rgba(15,118,110,.18);

}

.control-button{

    width:170px;

    height:58px;

    padding:0 20px;

    display:flex;

    justify-content:center;

    align-items:center;

    gap:12px;

    border:none;

    border-radius:14px;

    background:var(--mf-primary);

    color:white;

    font-family:var(--mf-font-body);

    font-size:17px;

    font-weight:600;

    cursor:pointer;

    transition:
            background-color .2s ease,
            transform .18s ease,
            box-shadow .18s ease;

}

.control-button:active{

    transform:translateY(0);

    box-shadow:none;

}

.control-button:focus,
.control-button:focus-visible,
.control-button:active {

    background: var(--mf-primary) !important;

    color: white;

    outline: none;

    box-shadow: none;

}

.toggle{

    display:flex;

    justify-content:center;

    align-items:center;

    gap:12px;

    margin-top:18px;

    font-family:var(--mf-font-body);

    font-size:15px;

    font-weight:500;

    color:var(--mf-text);

}

.control-button svg{

    width:20px;

    height:20px;

    flex:0 0 auto;

}

/*==================================================
    SVG Overlay
==================================================*/
.countdown-game{

    position:relative;

}

/*==================================================
    Desktop Layout
==================================================*/

.game-layout{

    display:flex;

    gap:48px;

    align-items:flex-start;

}

.game-panel{

    flex:1;

    display:flex;

    flex-direction:column;

    gap:36px;

}

.play-area{

    flex:1;

    min-width:0;

}

.work-panel{

    width:360px;

    flex-shrink:0;

    display:flex;

    flex-direction:column;

    gap:16px;

    position:sticky;

    top:24px;

}

.drag-layer{

    position:absolute;

    left:0;
    top:0;

    width:100%;
    height:100%;

    pointer-events:none;

    overflow:visible;

    z-index:100;

}

#segment1,
#segment2 {

    stroke: #0F766E;
    stroke-width: 5;
    stroke-linecap: round;
    fill: none;

}

/*==================================================
    Hidden
==================================================*/

.hidden{

    display:none !important;

}

/*==================================================
    Mobile
==================================================*/

@media (max-width:700px){

    .card{

        flex:1 1 0;

        min-width:0;

        aspect-ratio:1;

        height:auto;

        justify-content:center;

        align-items:center;

        background:white;

        border:1px solid var(--border);

        border-radius:14px;

        box-shadow:var(--shadow);

        cursor:pointer;

        user-select:none;

        touch-action:none;

        transition:all .15s ease;

        font-size:24px;

        font-weight:600;

        overflow:hidden;

    }

    .operator{

        width:62px;

        height:56px;

    }

    .expression-preview{

        width:100%;

        font-size:22px;

    }

    .controls-section{

        display:flex;

        flex-direction:row;

        justify-content:center;

        align-items:center;

        gap:10px;

        flex-wrap:nowrap;

    }

    .control-button{

        width:64px;

        height:48px;

        padding:0;

        border-radius:12px;

        gap:0;

    }
    .control-button span{

        display:none;

    }
    .control-button svg{

        width:24px;

        height:24px;

    }
    .result{

        width:auto;

        flex:1 1 0;

        aspect-ratio:auto;

        height:76px;

        padding:4px 8px;

        line-height:1.15;

        white-space:pre-line;

        overflow:hidden;

    }

    .game-layout{

        flex-direction:column;

    }

    .work-panel{

        width:100%;

    }

    .card.target-reached{

        border:3px solid #0F766E !important;

        box-shadow:0 0 24px rgba(15,118,110,.25) !important;

    }

}
