/* ----- Reset & base ----- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;600;700&display=swap');

body {
    font-family: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
    background: #0a0a0f;
    color: #e0e0e0;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* Canvas background */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 0;
    pointer-events: none;
    display: block;
}

/* Overlay content */
.content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 560px;
    padding: clamp(8px, 2vw, 20px) clamp(8px, 2vw, 20px) clamp(12px, 3vw, 28px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    animation: fadeUp 1.2s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    opacity: 0;
    transform: translateY(16px);
}

@keyframes fadeUp {
    to { opacity: 1; transform: translateY(0); }
}

/* Card (glass) */
.card {
    background: rgba(10, 10, 18, 0.70);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border-radius: clamp(24px, 5vw, 44px);
    padding: clamp(14px, 3vw, 28px) clamp(14px, 3vw, 28px) clamp(18px, 3.5vw, 32px);
    width: 100%;
    border: 1px solid rgba(0, 255, 65, 0.10);
    box-shadow: 0 30px 70px -16px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(0, 255, 65, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    gap: clamp(12px, 3vw, 24px);
    width: 100%;
    margin-bottom: clamp(10px, 2.5vw, 18px);
    padding-bottom: clamp(8px, 1.8vw, 14px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.avatar {
    width: clamp(48px, 11vw, 68px);
    height: clamp(48px, 11vw, 68px);
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(0, 255, 65, 0.18), rgba(0, 200, 255, 0.06));
    border: 1.5px solid rgba(0, 255, 65, 0.20);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(22px, 5.5vw, 34px);
    font-weight: 700;
    color: #00ff41;
    text-shadow: 0 0 24px rgba(0, 255, 65, 0.20);
    flex-shrink: 0;
    user-select: none;
}

.avatar span {
    filter: drop-shadow(0 0 10px rgba(0, 255, 65, 0.25));
}

.name-wrap {
    flex: 1;
    min-width: 0;
}

.name {
    font-size: clamp(20px, 5.5vw, 34px);
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #00ff41 0%, #00ccff 80%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.15;
}

.tagline {
    font-size: clamp(12px, 2.6vw, 16px);
    font-weight: 300;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.4px;
    -webkit-text-fill-color: rgba(255, 255, 255, 0.35);
}

/* Rotary dial */
.dial-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 420px;
    margin: 0 auto 14px;
    touch-action: none;
}

.dial-container {
    position: relative;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: grab;
}

.dial-container:active {
    cursor: grabbing;
}

.dial-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    transition: none;
    touch-action: none;
    will-change: transform;
}

.dial-item {
    position: absolute;
    width: clamp(44px, 10vw, 64px);
    height: clamp(44px, 10vw, 64px);
    margin-left: calc(-1 * clamp(22px, 5vw, 32px));
    margin-top: calc(-1 * clamp(22px, 5vw, 32px));
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    border: 1.5px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: clamp(16px, 4vw, 26px);
    color: rgba(255, 255, 255, 0.50);
    transition: border-color 0.3s, background 0.3s, box-shadow 0.3s, transform 0.3s;
    backface-visibility: hidden;
    will-change: transform;
    pointer-events: none;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
    transform: scale(1);
}

.dial-item .item-label {
    font-size: clamp(6px, 1.4vw, 9px);
    font-weight: 600;
    letter-spacing: 0.3px;
    color: rgba(255, 255, 255, 0.30);
    margin-top: 1px;
    text-align: center;
    line-height: 1.1;
    max-width: 48px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dial-item.active {
    border-color: rgba(0, 255, 65, 0.60);
    background: rgba(0, 255, 65, 0.12);
    box-shadow: 0 0 40px rgba(0, 255, 65, 0.20), inset 0 0 30px rgba(0, 255, 65, 0.06);
    transform: scale(1.6) !important;
    color: #00ff41;
    z-index: 2;
}

.dial-item.active .item-label {
    color: rgba(0, 255, 65, 0.80);
}

/* Fixed finger-stop, sitting below the dial (south) — this is where a
   selected item actually lands (see dial.js selection math), so the
   indicator has to live here, not on the side. */
.dial-pointer {
    position: absolute;
    bottom: -10px;
    left: 50%;
    top: auto;
    transform: translateX(-50%) rotate(180deg);
    font-size: clamp(20px, 5vw, 34px);
    color: #00ff41;
    text-shadow: 0 0 30px rgba(0, 255, 65, 0.30), 0 0 60px rgba(0, 255, 65, 0.10);
    z-index: 10;
    pointer-events: none;
    filter: drop-shadow(0 0 8px rgba(0, 255, 65, 0.20));
    line-height: 1;
}

.dial-pointer svg {
    display: block;
    width: clamp(24px, 5vw, 36px);
    height: auto;
    fill: #00ff41;
    filter: drop-shadow(0 0 12px rgba(0, 255, 65, 0.25));
}

/* Little screw-head under the stop, like the metal peg on a real rotary
   dial that the finger rests against */
.dial-stop::after {
    content: '';
    position: absolute;
    left: 50%;
    top: -6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #00ff41;
    box-shadow: 0 0 8px rgba(0, 255, 65, 0.6);
    transform: translateX(-50%);
}

.dial-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    pointer-events: none;
    text-align: center;
    width: 50%;
    max-width: 160px;
}

.dial-center .selected-icon {
    font-size: clamp(28px, 7vw, 44px);
    display: block;
    margin-bottom: 2px;
    filter: drop-shadow(0 0 20px rgba(0, 255, 65, 0.15));
}

.dial-center .selected-label {
    font-size: clamp(13px, 3vw, 20px);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.2px;
    line-height: 1.2;
}

.dial-center .selected-action {
    font-size: clamp(10px, 2.2vw, 14px);
    font-weight: 400;
    color: #00ff41;
    word-break: break-all;
    margin-top: 2px;
    opacity: 0.80;
    border-bottom: 1px solid rgba(0, 255, 65, 0.15);
    display: inline-block;
    padding-bottom: 2px;
    max-width: 100%;
}

.dial-center .selected-hint {
    font-size: clamp(8px, 1.6vw, 11px);
    color: rgba(255, 255, 255, 0.20);
    margin-top: 4px;
    font-weight: 300;
    letter-spacing: 0.3px;
}

.dial-ring-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1.5px solid rgba(0, 255, 65, 0.06);
    box-shadow: inset 0 0 60px rgba(0, 255, 65, 0.02), 0 0 60px rgba(0, 255, 65, 0.01);
    pointer-events: none;
    background: radial-gradient(circle at 50% 50%, rgba(0, 255, 65, 0.02), transparent 70%);
}

.dial-ring-bg::after {
    content: '';
    position: absolute;
    top: 6%;
    left: 6%;
    right: 6%;
    bottom: 6%;
    border-radius: 50%;
    border: 1px solid rgba(0, 255, 65, 0.04);
    pointer-events: none;
}

/* "drag to dial" affordance — visible on load, dismissed on first touch */
.dial-hint {
    position: absolute;
    top: 4%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border-radius: 20px;
    background: rgba(0, 255, 65, 0.07);
    border: 1px solid rgba(0, 255, 65, 0.18);
    color: rgba(0, 255, 65, 0.65);
    font-size: clamp(9px, 2.1vw, 12px);
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    pointer-events: none;
    z-index: 6;
    opacity: 0;
    white-space: nowrap;
    animation: hintFadeIn 0.6s ease-out 0.8s forwards, hintPulse 1.8s ease-in-out 1.6s 3;
    transition: opacity 0.5s ease;
}

.dial-hint.hidden {
    opacity: 0 !important;
    transition: opacity 0.4s ease;
}

.dial-hint .hint-icon {
    display: inline-block;
    animation: hintSpin 1.4s linear infinite;
}

@keyframes hintFadeIn {
    to { opacity: 1; }
}

@keyframes hintPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

@keyframes hintSpin {
    to { transform: rotate(360deg); }
}

/* One-time nudge so the ring visibly rocks on load, signalling it spins */
@keyframes dialWiggle {
    0% { transform: rotate(0deg); }
    18% { transform: rotate(16deg); }
    38% { transform: rotate(-9deg); }
    58% { transform: rotate(6deg); }
    78% { transform: rotate(-3deg); }
    100% { transform: rotate(0deg); }
}

.dial-ring.hint-wiggle {
    animation: dialWiggle 1.4s cubic-bezier(0.33, 1, 0.68, 1) 0.9s 1;
    transform-origin: 50% 50%;
}

.dial-ticks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    pointer-events: none;
}

.dial-ticks .tick {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 6%;
    background: rgba(255, 255, 255, 0.04);
    transform-origin: 0 0;
    border-radius: 1px;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: clamp(10px, 2.5vw, 18px);
    font-size: clamp(10px, 2vw, 13px);
    color: rgba(255, 255, 255, 0.06);
    letter-spacing: 0.4px;
    font-weight: 300;
    border-top: 1px solid rgba(255, 255, 255, 0.02);
    padding-top: clamp(10px, 2vw, 16px);
    width: 100%;
}

.footer span {
    display: inline-block;
    opacity: 0.5;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .content { animation: none; opacity: 1; transform: none; }
    #bg-canvas { display: none; }
    .card { background: rgba(10, 10, 18, 0.92); }
    body { overflow: auto; }
    .dial-item { transition: none; }
    .dial-hint { animation: none; opacity: 1; }
    .dial-hint .hint-icon { animation: none; }
    .dial-ring.hint-wiggle { animation: none; }
}

/* Scrollbar hide */
::-webkit-scrollbar { width: 0; height: 0; }

/* Mobile overrides — on phones we go edge-to-edge and maximise the dial.
   The background/card chrome takes a back seat; the dial is the screen. */
@media screen and (max-width: 768px) {
    body { overflow: hidden; }
    #bg-canvas { opacity: 0.35; }

    .content {
        padding: max(6px, env(safe-area-inset-top, 0px)) 0 max(6px, env(safe-area-inset-bottom, 0px));
        max-width: 100%;
        height: 100dvh;
        min-height: 100dvh;
    }
    .card {
        padding: 6px 0 12px;
        border-radius: 0;
        height: 100%;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }
    .header {
        padding: 0 16px;
        gap: 10px;
        margin-bottom: 2px;
        padding-bottom: 6px;
        flex: 0 0 auto;
    }
    .avatar { width: 36px; height: 36px; font-size: 16px; }
    .name { font-size: 17px; }
    .tagline { font-size: 10.5px; -webkit-text-fill-color: rgba(255,255,255,0.45); }

    /* Size the dial to the largest square that fits the remaining space —
       width comes from the viewport, but it's capped by leftover height too,
       so it never stretches into an oval and always reads as a real dial. */
    .dial-wrapper {
        width: min(calc(100vw - 12px), calc(100dvh - 120px));
        max-width: none;
        aspect-ratio: 1 / 1;
        margin: auto auto;
        flex: 0 0 auto;
        padding: 0;
    }

    .dial-item { width: 62px !important; height: 62px !important; margin-left: -31px !important; margin-top: -31px !important; font-size: 27px !important; border-width: 1.5px; }
    .dial-item .item-label { display: block !important; font-size: 8.5px !important; max-width: 56px; white-space: normal !important; line-height: 1.05 !important; }
    .dial-item.active { transform: scale(1.5) !important; }
    .dial-pointer { bottom: -8px; }
    .dial-pointer svg { width: 30px; }
    .dial-center { width: 48%; max-width: 175px; }
    .dial-center .selected-icon { font-size: 40px; }
    .dial-center .selected-label { font-size: 21px; }
    .dial-center .selected-action { font-size: 13px; }
    .dial-center .selected-hint { font-size: 10px; }
    .dial-ring-bg { border-width: 1px; }
    .footer { display: none; }
}

@media screen and (max-width: 420px) {
    .avatar { width: 32px; height: 32px; font-size: 15px; }
    .name { font-size: 16px; }
    .tagline { font-size: 10px; }
    .dial-wrapper { width: min(calc(100vw - 8px), calc(100dvh - 108px)); }
    .dial-item { width: 56px !important; height: 56px !important; margin-left: -28px !important; margin-top: -28px !important; font-size: 24px !important; }
    .dial-item .item-label { font-size: 8.5px !important; }
    .dial-item.active { transform: scale(1.55) !important; }
    .dial-pointer svg { width: 26px; }
    .dial-center { max-width: 150px; }
    .dial-center .selected-icon { font-size: 34px; }
    .dial-center .selected-label { font-size: 17px; }
    .dial-center .selected-action { font-size: 12px; }
    .dial-center .selected-hint { font-size: 9px; }
}
