:root {
    --bg: #07070d;
    --bg-2: #0f1020;
    --ink: #e9e7d8;
    --neon: #7cf9ff;
    --neon-dim: #3aa8b3;
    --hot: #ff5470;
    --bake: #c9a36a;

    /* Socotel S63 ivory palette */
    --body-light: #ede4d2;
    --body-mid:   #d8cbb1;
    --body-dark:  #a8997a;
    --body-shade: #6e6249;
    --chrome-1:   #f8f6ee;
    --chrome-2:   #b6ad9a;
    --chrome-3:   #5a5347;
    --ink-dark:   #1a1208;
    --plate-num:  #2b1f12;
    --hole-bg:    #1b140c;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 0%, #1a1330 0%, #07070d 55%, #000 100%);
    color: var(--ink);
    font-family: "Courier New", ui-monospace, monospace;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ---------- starfield ---------- */
.stars {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(1px 1px at 12% 22%, #fff, transparent 60%),
        radial-gradient(1px 1px at 78% 18%, #fff, transparent 60%),
        radial-gradient(1.5px 1.5px at 30% 70%, #fff, transparent 60%),
        radial-gradient(1px 1px at 65% 80%, #fff, transparent 60%),
        radial-gradient(1px 1px at 88% 55%, #fff, transparent 60%),
        radial-gradient(2px 2px at 5% 85%, #fff, transparent 60%),
        radial-gradient(1px 1px at 50% 35%, #fff, transparent 60%),
        radial-gradient(1.5px 1.5px at 22% 50%, #fff, transparent 60%),
        radial-gradient(1px 1px at 95% 15%, #fff, transparent 60%),
        radial-gradient(1px 1px at 40% 92%, #fff, transparent 60%);
    background-size: 100% 100%;
    z-index: 0;
    animation: drift 60s linear infinite;
    opacity: 0.7;
}
@keyframes drift {
    from { transform: translateY(0); }
    to { transform: translateY(-40px); }
}

/* ---------- main stage ---------- */
.phone-stage {
    position: relative;
    z-index: 1;
    max-width: 720px;
    margin: 0 auto;
    padding: 28px 18px 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.hud {
    text-align: center;
    width: 100%;
}
.hud h1 {
    margin: 0;
    font-size: 1.1rem;
    letter-spacing: 0.18em;
    color: var(--neon);
    text-shadow: 0 0 12px rgba(124, 249, 255, 0.45);
}
.hint {
    margin: 8px 0 0;
    font-size: 0.85rem;
    opacity: 0.75;
}
.hint strong {
    color: var(--bake);
    letter-spacing: 0.1em;
}

/* ---------- display ---------- */
.display {
    width: 100%;
    max-width: 480px;
    background: linear-gradient(180deg, #0c2a14 0%, #05140a 100%);
    border: 1px solid #1d4a2c;
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow:
        inset 0 0 24px rgba(0, 255, 120, 0.18),
        0 0 18px rgba(0, 0, 0, 0.5);
    font-family: "VT323", "Courier New", monospace;
}
.display-label {
    color: #6dd098;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    opacity: 0.7;
}
.display-number {
    flex: 1;
    color: #b8ffd0;
    font-size: 1.5rem;
    letter-spacing: 0.3em;
    text-shadow: 0 0 8px rgba(120, 255, 170, 0.6);
    word-spacing: 0.2em;
}
.clear-btn {
    background: transparent;
    border: 1px solid #2c5e3f;
    color: #6dd098;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.75rem;
    transition: all 0.2s;
}
.clear-btn:hover {
    background: rgba(108, 208, 152, 0.1);
    color: #b8ffd0;
}

/* ---------- phone body (Socotel S63) ---------- */
.phone {
    position: relative;
    width: min(94vw, 480px);
    height: min(78vw, 400px);
    background:
        radial-gradient(ellipse at 30% 18%, #f6efdc 0%, var(--body-light) 35%, var(--body-mid) 78%, var(--body-dark) 100%);
    border-radius: 22px 22px 28px 28px / 26px 26px 36px 36px;
    box-shadow:
        0 30px 60px rgba(0, 0, 0, 0.55),
        0 6px 0 var(--body-shade),
        inset 0 -10px 18px rgba(110, 98, 73, 0.4),
        inset 0 4px 0 rgba(255, 255, 255, 0.55);
    margin-top: 14px;
    overflow: hidden;
}
/* subtle texture/seam */
.phone::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background:
        linear-gradient(180deg, transparent 60%, rgba(110, 98, 73, 0.12) 100%);
    pointer-events: none;
}

/* horizontal handset resting on cradle prongs at the top */
.handset {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    width: 86%;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.5s cubic-bezier(.2,.9,.3,1.4);
    z-index: 5;
}
.handset.lifted {
    transform: translate(-44%, -80px) rotate(-18deg);
}

.handset .earpiece,
.handset .mouthpiece {
    width: 78px;
    height: 56px;
    background:
        radial-gradient(ellipse at 40% 30%, #2a2118 0%, #0d0905 85%);
    border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%;
    box-shadow:
        inset 0 -3px 8px rgba(0, 0, 0, 0.7),
        inset 0 3px 4px rgba(255, 240, 200, 0.08),
        0 10px 18px rgba(0, 0, 0, 0.45);
    position: relative;
}
.handset .earpiece::after,
.handset .mouthpiece::after {
    content: "";
    position: absolute;
    inset: 12px;
    border-radius: 50%;
    background:
        radial-gradient(circle, rgba(0, 0, 0, 0.85) 1.4px, transparent 1.6px) 0 0 / 7px 7px;
    opacity: 0.85;
}
.handset .bar {
    flex: 1;
    height: 26px;
    margin: 0 -6px;
    background:
        linear-gradient(180deg, #2a2118 0%, #18110a 50%, #0d0905 100%);
    border-radius: 14px / 18px;
    box-shadow:
        inset 0 -4px 8px rgba(0, 0, 0, 0.6),
        inset 0 2px 3px rgba(255, 240, 200, 0.08);
}

/* small chromed prongs on the body holding the handset */
.cradle-prong {
    position: absolute;
    top: 8px;
    width: 22px;
    height: 18px;
    background: linear-gradient(180deg, var(--chrome-1), var(--chrome-2) 60%, var(--chrome-3));
    border-radius: 6px 6px 3px 3px;
    box-shadow:
        inset 0 -3px 4px rgba(0, 0, 0, 0.4),
        0 2px 3px rgba(0, 0, 0, 0.4);
    z-index: 4;
}
.cradle-prong.cradle-left  { left: 14%; }
.cradle-prong.cradle-right { right: 14%; }

/* dial mounting plate (slightly recessed area on the body) */
.dial-plate {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    aspect-ratio: 1;
    border-radius: 50%;
    background:
        radial-gradient(circle, var(--body-mid) 0%, var(--body-dark) 100%);
    box-shadow:
        inset 0 4px 10px rgba(0, 0, 0, 0.35),
        inset 0 -2px 4px rgba(255, 255, 255, 0.4),
        0 1px 0 rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* the chrome ring + dial assembly */
.dial-housing {
    position: relative;
    width: 96%;
    aspect-ratio: 1;
    border-radius: 50%;
    /* chrome ring */
    background:
        conic-gradient(from 0deg,
            var(--chrome-1) 0deg, var(--chrome-2) 60deg,
            var(--chrome-1) 120deg, var(--chrome-3) 180deg,
            var(--chrome-1) 240deg, var(--chrome-2) 300deg,
            var(--chrome-1) 360deg);
    padding: 6%;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.5),
        inset 0 0 0 1px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
}

.finger-stop {
    position: absolute;
    top: 0;
    right: 4%;
    width: 22%;
    height: 22%;
    transform: rotate(36deg);
    pointer-events: none;
    z-index: 3;
}
.finger-stop path {
    fill: var(--chrome-3);
    stroke: rgba(0, 0, 0, 0.6);
    stroke-width: 1;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6));
}

/* numbers printed on the FIXED back-plate, visible between the holes */
.number-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
}
.number-ring .num {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 11%;
    aspect-ratio: 1;
    margin: -5.5% 0 0 -5.5%;
    color: var(--plate-num);
    font-family: "Times New Roman", "Georgia", serif;
    font-weight: bold;
    font-size: clamp(0.85rem, 3.2vw, 1.15rem);
    display: flex;
    align-items: center;
    justify-content: center;
    --angle: calc(-60deg + var(--i) * 30deg);
    --r: 47%;
    transform:
        rotate(var(--angle))
        translate(var(--r))
        rotate(calc(-1 * var(--angle)));
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* the rotating dial — translucent disc with cut holes */
.dial {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 35%,
            rgba(255, 255, 255, 0.32) 0%,
            rgba(255, 255, 255, 0.08) 50%,
            rgba(0, 0, 0, 0.18) 100%),
        rgba(40, 30, 18, 0.18);
    backdrop-filter: blur(0.5px);
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.35),
        inset 0 6px 18px rgba(255, 255, 255, 0.25),
        0 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.45s cubic-bezier(.45,.05,.55,.95);
    will-change: transform;
    z-index: 2;
}
.dial.spinning {
    transition: transform var(--spin-time, 0.6s) cubic-bezier(.4,.05,.55,.95);
}
.dial.returning {
    transition: transform var(--return-time, 1.2s) cubic-bezier(.45,.05,.55,.95);
}

.dial-face {
    position: absolute;
    inset: 0;
}

/* finger holes — empty cut-outs that go through the disc */
.hole {
    position: absolute;
    width: 16%;
    aspect-ratio: 1;
    top: 50%;
    left: 50%;
    margin: -8% 0 0 -8%;
    border: none;
    border-radius: 50%;
    background:
        radial-gradient(circle at 40% 40%,
            rgba(20, 14, 6, 0.95) 0%,
            rgba(0, 0, 0, 0.92) 80%);
    cursor: pointer;
    box-shadow:
        inset 0 3px 6px rgba(0, 0, 0, 0.85),
        inset 0 -1px 2px rgba(255, 230, 180, 0.06),
        0 0 0 1px rgba(0, 0, 0, 0.4);
    --angle: calc(-60deg + var(--i) * 30deg);
    --r: 35%;
    transform:
        rotate(var(--angle))
        translate(var(--r))
        rotate(calc(-1 * var(--angle)));
    transition: filter 0.15s;
}
.hole:hover  { filter: brightness(1.4); }
.hole:active { filter: brightness(0.6); }

/* center cap with logo */
.dial-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28%;
    height: 28%;
    margin: -14% 0 0 -14%;
    border-radius: 50%;
    background:
        radial-gradient(circle, var(--chrome-1) 0%, var(--chrome-2) 70%, var(--chrome-3) 100%);
    color: var(--ink-dark);
    font-family: "Helvetica", "Arial", sans-serif;
    font-size: 0.55rem;
    font-weight: bold;
    letter-spacing: 0.12em;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 0 -2px 4px rgba(0, 0, 0, 0.35),
        inset 0 2px 3px rgba(255, 255, 255, 0.6),
        0 1px 2px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 3;
}

/* card holder drawer at the bottom front */
.card-drawer {
    position: absolute;
    bottom: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: 32%;
    height: 26px;
    background:
        linear-gradient(180deg, #f9f3df 0%, #d8cbb1 100%);
    border-radius: 4px;
    box-shadow:
        inset 0 0 0 1px rgba(110, 98, 73, 0.35),
        0 2px 4px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.card-drawer::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 2px;
    width: 14px;
    height: 4px;
    margin-left: -7px;
    background: var(--chrome-3);
    border-radius: 2px;
}
.card-number {
    font-family: "Courier New", monospace;
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    color: var(--plate-num);
}

/* signal/status row */
.signal {
    margin-top: 10px;
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    color: var(--neon);
    text-transform: uppercase;
    opacity: 0.85;
}
.signal .dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--neon);
    box-shadow: 0 0 10px var(--neon);
    margin-right: 6px;
    vertical-align: middle;
    animation: pulse 1.5s ease-in-out infinite;
}
.signal.live .dot { background: var(--hot); box-shadow: 0 0 14px var(--hot); }
.signal.live { color: var(--hot); }
.signal.dialing .dot { background: var(--bake); box-shadow: 0 0 12px var(--bake); }
.signal.dialing { color: var(--bake); }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(0.7); }
}

/* ---------- alien overlay ---------- */
.overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 50% 50%, #0a0030 0%, #000 75%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadein 0.6s ease;
}
.overlay[hidden] { display: none; }
@keyframes fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.overlay-frame {
    position: relative;
    width: min(94vw, 720px);
    padding: 22px 24px 28px;
    border: 1px solid var(--neon);
    border-radius: 10px;
    background: rgba(8, 0, 24, 0.7);
    box-shadow:
        0 0 60px rgba(124, 249, 255, 0.3),
        inset 0 0 30px rgba(124, 249, 255, 0.08);
    backdrop-filter: blur(6px);
    overflow: hidden;
}

.scanlines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        180deg,
        rgba(124, 249, 255, 0.04) 0 2px,
        transparent 2px 4px
    );
    mix-blend-mode: screen;
    animation: scan 6s linear infinite;
}
@keyframes scan {
    from { transform: translateY(0); }
    to   { transform: translateY(40px); }
}

.overlay-status {
    color: var(--neon);
    letter-spacing: 0.2em;
    text-shadow: 0 0 10px rgba(124, 249, 255, 0.6);
    margin-bottom: 14px;
    font-size: 0.95rem;
}

.waveform {
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(124, 249, 255, 0.3);
    border-radius: 6px;
    padding: 4px;
}
#scope {
    width: 100%;
    height: 160px;
    display: block;
}

.subtitles {
    margin: 16px 0 14px;
    min-height: 3.2em;
    font-family: "VT323", "Courier New", monospace;
    font-size: 1.4rem;
    color: var(--ink);
    letter-spacing: 0.1em;
    text-shadow: 0 0 6px rgba(124, 249, 255, 0.4);
    line-height: 1.4;
    word-break: break-word;
}

.hangup {
    background: linear-gradient(180deg, #ff5470 0%, #b82a44 100%);
    border: none;
    color: #fff;
    padding: 10px 18px;
    border-radius: 6px;
    font-family: inherit;
    font-weight: bold;
    letter-spacing: 0.18em;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(255, 84, 112, 0.4);
    transition: transform 0.2s;
}
.hangup:hover { transform: translateY(-2px); }
.hangup:active { transform: translateY(1px); }

.meta {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--neon-dim);
    letter-spacing: 0.1em;
}
.meta em {
    font-style: normal;
    color: var(--neon);
}

@media (max-width: 480px) {
    .display-number { font-size: 1.1rem; letter-spacing: 0.18em; }
    .hud h1 { font-size: 0.92rem; }
    .subtitles { font-size: 1.1rem; }
}
