:root {
    --bg: #0f172a;
    --text: #f8fafc;
    --muted: #94a3b8;
    --coffee: #ef4444;
    --coffee-hover: #f98181;
    --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5rem;
    padding: 1.5rem;
    margin: auto;
}

@media (max-width: 700px) {
    .container {
        margin-top: 3rem;
    }
    div.modal-content {
        padding: 0.4rem;
        font-size: 0.8rem;
    }
}

header {
    text-align: center;
}

h1 {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.4rem;
}

h2 {
    margin-bottom: 1rem;
}

p {
    color: var(--muted);
    font-size: 0.9rem;
}

.dial-container {
    position: relative;
    width: 68vmin;
    height: 68vmin;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
}

#dial {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    touch-action: none;
}

.segment {
    transform-box: fill-box;
    transform-origin: center;
    will-change: transform, filter;
    transition:
        filter 0.25s var(--bounce),
        transform 0.25s var(--bounce);
    cursor: pointer;
    outline: none;
}

.segment:hover {
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5)) brightness(1.25);
    transform: scale(1.08);
}

.segment:active {
    transform: scale(0.95);
    transition-duration: 0.1s;
}

.hour-label {
    fill: var(--muted);
    font-size: 13px;
    font-weight: 600;
    pointer-events: none;
    user-select: none;
}

.cup-layer {
    fill: var(--coffee);
    stroke: var(--coffee);
    stroke-width: 0.5;
    transform-box: view-box;
    transform-origin: 250px 250px;
    will-change: transform, filter;
    animation: popIn 0.5s var(--bounce) forwards;
    cursor: pointer;
    transition:
        fill 0.2s var(--bounce),
        stroke 0.2s var(--bounce),
        stroke-width 0.2s var(--bounce),
        filter 0.2s var(--bounce);
}

.cup-layer:hover {
    fill: var(--coffee-hover);
    stroke: var(--coffee-hover);
    filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.7));
}

.cup-layer:active {
    transform: scale(0.97);
    transition-duration: 0.1s;
}

.center-content {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10;
}

#center-cups {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.1rem;
}

#center-mg {
    font-size: 0.95rem;
    color: var(--coffee-hover);
    font-weight: 600;
    margin-bottom: 0.1rem;
}

#center-desc {
    font-size: 0.8rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

#reset-btn {
    pointer-events: auto;
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    transition: all 0.2s var(--bounce);
}

#reset-btn:hover {
    background: rgba(239, 68, 68, 0.4);
    color: #fff;
    transform: scale(1.05);
}

#reset-btn:active {
    transform: scale(0.95);
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.82);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

#tooltip {
    position: fixed;
    pointer-events: none;
    background: rgba(15, 23, 42, 0.95);
    color: var(--text);
    padding: 0.6rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.15s var(--bounce);
    z-index: 100;
    line-height: 1.4;
    transform: translate(-50%, calc(-100% - 30px));
}

#pi-link {
    position: absolute;
    bottom: 15px;
    right: 15px;
    color: var(--muted);
    font-family: serif;
    font-size: 1.2rem;
    cursor: default;
    opacity: 0.3;
    transition: opacity 0.2s;
    user-select: none;
}

#info-btn {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--text);
    font-family: serif;
    font-style: italic;
    cursor: pointer;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
    transition: all 0.2s var(--bounce);
}

#info-btn:hover {
    opacity: 1;
    color: var(--text);
    border-color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

#info-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
    text-align: center;
}

#info-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 2rem;
    border-radius: 0.75rem;
    max-width: 480px;
    width: 90%;
    max-height: 90%;
    overflow: auto;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    transform: translateY(0) scale(1);
    transition: transform 0.3s var(--bounce);
}

#info-modal-overlay.hidden .modal-content {
    transform: translateY(20px) scale(0.95);
}

.modal-content p {
    margin-bottom: 1rem;
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.5;
}

.accordion {
    margin-bottom: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    overflow: hidden;
    text-align: left;
}

.accordion summary {
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    transition: background 0.2s;
    font-size: 0.95rem;
    color: var(--text);
}

.accordion summary::-webkit-details-marker {
    display: none;
}

.accordion summary:hover {
    background: rgba(255, 255, 255, 0.08);
}

.accordion summary::after {
    content: "▼";
    font-size: 0.7rem;
    color: var(--muted);
    transition: transform 0.3s var(--bounce);
}

.accordion[open] summary::after {
    transform: rotate(180deg);
}

.accordion-content {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.accordion[open] .accordion-content {
    animation: fadeInDown 0.3s ease-out forwards;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.accordion-content p:last-of-type {
    margin-bottom: 0;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin: 1rem 0;
}

.data-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.4rem 0.5rem;
    border-radius: 0.4rem;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.data-card span {
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.2;
}

.data-card strong {
    font-size: 0.8rem;
    color: var(--text);
    white-space: nowrap;
}

.accordion-content small {
    margin-top: 1rem;
    display: block;
}

.settings-grid {
    display: grid;
    grid-template-columns: auto auto;
    gap: 0.75rem;
    align-items: center;
    justify-content: center;
    margin: 0 1.5rem 1.5rem;
    text-align: left;
    font-size: 0.95rem;
}

.settings-grid span:nth-child(odd) {
    text-align: right;
    color: var(--muted);
}

.settings-grid span:nth-child(even) {
    color: var(--text);
}

.modal-content hr {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 1.5rem 0;
}

.modal-content small {
    color: var(--muted);
    font-size: 0.75rem;
    line-height: 1.4;
    display: block;
}

.modal-content a {
    color: #60a5fa;
    text-decoration: none;
}

.modal-content a:hover {
    text-decoration: underline;
}

.inline-input {
    background: rgba(255, 255, 255, 0.05);
    color: #60a5fa;
    border: 1px dashed var(--muted);
    border-radius: 4px;
    padding: 0px 4px;
    font-size: 0.95rem;
    font-weight: bold;
    width: 3.5rem;
    text-align: center;
    font-family: inherit;
    transition: all 0.2s var(--bounce);
    display: inline-block;
}

.inline-input:focus {
    outline: none;
    border-color: #60a5fa;
    background: rgba(255, 255, 255, 0.15);
}

.inline-input::-webkit-outer-spin-button,
.inline-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.inline-input[type="number"] {
    -moz-appearance: textfield;
}

#close-modal-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

#close-modal-btn:hover {
    color: var(--text);
}
