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

:root {
    --blue: #1565C0;
    --blue-dark: #0D47A1;
    --blue-light: #42A5F5;
    --cyan: #26C6DA;
    --ink: #EAF2FB;
    --muted: #7fa3c8;
}

html, body { height: 100%; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--ink);
    background: radial-gradient(1200px 800px at 50% 38%, #0a2545 0%, #051529 45%, #01060e 100%);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    cursor: default;
}

.brand {
    position: fixed;
    top: 26px;
    left: 34px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 5;
}
.brand img { width: 44px; height: 44px; }
.brand span { font-size: 22px; font-weight: 300; letter-spacing: .4px; }
.brand b { font-weight: 800; color: var(--blue-light); }
.brand em { font-style: normal; font-weight: 300; color: var(--muted); margin-left: 6px; }

.lang-badge {
    position: fixed;
    top: 30px;
    right: 36px;
    padding: 8px 18px;
    border: 1px solid rgba(66,165,245,.5);
    border-radius: 999px;
    background: rgba(21,101,192,.18);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--blue-light);
    z-index: 5;
}

main {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding-bottom: 24px;
}

.orb-wrap { position: relative; width: min(46vh, 62vw, 480px); height: min(46vh, 62vw, 480px); }
#orb { width: 100%; height: 100%; display: block; }

.state-label {
    position: absolute;
    left: 50%;
    bottom: -6px;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 17px;
    font-weight: 300;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--muted);
    max-width: 94vw;
    text-align: center;
}

.hints {
    height: 30px;
    margin-top: 20px;
    font-size: 19px;
    font-weight: 300;
    color: rgba(127,163,200,.85);
    letter-spacing: .3px;
    transition: opacity .6s;
}

.captions {
    width: min(88vw, 1080px);
    min-height: 128px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
    text-align: center;
}
.cap { line-height: 1.45; }
.cap-q { font-size: 20px; color: var(--muted); font-style: italic; }
.cap-a {
    font-size: 26px;
    font-weight: 400;
    color: var(--ink);
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: none;
    scroll-behavior: smooth;
}
.cap-a::-webkit-scrollbar { display: none; }
.cap-a .chunk { opacity: .45; transition: opacity .5s; }
.cap-a .chunk.current { opacity: 1; }
.cap-a.finished .chunk { opacity: .9; }

.talk {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 46px;
    font-size: 22px;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
    border: 0;
    border-radius: 999px;
    box-shadow: 0 8px 40px rgba(21,101,192,.45);
    cursor: pointer;
    transition: transform .12s, box-shadow .2s;
    touch-action: none;
}
.talk:active, .talk.holding {
    transform: scale(.97);
    background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);
    box-shadow: 0 8px 48px rgba(211,47,47,.5);
}
.hold-hint { margin-top: 12px; font-size: 13px; color: rgba(127,163,200,.55); letter-spacing: 1px; }

.reset {
    position: fixed;
    right: 34px;
    bottom: 30px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 18px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    color: var(--muted);
    background: rgba(21,101,192,.10);
    border: 1px solid rgba(66,165,245,.35);
    border-radius: 999px;
    cursor: pointer;
    transition: color .2s, border-color .2s, background .2s;
    z-index: 5;
}
.reset:hover { color: var(--ink); border-color: rgba(66,165,245,.8); background: rgba(21,101,192,.25); }
.reset kbd {
    font-family: inherit;
    font-size: 11px;
    padding: 2px 7px;
    border: 1px solid rgba(127,163,200,.45);
    border-radius: 5px;
    color: rgba(127,163,200,.9);
}

.toast {
    position: fixed;
    bottom: 34px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(183,28,28,.92);
    color: #fff;
    padding: 14px 26px;
    border-radius: 12px;
    font-size: 17px;
    z-index: 10;
    box-shadow: 0 10px 40px rgba(0,0,0,.5);
}

/* ===== Small screens (phones / narrow tablets) ===== */
@media (max-width: 680px) {
    .brand { top: 12px; left: 14px; gap: 7px; }
    .brand img { width: 26px; height: 26px; }
    .brand span { font-size: 14px; }
    .brand em { display: none; }

    .lang-badge { top: 12px; right: 12px; padding: 4px 10px; font-size: 10px; letter-spacing: 1px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    main { gap: 3px; padding: 46px 0 10px; justify-content: flex-start; }

    /* The canvas becomes the fixed square and the wrap grows around canvas +
       label, so a wrapped label pushes content down instead of overlaying the
       ring or the hints below. */
    .orb-wrap {
        width: auto;
        height: auto;
        margin-top: 2vh;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    #orb { width: min(26vh, 52vw); height: min(26vh, 52vw); }
    .state-label {
        position: static;
        transform: none;
        margin-top: 10px;
        white-space: normal;
        font-size: 11px;
        letter-spacing: 1.4px;
        line-height: 1.5;
        width: 88vw;
    }

    .hints { margin-top: 14px; font-size: 13px; height: auto; min-height: 20px; padding: 0 16px; text-align: center; }

    .captions { width: 92vw; min-height: 0; flex: 1 1 auto; overflow: hidden; margin-top: 4px; gap: 6px; }
    .cap-q { font-size: 13px; }
    .cap-a { font-size: 15px; line-height: 1.5; max-height: none; flex: 1 1 auto; }

    .talk { padding: 13px 28px; font-size: 16px; margin-top: 6px; gap: 10px; }
    .talk svg { width: 20px; height: 20px; }
    .hold-hint { margin-top: 6px; font-size: 11px; }

    /* Icon-only reset, small and clear of the talk button */
    .reset { right: 10px; bottom: 10px; padding: 9px; border-radius: 50%; }
    .reset span, .reset kbd { display: none; }
    .reset svg { width: 15px; height: 15px; display: block; }

    /* Lifted above the corner reset button so they can never overlap */
    .toast { width: 78vw; text-align: center; font-size: 14px; padding: 11px 16px; bottom: 74px; }
}

/* Touch devices: the space-bar hint is meaningless */
@media (pointer: coarse) {
    .hold-hint { display: none; }
}

/* Short landscape screens: keep everything on one screen */
@media (max-height: 560px) {
    .orb-wrap { width: min(30vh, 30vw); height: min(30vh, 30vw); }
    #orb { width: 100%; height: 100%; }
    .state-label { display: none; }
    .hints { display: none; }
    .cap-a { font-size: 16px; max-height: 70px; }
    .talk { padding: 12px 28px; font-size: 16px; }
}
