* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: #1a1a1a;
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        sans-serif;
}

html.embedded,
html.embedded body {
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

html.embedded body {
    padding: 0;
    container-type: size;
    display: flex;
    align-items: center;
    justify-content: center;
}

html.embedded #card {
    width: 100%;
    height: 100%;
    max-width: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(0.75rem, 6cqmin, 2rem);
}
html.embedded #embed {
    display: none;
}

html.embedded h1 {
    font-size: clamp(14px, 7cqmin, 24px);
    margin-bottom: clamp(0.5rem, 5cqmin, 1.5rem);
    padding: 0 clamp(12px, 8cqmin, 28px);
}

html.embedded #time {
    font-size: clamp(20px, 13cqmin, 44px);
    margin-bottom: clamp(0.5rem, 5cqmin, 1.5rem);
}

html.embedded #time .unit {
    font-size: 0.5em;
}

html.embedded #body {
    min-height: 0;
}

@container (width >= 472px) and (height >= 312px) and (height <= 328px) {
    html.embedded #body {
        min-height: 152px;
    }
    html.embedded h1 {
        margin-bottom: 1.5rem;
    }
    html.embedded #time {
        margin-bottom: 1.5rem;
    }
}

html.embedded .btn-row button.action {
    font-size: clamp(11px, 4cqmin, 15px);
    padding: clamp(6px, 2.5cqmin, 10px);
}

#card {
    position: relative;
    background: #242424;
    border: 8px solid transparent;
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    background-image:
        linear-gradient(#242424, #242424),
        var(--border-gradient, linear-gradient(135deg, #4f8cff, #8a5bff));
    background-origin: border-box;
    background-clip: padding-box, border-box;
}

#palette {
    position: absolute;
    right: 24px;
    bottom: 24px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    border: 2px solid rgba(255, 255, 255, 0.35);
    transition: border-color 0.15s;
    z-index: 21;
}

#palette:hover {
    border-color: #f0f0f0;
}

#palette.active {
    border-color: #5b9cf6;
}

#colorPicker {
    position: absolute;
    right: 24px;
    bottom: 52px;
    transform-origin: bottom right;
    transform: scale(0.92);
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    padding: 16px;
    background: #242424;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    z-index: 20;
    opacity: 0;
    transition:
        opacity 0.18s ease,
        transform 0.18s ease;
}

#colorPicker.open {
    display: grid;
    opacity: 1;
    transform: scale(1);
}

.sphere {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    transition:
        transform 0.12s ease,
        box-shadow 0.12s ease;
}

.sphere:hover {
    transform: scale(1.12);
}

.sphere.selected {
    box-shadow: 0 0 0 3px #fff;
}

h1 {
    font-family: "Lora", Georgia, "Times New Roman", serif;
    font-size: 24px;
    font-weight: 500;
    color: #f0f0f0;
    margin-bottom: 1.5rem;
    text-align: center;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    padding: 0 28px;
}

#back,
#close,
#clock {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        sans-serif;
}

#back {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.35);
    text-decoration: none;
    font-size: 20px;
    line-height: 1;
    transition: color 0.15s;
    cursor: pointer;
}

#back:hover {
    color: #f0f0f0;
}

#close {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.35);
    font-size: 20px;
    line-height: 1;
    transition: color 0.15s;
    cursor: pointer;
}

#close:hover {
    color: #f0f0f0;
}

#embed {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.35);
    font-size: 14px;
    line-height: 1;
    transition: color 0.15s;
    cursor: pointer;
    user-select: none;
    font-family: monospace;
}

@media (max-width: 1000px), (pointer: coarse) {
    #embed {
        display: none;
    }
}

#embed:hover {
    color: #f0f0f0;
}

#embed.active {
    color: #5b9cf6;
}

#embedWrap {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
    transition:
        max-height 0.3s ease,
        opacity 0.2s ease,
        margin-top 0.3s ease;
}

#embedWrap.open {
    max-height: 180px;
    opacity: 1;
    margin-top: 1rem;
}

#embedCode {
    width: 100%;
    height: 92px;
    padding: 10px;
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #cfcfcf;
    font-family: monospace;
    font-size: 12px;
    resize: none;
    outline: none;
    color-scheme: dark;
}

#embedCode:focus {
    border-color: rgba(255, 255, 255, 0.3);
}

#embedCopy {
    margin-top: 8px;
    width: 100%;
    padding: 8px;
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition:
        color 0.15s,
        border-color 0.15s;
}

#embedCopy:hover {
    border-color: rgba(255, 255, 255, 0.35);
    color: #f0f0f0;
}

#embedCopy.copied {
    color: #6ee7b7;
    border-color: #6ee7b7;
}

#clock {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.35);
    font-size: 20px;
    line-height: 1;
    transition: color 0.15s;
    cursor: pointer;
    user-select: none;
}

#clock:hover {
    color: #f0f0f0;
}

#clock.active {
    color: #5b9cf6;
}

#startTimeWrap {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-bottom: 0;
    transition:
        max-height 0.25s ease,
        opacity 0.2s ease,
        margin-bottom 0.25s ease;
}

#startTimeWrap.open {
    max-height: 60px;
    opacity: 1;
    margin-bottom: 10px;
}

input[type="datetime-local"] {
    width: 100%;
    padding: 10px;
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #f0f0f0;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    color-scheme: dark;
}

input[type="datetime-local"]:focus {
    border-color: rgba(255, 255, 255, 0.3);
}

#body {
    min-height: 152px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

input[type="text"] {
    width: 100%;
    padding: 10px;
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #f0f0f0;
    font-size: 16px;
    font-family: inherit;
    outline: none;
}

input[type="text"]:focus {
    border-color: rgba(255, 255, 255, 0.3);
}

#time {
    font-family: monospace;
    font-size: 44px;
    font-weight: 500;
    color: #f0f0f0;
    text-align: center;
    letter-spacing: 1px;
    margin: 0 0 1.5rem;
}

#time .unit {
    font-size: 22px;
    color: rgba(255, 255, 255, 0.4);
    margin-left: 2px;
}

@keyframes flash {
    0%,
    100% {
        color: #f0f0f0;
    }
    50% {
        color: #6ee7b7;
    }
}

#time.flash {
    animation: flash 0.5s ease-in-out 3;
}

.btn-row {
    display: flex;
    gap: 10px;
}

button.action {
    flex: 1;
    padding: 10px;
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #f0f0f0;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    transition:
        border-color 0.15s,
        color 0.15s;
}

button.action:hover {
    border-color: rgba(255, 255, 255, 0.35);
}

#error {
    color: #f87171;
    font-size: 14px;
    text-align: center;
    margin-top: 1rem;
}
