:root {
    color-scheme: dark;
}

.clock-page {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
    background: #02070b;
}

.clock-page .sound-toggle {
    bottom: clamp(64px, 8vh, 84px);
}

#abyss {
    position: fixed;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.clock-back-link {
    position: fixed;
    top: clamp(12px, 2vmin, 24px);
    left: clamp(12px, 2vmin, 24px);
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(129, 255, 239, 0.18);
    border-radius: 8px;
    color: rgba(233, 255, 249, 0.74);
    background: rgba(3, 12, 17, 0.48);
    text-decoration: none;
    font-size: clamp(0.72rem, 1vw, 0.88rem);
    backdrop-filter: blur(10px);
}

.clock-back-link:hover {
    color: #31ffe7;
    border-color: rgba(49, 255, 231, 0.46);
}

.clock-back-link svg {
    width: 16px;
    height: 16px;
}

.clock-hud {
    position: fixed;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    padding: clamp(12px, 2.4vmin, 34px);
}

.readout {
    align-self: end;
    justify-self: start;
    width: min(clamp(300px, 40vw, 580px), calc(100vw - 24px));
    padding: clamp(10px, 1.2vw, 16px) clamp(12px, 1.4vw, 18px);
    border: 1px solid rgba(129, 255, 239, 0.28);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(3, 12, 17, 0.78), rgba(8, 47, 54, 0.48)),
        linear-gradient(90deg, rgba(28, 255, 231, 0.1), rgba(255, 184, 77, 0.08));
    box-shadow:
        0 0 42px rgba(19, 232, 219, 0.18),
        inset 0 0 26px rgba(125, 255, 242, 0.06);
    backdrop-filter: blur(12px);
}

.mode-tabs {
    pointer-events: auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(4px, 0.5vw, 6px);
    margin-bottom: clamp(8px, 0.9vw, 12px);
    padding: 3px;
    border: 1px solid rgba(129, 255, 239, 0.16);
    border-radius: 8px;
    background: rgba(1, 12, 17, 0.54);
}

.mode-tab,
.preset-row button,
.command-row button {
    pointer-events: auto;
    min-width: 0;
    min-height: clamp(28px, 2.6vw, 34px);
    border: 1px solid rgba(129, 255, 239, 0.16);
    border-radius: 6px;
    background: rgba(8, 35, 43, 0.62);
    color: rgba(236, 255, 251, 0.82);
    font: inherit;
    font-size: clamp(0.64rem, 0.78vw, 0.78rem);
    font-weight: 650;
    letter-spacing: 0;
    cursor: pointer;
}

.mode-tab:hover,
.preset-row button:hover,
.command-row button:hover {
    border-color: rgba(49, 255, 231, 0.44);
    color: #f9fffc;
}

.command-row button:disabled {
    cursor: default;
    opacity: 0.48;
}

.mode-tab.is-active,
.command-row .primary-action {
    border-color: rgba(49, 255, 231, 0.58);
    background: linear-gradient(135deg, rgba(49, 255, 231, 0.24), rgba(255, 184, 77, 0.12));
    color: #ffffff;
    box-shadow: inset 0 0 16px rgba(49, 255, 231, 0.12);
}

.status-row {
    display: flex;
    align-items: center;
    gap: clamp(6px, 0.8vw, 9px);
    min-height: clamp(16px, 1.4vw, 20px);
    color: rgba(233, 255, 249, 0.82);
    font-size: clamp(0.66rem, 0.82vw, 0.78rem);
    letter-spacing: 0;
    text-transform: uppercase;
}

.status-dot {
    width: clamp(7px, 0.8vw, 10px);
    height: clamp(7px, 0.8vw, 10px);
    border-radius: 50%;
    background: #ffcc66;
    box-shadow: 0 0 16px #ffcc66;
}

.status-dot[data-state="locked"] {
    background: #31ffe7;
    box-shadow: 0 0 20px #31ffe7;
}

.status-dot[data-state="warn"] {
    background: #ff3864;
    box-shadow: 0 0 20px #ff3864;
}

.digital-time {
    margin-top: clamp(4px, 0.7vw, 8px);
    font-family: "SF Mono", "Cascadia Mono", Consolas, monospace;
    font-size: clamp(1.9rem, 4.2vw, 4.6rem);
    line-height: 0.98;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-shadow:
        0 0 14px rgba(49, 255, 231, 0.74),
        0 0 36px rgba(49, 255, 231, 0.34),
        0 0 2px rgba(255, 255, 255, 0.9);
}

.date-line {
    margin-top: clamp(4px, 0.7vw, 8px);
    color: rgba(242, 255, 251, 0.78);
    font-size: clamp(0.72rem, 1.05vw, 1rem);
}

.tool-panel {
    margin-top: clamp(9px, 1.1vw, 14px);
}

.timer-inputs {
    pointer-events: auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(6px, 0.75vw, 9px);
}

.timer-inputs label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: clamp(6px, 0.8vw, 8px);
    border: 1px solid rgba(129, 255, 239, 0.16);
    border-radius: 6px;
    background: rgba(3, 17, 24, 0.56);
}

.timer-inputs span,
.tool-hint span {
    color: rgba(183, 229, 220, 0.64);
    font-size: clamp(0.56rem, 0.7vw, 0.66rem);
    font-weight: 650;
    text-transform: uppercase;
}

.timer-inputs input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #f9fffc;
    font-family: "SF Mono", "Cascadia Mono", Consolas, monospace;
    font-size: clamp(0.84rem, 1.05vw, 1rem);
    font-variant-numeric: tabular-nums;
}

.preset-row,
.command-row {
    pointer-events: auto;
    display: grid;
    gap: clamp(5px, 0.65vw, 8px);
}

.preset-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: clamp(7px, 0.8vw, 10px);
}

.command-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: clamp(7px, 0.8vw, 10px);
}

#stopwatchPanel .command-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.lap-list {
    pointer-events: auto;
    display: grid;
    gap: 4px;
    max-height: clamp(54px, 11vh, 92px);
    margin: clamp(8px, 0.9vw, 12px) 0 0;
    padding: 0;
    overflow: auto;
    color: rgba(242, 255, 251, 0.82);
    font-family: "SF Mono", "Cascadia Mono", Consolas, monospace;
    font-size: clamp(0.62rem, 0.78vw, 0.76rem);
    list-style: none;
}

.lap-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    min-height: 18px;
    padding: 3px 0;
    border-top: 1px solid rgba(129, 255, 239, 0.1);
}

.tool-hint {
    margin-top: clamp(8px, 0.9vw, 11px);
    padding-top: clamp(6px, 0.8vw, 9px);
    border-top: 1px solid rgba(129, 255, 239, 0.16);
}

.tool-hint strong {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    color: #f9fffc;
    font-size: clamp(0.6rem, 0.78vw, 0.74rem);
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.meta-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(70px, 0.68fr) minmax(0, 1.22fr);
    gap: clamp(6px, 0.9vw, 10px);
    margin-top: clamp(9px, 1.2vw, 14px);
}

.meta-grid div {
    min-width: 0;
    padding-top: clamp(6px, 0.8vw, 9px);
    border-top: 1px solid rgba(129, 255, 239, 0.16);
}

.meta-grid span {
    display: block;
    color: rgba(183, 229, 220, 0.64);
    font-size: clamp(0.56rem, 0.72vw, 0.68rem);
    text-transform: uppercase;
}

.meta-grid strong {
    display: block;
    min-width: 0;
    margin-top: clamp(2px, 0.45vw, 4px);
    overflow: hidden;
    color: #f9fffc;
    font-size: clamp(0.62rem, 0.9vw, 0.82rem);
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.locate-button {
    pointer-events: auto;
    justify-self: end;
    align-self: end;
    display: inline-flex;
    align-items: center;
    gap: clamp(6px, 0.8vw, 9px);
    min-height: clamp(36px, 3.2vw, 44px);
    padding: 0 clamp(11px, 1.25vw, 16px);
    border: 1px solid rgba(255, 206, 121, 0.44);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(255, 184, 77, 0.18), rgba(24, 255, 231, 0.12));
    color: #fff8e8;
    font-size: clamp(0.76rem, 0.95vw, 0.92rem);
    box-shadow: 0 0 24px rgba(255, 184, 77, 0.16);
    cursor: pointer;
}

.locate-button[hidden] {
    display: none;
}

.locate-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.target-icon {
    position: relative;
    width: clamp(14px, 1.4vw, 17px);
    height: clamp(14px, 1.4vw, 17px);
    border: 2px solid currentColor;
    border-radius: 50%;
}

.target-icon::before,
.target-icon::after {
    content: "";
    position: absolute;
    background: currentColor;
}

.target-icon::before {
    left: calc(50% - 1px);
    top: -6px;
    width: 2px;
    height: calc(100% + 8px);
}

.target-icon::after {
    left: -6px;
    top: calc(50% - 1px);
    width: calc(100% + 8px);
    height: 2px;
}

@media (max-width: 960px), (max-height: 760px) {
    .clock-hud {
        padding: clamp(10px, 2vmin, 22px);
    }

    .readout {
        width: min(clamp(290px, 43vw, 460px), calc(100vw - 20px));
    }

    .status-row {
        font-size: clamp(0.62rem, 0.92vw, 0.72rem);
    }

    .digital-time {
        font-size: clamp(1.75rem, 4.55vw, 3.15rem);
    }

    .date-line {
        font-size: clamp(0.68rem, 1.2vw, 0.88rem);
    }

    .meta-grid {
        grid-template-columns: minmax(0, 1fr) minmax(66px, 0.7fr) minmax(0, 1.1fr);
    }

    .command-row button,
    .preset-row button,
    .mode-tab {
        min-height: 29px;
    }
}

@media (max-height: 620px) and (min-width: 721px) {
    .readout {
        width: min(clamp(280px, 37vw, 430px), calc(100vw - 20px));
    }

    .digital-time {
        font-size: clamp(1.6rem, 3.8vw, 2.8rem);
    }

    .mode-tabs {
        margin-bottom: 8px;
    }

    .meta-grid {
        margin-top: 10px;
    }

    .date-line {
        margin-top: 5px;
    }
}

@media (max-width: 720px) {
    .clock-hud {
        grid-template-rows: auto 1fr auto;
        align-items: end;
        padding-top: clamp(58px, 9vh, 74px);
    }

    .readout {
        align-self: end;
        width: min(clamp(280px, 52vw, 360px), calc(100vw - 20px));
    }

    .digital-time {
        font-size: clamp(1.45rem, 4.2vw, 2.4rem);
    }

    .timer-inputs {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .locate-button {
        justify-self: end;
        justify-content: center;
        margin-top: 12px;
    }
}

@media (max-width: 520px) {
    .readout {
        width: min(330px, calc(100vw - 18px));
    }

    .meta-grid {
        grid-template-columns: minmax(0, 1fr) minmax(68px, 0.72fr);
    }

    .meta-grid div:nth-child(3) {
        grid-column: 1 / -1;
    }

    .command-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #stopwatchPanel .command-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
