/*  
   BASE
*/

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #1a0f0a;
    color: #eee;
}

footer {
    text-align: center;
    padding: 20px 0;
    font-size: 14px;
    color: #888;
}


/*  
   APP
*/

.app {
    width: min(900px, calc(100% - 30px));
    margin: 0 auto;
    padding: 30px 0 60px;
}


/*  
   HEADER
*/

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 30px;
}

    .app-header h1 {
        margin: 8px 0 0;
        font-size: 32px;
        font-weight: 600;
    }

.back-link {
    color: #aaa;
    text-decoration: none;
    font-size: 14px;
}

    .back-link:hover {
        color: #fff;
    }

.timer-name-display {
    margin: 8px 0 0;
    font-size: 32px;
    font-weight: 600;
}


/*  
   GENERAL VIEWS
*/

.view {
    width: 100%;
}

.hidden {
    display: none !important;
}


/*  
   TIMER NAME
*/

.timer-name-row {
    margin-bottom: 20px;
}

#timerName {
    width: 100%;
    padding: 14px 16px;
    background: #1c1c1c;
    color: #fff;
    border: 1px solid #333;
    border-radius: 8px;
    font-size: 20px;
    outline: none;
}

    #timerName:focus {
        border-color: #666;
    }


/*  
   ROUND EDITOR
*/

.round-list-header,
.round-row {
    display: grid;
    grid-template-columns: 60px 130px 1fr 50px;
    gap: 12px;
    align-items: center;
}

.round-list-header {
    padding: 0 12px 8px;
    color: #888;
    font-size: 13px;
    text-transform: uppercase;
}

.round-row {
    margin-bottom: 8px;
    padding: 8px 12px;
    background: #1c1c1c;
    border: 1px solid #292929;
    border-radius: 8px;
}

.round-number {
    color: #888;
    font-weight: 600;
    text-align: center;
}

.round-row input {
    width: 100%;
    padding: 10px;
    background: #111;
    color: #fff;
    border: 1px solid #333;
    border-radius: 6px;
    font-size: 15px;
}

    .round-row input:focus {
        outline: none;
        border-color: #666;
    }

.remove-round {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 6px;
    background: #2a1717;
    color: #e88;
    cursor: pointer;
}

    .remove-round:hover {
        background: #4a2020;
    }


/*  
   BUTTONS
*/

button {
    font: inherit;
    cursor: pointer;
}

.primary-button,
.secondary-button,
.danger-button,
.add-round-button {
    border-radius: 7px;
    padding: 11px 18px;
    border: 1px solid transparent;
}

.primary-button {
    background: #eee;
    color: #111;
}

    .primary-button:hover {
        background: #fff;
    }

.secondary-button {
    background: #222;
    color: #ddd;
    border-color: #444;
}

    .secondary-button:hover {
        background: #2d2d2d;
    }

.danger-button {
    background: #281818;
    color: #e99;
    border-color: #4b2525;
}

    .danger-button:hover {
        background: #3a1d1d;
    }

.add-round-button {
    width: 100%;
    margin-top: 10px;
    background: transparent;
    color: #aaa;
    border: 1px dashed #444;
}

    .add-round-button:hover {
        color: #fff;
        border-color: #777;
    }


/*  
   EDITOR ACTIONS
*/

.editor-actions {
    margin-top: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.secondary-actions {
    display: flex;
    gap: 8px;
}


/*  
   IMPORT / EXPORT
*/

.import-export-box {
    width: 100%;
    min-height: 220px;
    margin-top: 20px;
    padding: 15px;
    resize: vertical;
    background: #0b0b0b;
    color: #eee;
    border: 1px solid #444;
    border-radius: 8px;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.5;
}

    .import-export-box:focus {
        outline: none;
        border-color: #777;
    }

.import-export-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}


/*  
   TIMER DISPLAY
*/

.timer-display {
    text-align: center;
    padding: 60px 20px 40px;
}

.current-round-name {
    min-height: 38px;
    color: #aaa;
    font-size: 24px;
    font-weight: 500;
}

.time-display {
    margin: 10px 0;
    font-size: clamp(80px, 18vw, 180px);
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.round-progress {
    color: #888;
    font-size: 18px;
}

.next-round {
    margin-top: 12px;
    color: #aaa;
    font-size: 16px;
}


/*  
   PROGRESS BAR
*/

.timer-progress {
    width: 100%;
    height: 8px;
    background: #222;
    border-radius: 10px;
    overflow: hidden;
}

#progressBar {
    width: 0%;
    height: 100%;
    background: #eee;
    transition: width 0.1s linear;
}


/*  
   TIMER CONTROLS
*/

.timer-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 30px;
}

.large-button {
    min-width: 120px;
    padding: 14px 22px;
}


/*  
   COMPLETE
*/

.complete-display {
    text-align: center;
    padding: 100px 20px;
}

.complete-icon {
    font-size: 70px;
    margin-bottom: 20px;
}

.complete-display h2 {
    margin: 0 0 10px;
    font-size: 36px;
}

.complete-display p {
    color: #999;
    margin-bottom: 30px;
}

.complete-display button {
    margin: 5px;
}


/*  
   MOBILE
*/

@media (max-width: 650px) {

    .app {
        width: min(100% - 20px, 900px);
        padding-top: 20px;
    }

    .app-header h1 {
        font-size: 26px;
    }

    .round-list-header {
        display: none;
    }

    .round-row {
        grid-template-columns: 35px 100px 1fr 40px;
        padding: 8px;
    }

    .editor-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .secondary-actions {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }

    .timer-display {
        padding-top: 40px;
    }

    .current-round-name {
        font-size: 20px;
    }

    .timer-controls {
        flex-wrap: wrap;
    }

    .large-button {
        flex: 1;
        min-width: 100px;
    }
}

/*  
   SAVED TIMERS
*/

.saved-timers-section {
    margin-top: 45px;
    padding-top: 25px;
    border-top: 1px solid #292929;
}

.saved-timers-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 18px;
}

    .saved-timers-header h2 {
        margin: 0;
        font-size: 20px;
        font-weight: 500;
        color: #ddd;
    }

.saved-timers-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.saved-timer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 16px 18px;
    background: #1c1c1c;
    border: 1px solid #292929;
    border-radius: 8px;
}

.saved-timer-info {
    min-width: 0;
}

    .saved-timer-info strong {
        display: block;
        margin-bottom: 5px;
        color: #eee;
        font-size: 15px;
    }

.saved-timer-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

    .saved-timer-controls button {
        white-space: nowrap;
    }

        .saved-timer-controls button:disabled {
            opacity: 0.5;
            cursor: default;
        }


/*  
   ROUND SUMMARY TABLE
*/

.round-summary-table {
    margin: 20px 0;
    width: 100%;
}

.round-summary-table table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.round-summary-table table th,
.round-summary-table table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.round-summary-table table th {
    background: rgba(255, 255, 255, 0.08);
    font-weight: 600;
    font-size: 14px;
}

.round-summary-table table tr:last-child td {
    border-bottom: none;
}

.round-summary-table table tr.total-row {
    background: rgba(255, 255, 255, 0.08);
    border-top: 2px solid rgba(255, 255, 255, 0.2);
}


/*  
   MOBILE
*/

@media (max-width: 600px) {

    .saved-timer-item {
        align-items: stretch;
        flex-direction: column;
        gap: 14px;
    }

    .saved-timer-controls {
        width: 100%;
    }

        .saved-timer-controls button {
            flex: 1;
        }
}

/* ================================================================
   TEXT LINKS
================================================================ */

.current-round-name a,
.rounds-summary a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

    .current-round-name a:hover,
    .rounds-summary a:hover {
        color: #fff;
    }