:root {
    --ti-ink: #07101f;
    --ti-ink-2: #101a33;
    --ti-gold: #f3c86a;
    --ti-gold-2: #fff0af;
    --ti-parchment: #f7edcf;
    --ti-burgundy: #762d45;
    --ti-blue: #5db2d8;
    --ti-red: #ff4f5f;
    --ti-green: #68d391;
}

html.ti-lock,
body.ti-lock {
    overflow: hidden !important;
    overscroll-behavior: none;
}

.ti-shell,
.ti-shell * {
    box-sizing: border-box;
}

.ti-shell {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    width: 100vw;
    height: 100dvh;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 18%, rgba(92, 105, 170, 0.22), transparent 35%),
        linear-gradient(180deg, #060b17 0%, #0d1427 52%, #050811 100%);
    color: #fff;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    isolation: isolate;
    touch-action: none;
    user-select: none;
}

.ti-stage {
    position: relative;
    display: grid;
    grid-template-rows: 82px minmax(0, 1fr) auto;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.ti-hud {
    position: relative;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(150px, 1.35fr) minmax(92px, .7fr) minmax(164px, .8fr) minmax(92px, .7fr) minmax(120px, .75fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    min-height: 82px;
    border-bottom: 1px solid rgba(243, 200, 106, .35);
    background:
        linear-gradient(180deg, rgba(6, 10, 22, .98), rgba(11, 18, 38, .94)),
        repeating-linear-gradient(90deg, transparent 0 31px, rgba(255,255,255,.02) 31px 32px);
    box-shadow: 0 10px 34px rgba(0,0,0,.32);
}

.ti-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ti-brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 54px;
    flex: 0 0 auto;
    border: 2px solid var(--ti-gold);
    border-radius: 6px 6px 12px 12px;
    color: var(--ti-gold-2);
    background: linear-gradient(145deg, #2a2444, #12162d 65%, #5a243b);
    box-shadow: inset 0 0 0 3px rgba(243,200,106,.1), 0 0 22px rgba(243,200,106,.2);
    font-family: Georgia, serif;
    font-size: 28px;
    font-weight: 800;
}

.ti-brand-copy {
    min-width: 0;
    line-height: .88;
    letter-spacing: .06em;
}

.ti-brand-copy strong,
.ti-brand-copy em {
    display: block;
    white-space: nowrap;
}

.ti-brand-copy strong {
    color: #fff7d8;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(16px, 1.8vw, 23px);
}

.ti-brand-copy em {
    margin-top: 5px;
    color: var(--ti-gold);
    font-size: clamp(10px, 1vw, 13px);
    font-style: normal;
    font-weight: 900;
    letter-spacing: .26em;
}

.ti-stat {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    padding: 7px 10px;
    border-left: 1px solid rgba(255,255,255,.1);
}

.ti-stat span {
    color: rgba(255,255,255,.62);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.ti-stat strong {
    margin-top: 2px;
    overflow: hidden;
    color: #fff;
    font-family: "Courier New", monospace;
    font-size: clamp(18px, 2vw, 26px);
    letter-spacing: .04em;
    text-overflow: ellipsis;
}

.ti-clock {
    justify-self: center;
    min-width: 152px;
    padding: 7px 16px 5px;
    border: 2px solid rgba(255, 79, 95, .78);
    border-radius: 10px;
    color: #ff5a68;
    background: #09030a;
    box-shadow: inset 0 0 20px rgba(255,79,95,.16), 0 0 22px rgba(255,79,95,.13);
    font-family: "Courier New", monospace;
    font-size: clamp(30px, 4vw, 48px);
    font-weight: 900;
    line-height: 1;
    letter-spacing: .04em;
    text-align: center;
    text-shadow: 0 0 10px rgba(255, 79, 95, .65);
}

.ti-clock.is-urgent {
    animation: ti-clock-pulse .7s infinite alternate ease-in-out;
}

@keyframes ti-clock-pulse {
    from { transform: scale(1); box-shadow: inset 0 0 20px rgba(255,79,95,.16), 0 0 18px rgba(255,79,95,.15); }
    to { transform: scale(1.045); box-shadow: inset 0 0 24px rgba(255,79,95,.3), 0 0 30px rgba(255,79,95,.42); }
}

.ti-health {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 96px;
}

.ti-page-life {
    position: relative;
    width: 25px;
    height: 34px;
    border: 2px solid var(--ti-gold);
    border-radius: 3px 3px 8px 3px;
    background: linear-gradient(145deg, #fff0ba, #c58e44);
    box-shadow: 0 0 12px rgba(243,200,106,.25);
    transition: opacity .2s ease, filter .2s ease, transform .2s ease;
}

.ti-page-life::before,
.ti-page-life::after {
    content: "";
    position: absolute;
    left: 5px;
    right: 5px;
    height: 2px;
    background: rgba(72, 37, 30, .45);
}

.ti-page-life::before { top: 10px; }
.ti-page-life::after { top: 17px; }

.ti-page-life.is-lost {
    opacity: .2;
    filter: grayscale(1);
    transform: rotate(8deg) translateY(3px);
}

.ti-hud-actions {
    display: flex;
    gap: 7px;
}

.ti-icon-btn {
    display: grid;
    place-items: center;
    width: 39px;
    height: 39px;
    padding: 0;
    border: 1px solid rgba(243,200,106,.45);
    border-radius: 8px;
    color: #fff2c5;
    background: rgba(255,255,255,.045);
    font-size: 20px;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease;
}

.ti-icon-btn:hover,
.ti-icon-btn:focus-visible {
    background: rgba(243,200,106,.16);
    transform: translateY(-1px);
    outline: 2px solid rgba(243,200,106,.7);
    outline-offset: 2px;
}

.ti-canvas-wrap {
    position: relative;
    min-height: 0;
    overflow: hidden;
    background: #060b16;
}

.ti-canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: transparent;
}

.ti-wave-banner,
.ti-status {
    position: absolute;
    left: 50%;
    z-index: 8;
    pointer-events: none;
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
    transition: opacity .2s ease, transform .2s ease;
}

.ti-wave-banner {
    top: 32px;
    padding: 8px 18px;
    border: 1px solid rgba(243,200,106,.55);
    border-radius: 999px;
    color: #fff5cf;
    background: rgba(6, 10, 22, .86);
    box-shadow: 0 6px 28px rgba(0,0,0,.35);
    font-family: Georgia, serif;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.ti-status {
    bottom: 28px;
    padding: 10px 16px;
    border-radius: 10px;
    color: #fff;
    background: rgba(8, 13, 28, .88);
    font-weight: 800;
    box-shadow: 0 8px 28px rgba(0,0,0,.34);
}

.ti-wave-banner.is-visible,
.ti-status.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.ti-controls {
    display: none;
    grid-template-columns: 1fr 1.25fr 1fr;
    gap: 10px;
    min-height: 92px;
    padding: 9px max(12px, env(safe-area-inset-right)) calc(9px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border-top: 1px solid rgba(243,200,106,.28);
    background: linear-gradient(180deg, rgba(6,10,22,.98), #03050b);
}

.ti-controls button {
    min-height: 66px;
    border: 1px solid rgba(243,200,106,.55);
    border-radius: 16px;
    color: #fff6d3;
    background: linear-gradient(180deg, rgba(46,54,94,.96), rgba(20,25,51,.98));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.09), 0 7px 16px rgba(0,0,0,.25);
    font-size: 28px;
    font-weight: 900;
    touch-action: none;
}

.ti-controls button:active,
.ti-controls button.is-active {
    transform: translateY(2px);
    background: linear-gradient(180deg, rgba(90,55,95,.98), rgba(36,22,53,.98));
}

.ti-controls [data-ti-fire] {
    border-color: rgba(243,200,106,.9);
    color: #1a1424;
    background: linear-gradient(180deg, #fff0a9, #e2a94e);
}

.ti-controls [data-ti-fire] span {
    display: inline-block;
    font-size: 18px;
    letter-spacing: .14em;
}

.ti-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: clamp(14px, 3vw, 34px);
    overflow: auto;
    background:
        radial-gradient(circle at 50% 26%, rgba(69, 74, 132, .28), transparent 34%),
        rgba(2, 5, 13, .88);
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
}

.ti-overlay[hidden] {
    display: none !important;
}

.ti-panel {
    width: min(860px, 100%);
    max-height: min(88dvh, 820px);
    overflow: auto;
    padding: clamp(22px, 4vw, 42px);
    border: 1px solid rgba(243,200,106,.5);
    border-radius: 24px;
    background:
        linear-gradient(145deg, rgba(25, 30, 58, .98), rgba(8, 12, 27, .99)),
        repeating-linear-gradient(0deg, transparent 0 30px, rgba(255,255,255,.02) 30px 31px);
    box-shadow: 0 30px 90px rgba(0,0,0,.58), inset 0 0 0 4px rgba(243,200,106,.045);
}

.ti-intro-panel {
    width: min(720px, 100%);
    text-align: center;
}

.ti-seal {
    display: grid;
    place-items: center;
    width: 82px;
    height: 82px;
    margin: 0 auto 16px;
    border: 2px solid var(--ti-gold);
    border-radius: 50%;
    background: radial-gradient(circle, #8b3e54 0 43%, #311d37 44% 100%);
    box-shadow: 0 0 0 6px rgba(243,200,106,.08), 0 0 34px rgba(243,200,106,.24);
}

.ti-seal span {
    color: #fff2bd;
    font-family: Georgia, serif;
    font-size: 29px;
    font-weight: 900;
}

.ti-kicker {
    margin: 0 0 10px;
    color: var(--ti-gold);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .22em;
    text-transform: uppercase;
}

.ti-panel h1,
.ti-panel h2,
.ti-panel h3,
.ti-panel p {
    max-width: none;
}

.ti-panel h1 {
    margin: 0;
    color: #fff8dd;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(44px, 8vw, 78px);
    line-height: .95;
    letter-spacing: -.04em;
}

.ti-panel h2 {
    margin: 0 0 18px;
    color: #fff8dd;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(31px, 5vw, 50px);
    line-height: 1.02;
}

.ti-panel h3 {
    margin: 24px 0 15px;
    color: #fff;
    font-size: clamp(20px, 3vw, 28px);
    line-height: 1.25;
}

.ti-intro-panel > p:not(.ti-kicker):not(.ti-small) {
    width: min(570px, 100%);
    margin: 20px auto 0;
    color: rgba(255,255,255,.79);
    font-size: clamp(16px, 2.3vw, 20px);
    line-height: 1.55;
}

.ti-instructions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 28px 0;
}

.ti-instructions > div {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 7px;
    min-height: 76px;
    padding: 13px;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 14px;
    background: rgba(255,255,255,.035);
}

.ti-instructions span {
    width: 100%;
    color: rgba(255,255,255,.66);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.ti-instructions kbd,
.ti-instructions strong {
    min-width: 32px;
    padding: 7px 9px;
    border: 1px solid rgba(243,200,106,.5);
    border-radius: 7px;
    color: #fff2c1;
    background: #12182e;
    box-shadow: inset 0 -2px 0 rgba(0,0,0,.3);
    font: 800 14px/1 ui-monospace, monospace;
}

.ti-primary {
    min-width: 190px;
    padding: 15px 24px;
    border: 0;
    border-radius: 12px;
    color: #1d1424;
    background: linear-gradient(180deg, #fff2b5 0%, #e1aa4f 100%);
    box-shadow: 0 9px 24px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.75);
    font-size: 16px;
    font-weight: 950;
    letter-spacing: .08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform .15s ease, filter .15s ease;
}

.ti-primary:hover,
.ti-primary:focus-visible {
    transform: translateY(-2px);
    filter: brightness(1.06);
    outline: 3px solid rgba(255,242,181,.34);
    outline-offset: 3px;
}

.ti-small {
    margin: 17px 0 0;
    color: rgba(255,255,255,.45);
    font-size: 12px;
}

.ti-question-panel {
    width: min(920px, 100%);
}

.ti-question-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    color: var(--ti-gold);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.ti-passage,
.ti-reading {
    margin: 0 0 21px;
    padding: 19px 21px;
    border-left: 4px solid var(--ti-gold);
    border-radius: 0 12px 12px 0;
    color: #332719;
    background: linear-gradient(145deg, #fff9e7, #e9d7a9);
    box-shadow: 0 10px 26px rgba(0,0,0,.22);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(17px, 2.4vw, 22px);
    line-height: 1.55;
}

.ti-question-panel h2 {
    margin-bottom: 21px;
    color: #fff;
    font-family: inherit;
    font-size: clamp(24px, 3.6vw, 36px);
    line-height: 1.25;
}

.ti-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.ti-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 13px;
    min-height: 74px;
    padding: 14px 16px;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 13px;
    color: #fff;
    background: rgba(255,255,255,.05);
    text-align: left;
    font: inherit;
    font-size: clamp(14px, 2vw, 18px);
    font-weight: 750;
    line-height: 1.28;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.ti-option:hover,
.ti-option:focus-visible {
    border-color: rgba(243,200,106,.75);
    background: rgba(243,200,106,.1);
    transform: translateY(-1px);
    outline: none;
}

.ti-option:disabled {
    cursor: default;
}

.ti-option-index {
    display: grid;
    place-items: center;
    width: 31px;
    height: 31px;
    flex: 0 0 auto;
    border: 1px solid rgba(243,200,106,.45);
    border-radius: 8px;
    color: var(--ti-gold-2);
    background: rgba(0,0,0,.18);
    font-family: ui-monospace, monospace;
    font-weight: 900;
}

.ti-option.is-correct {
    border-color: rgba(104,211,145,.95);
    background: rgba(104,211,145,.18);
}

.ti-option.is-wrong {
    border-color: rgba(255,79,95,.9);
    background: rgba(255,79,95,.15);
}

.ti-feedback {
    margin-top: 18px;
    padding: 16px 18px;
    border: 1px solid rgba(243,200,106,.28);
    border-radius: 13px;
    background: rgba(0,0,0,.2);
}

.ti-feedback[hidden] {
    display: none;
}

.ti-feedback strong {
    display: block;
    color: var(--ti-gold-2);
    font-size: 20px;
}

.ti-feedback p {
    margin: 7px 0 0;
    color: rgba(255,255,255,.75);
    line-height: 1.5;
}

.ti-reading-panel {
    width: min(920px, 100%);
}

.ti-reading-panel .ti-options {
    margin-top: 15px;
}

.ti-reading-panel .ti-feedback .ti-primary {
    margin-top: 15px;
}

.ti-compact-panel {
    width: min(430px, 100%);
    text-align: center;
}

.ti-results-panel {
    width: min(760px, 100%);
    text-align: center;
}

.ti-results-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 24px 0;
}

.ti-results-grid > div {
    padding: 17px 10px;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 14px;
    background: rgba(255,255,255,.04);
}

.ti-results-grid span,
.ti-results-grid strong {
    display: block;
}

.ti-results-grid span {
    min-height: 30px;
    color: rgba(255,255,255,.58);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.ti-results-grid strong {
    margin-top: 4px;
    color: var(--ti-gold-2);
    font-family: ui-monospace, monospace;
    font-size: clamp(24px, 4vw, 38px);
}

.ti-result-message {
    margin: 0 auto 22px;
    color: rgba(255,255,255,.76);
    font-size: 17px;
    line-height: 1.5;
}

@media (pointer: coarse), (max-width: 900px) {
    .ti-stage {
        grid-template-rows: 68px minmax(0, 1fr) auto;
    }

    .ti-hud {
        grid-template-columns: minmax(120px, 1fr) minmax(118px, .7fr) minmax(94px, .6fr) auto;
        min-height: 68px;
        padding: 7px 10px;
        gap: 7px;
    }

    .ti-brand-mark {
        width: 34px;
        height: 44px;
        font-size: 22px;
    }

    .ti-brand-copy strong { font-size: 15px; }
    .ti-brand-copy em { font-size: 9px; letter-spacing: .16em; }

    .ti-stat-score,
    .ti-stat-accuracy {
        display: none;
    }

    .ti-clock {
        min-width: 118px;
        padding: 5px 10px 3px;
        font-size: 31px;
    }

    .ti-health {
        min-width: 88px;
        gap: 6px;
    }

    .ti-page-life {
        width: 21px;
        height: 29px;
    }

    .ti-icon-btn {
        width: 34px;
        height: 34px;
        font-size: 17px;
    }

    .ti-controls {
        display: grid;
    }

    .ti-results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 650px) {
    .ti-hud {
        grid-template-columns: minmax(96px, 1fr) minmax(108px, .8fr) auto;
    }

    .ti-health {
        display: none;
    }

    .ti-brand-copy em {
        display: none;
    }

    .ti-hud-actions [data-ti-fullscreen] {
        display: none;
    }

    .ti-panel {
        padding: 21px 16px;
        border-radius: 18px;
    }

    .ti-instructions {
        grid-template-columns: 1fr 1fr;
    }

    .ti-instructions > div:last-child {
        grid-column: 1 / -1;
    }

    .ti-options {
        grid-template-columns: 1fr;
    }

    .ti-question-topline {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }

    .ti-passage,
    .ti-reading {
        padding: 14px 15px;
        font-size: 16px;
    }

    .ti-controls {
        min-height: 84px;
    }

    .ti-controls button {
        min-height: 60px;
    }
}

@media (max-height: 620px) and (orientation: landscape) {
    .ti-stage {
        grid-template-rows: 58px minmax(0, 1fr) 66px;
    }

    .ti-hud {
        min-height: 58px;
        padding: 5px 10px;
    }

    .ti-brand-mark {
        width: 31px;
        height: 39px;
    }

    .ti-clock {
        font-size: 28px;
    }

    .ti-controls {
        min-height: 66px;
        padding-top: 5px;
        padding-bottom: calc(5px + env(safe-area-inset-bottom));
    }

    .ti-controls button {
        min-height: 50px;
    }

    .ti-panel {
        max-height: 92dvh;
        padding: 17px 20px;
    }

    .ti-panel h1 {
        font-size: 45px;
    }

    .ti-instructions {
        margin: 14px 0;
    }

    .ti-instructions > div {
        min-height: 58px;
        padding: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ti-shell *,
    .ti-shell *::before,
    .ti-shell *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .001ms !important;
    }
}

.ti-shell.is-portrait-world .ti-canvas {
    object-fit: fill;
}

@media (max-width: 650px) {
    .ti-wave-banner {
        top: 16px;
        max-width: calc(100% - 28px);
        padding: 7px 13px;
        font-size: 12px;
        letter-spacing: .06em;
        white-space: nowrap;
    }

    .ti-status {
        bottom: 18px;
        max-width: calc(100% - 28px);
        font-size: 13px;
        text-align: center;
    }
}
