.thw-timewalk {
    --thw-ink: #24221d;
    --thw-muted: #69645b;
    --thw-paper: #f4efe4;
    --thw-paper-deep: #e9dfcd;
    --thw-line: rgba(36, 34, 29, 0.2);
    --thw-red: #d82b26;
    --thw-gold: #d9a700;
    --thw-blue: #263ed1;
    position: relative;
    isolation: isolate;
    width: min(100%, 1600px);
    margin: 0 auto;
    padding: clamp(22px, 4vw, 56px);
    overflow: hidden;
    border: 1px solid rgba(36, 34, 29, 0.16);
    background:
        radial-gradient(circle at 8% 0%, rgba(255, 255, 255, 0.9), transparent 34%),
        linear-gradient(145deg, #faf8f3 0%, var(--thw-paper) 70%, #efe6d6 100%);
    box-shadow: 0 24px 70px rgba(45, 37, 24, 0.12);
    color: var(--thw-ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

.thw-timewalk *,
.thw-timewalk *::before,
.thw-timewalk *::after {
    box-sizing: border-box;
}

.thw-timewalk button,
.thw-timewalk summary {
    font: inherit;
}

.thw-timewalk button {
    color: inherit;
}

.thw-header {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
    gap: clamp(22px, 4vw, 56px);
    align-items: end;
    margin-bottom: 30px;
}

.thw-eyebrow,
.thw-phase-card__kicker,
.thw-method-note__label {
    margin: 0 0 8px;
    color: #71644f;
    font-size: 0.73rem;
    font-weight: 750;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.thw-heading-copy h2 {
    margin: 0;
    max-width: 820px;
    color: #191815;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.05rem, 4.8vw, 4.9rem);
    font-weight: 500;
    letter-spacing: -0.045em;
    line-height: 0.98;
}

.thw-intro {
    max-width: 780px;
    margin: 18px 0 0;
    color: #4d4941;
    font-size: clamp(1rem, 1.35vw, 1.17rem);
}

.thw-method-note {
    padding: 18px 20px;
    border-left: 3px solid var(--thw-gold);
    background: rgba(255, 255, 255, 0.55);
}

.thw-method-note p {
    margin: 0;
    color: #565047;
    font-size: 0.92rem;
}

.thw-phase-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 12px;
    padding: 8px;
    border: 1px solid var(--thw-line);
    background: rgba(255, 255, 255, 0.52);
}

.thw-phase-tab {
    display: grid;
    grid-template-columns: 12px auto 1fr;
    gap: 10px;
    align-items: center;
    min-height: 62px;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 2px;
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: background-color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.thw-phase-tab:hover {
    background: rgba(255, 255, 255, 0.72);
}

.thw-phase-tab[aria-selected="true"] {
    border-color: rgba(36, 34, 29, 0.28);
    background: #fff;
    box-shadow: 0 7px 24px rgba(47, 39, 27, 0.08);
}

.thw-phase-tab:focus-visible,
.thw-toolbar button:focus-visible,
.thw-hotspot:focus-visible,
.thw-directory button:focus-visible,
.thw-room-card__close:focus-visible,
.thw-plan-stage:focus-visible {
    outline: 3px solid #111;
    outline-offset: 3px;
}

.thw-phase-tab__dot {
    width: 11px;
    height: 11px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    background: currentColor;
}

.thw-phase-tab--red { color: var(--thw-red); }
.thw-phase-tab--gold { color: #aa8000; }
.thw-phase-tab--blue { color: var(--thw-blue); }

.thw-phase-tab__year {
    color: var(--thw-ink);
    font-size: 1.08rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.thw-phase-tab__label {
    color: var(--thw-muted);
    font-size: 0.86rem;
}

.thw-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
}

.thw-playback,
.thw-view-options {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.thw-icon-button,
.thw-play-button,
.thw-option-button {
    min-height: 42px;
    border: 1px solid rgba(36, 34, 29, 0.24);
    background: rgba(255, 255, 255, 0.72);
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.thw-icon-button:hover,
.thw-play-button:hover,
.thw-option-button:hover {
    border-color: rgba(36, 34, 29, 0.5);
    background: #fff;
}

.thw-icon-button {
    width: 44px;
    padding: 0;
    font-size: 1.15rem;
}

.thw-play-button {
    min-width: 156px;
    padding: 8px 15px;
    color: #fff !important;
    background: var(--thw-ink);
    font-size: 0.88rem;
    font-weight: 750;
}

.thw-play-button:hover {
    background: #000;
}

.thw-option-button {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    padding: 8px 13px;
    color: #4f4a42;
    font-size: 0.82rem;
    font-weight: 700;
}

.thw-option-button__mark {
    width: 9px;
    height: 9px;
    border: 1px solid #756e64;
    border-radius: 50%;
    background: transparent;
}

.thw-option-button[aria-pressed="true"] .thw-option-button__mark {
    border-color: var(--thw-ink);
    background: var(--thw-ink);
    box-shadow: inset 0 0 0 2px #fff;
}

.thw-viewer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
}

.thw-plan-column {
    min-width: 0;
}

.thw-plan-stage {
    position: relative;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 1718 / 916;
    border: 1px solid rgba(36, 34, 29, 0.22);
    background: #fff;
    box-shadow: 0 16px 42px rgba(48, 39, 25, 0.11);
}

.thw-plan-stage img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.thw-reconstruction {
    position: absolute;
    z-index: 1;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.thw-reconstruction__group {
    opacity: 0;
    transition: opacity 640ms cubic-bezier(0.22, 1, 0.36, 1);
}

.thw-timewalk[data-phase="origin"] .thw-reconstruction__group--origin,
.thw-timewalk[data-phase="1755"] .thw-reconstruction__group--1755 {
    opacity: 1;
}

.thw-reconstruction__wall {
    fill: rgba(214, 205, 190, 0.13);
    stroke: #c8bba6;
    stroke-width: 16;
    stroke-linecap: square;
    stroke-linejoin: miter;
    vector-effect: non-scaling-stroke;
}

.thw-reconstruction__edge {
    fill: none;
    stroke: #5f584e;
    stroke-width: 2;
    stroke-dasharray: 9 7;
    stroke-linecap: square;
    stroke-linejoin: miter;
    vector-effect: non-scaling-stroke;
}

.thw-reconstruction-key {
    position: absolute;
    z-index: 4;
    top: 10px;
    left: 10px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 8px;
    border: 1px solid rgba(59, 53, 44, 0.2);
    background: rgba(255, 255, 255, 0.9);
    color: #5f584e;
    font-size: 12px;
    opacity: 1;
    transition: opacity 180ms ease;
}

.thw-timewalk[data-phase="1850"] .thw-reconstruction-key {
    pointer-events: none;
    opacity: 0;
}

.thw-reconstruction-key span {
    width: 30px;
    border-top: 4px solid #c8bba6;
    border-bottom: 1px dashed #5f584e;
}

.thw-plan-base {
    z-index: 1;
    opacity: 0;
    transition: opacity 640ms cubic-bezier(0.22, 1, 0.36, 1);
}

.thw-layer {
    z-index: 2;
    opacity: 0;
    transition: opacity 640ms cubic-bezier(0.22, 1, 0.36, 1);
}

.thw-timewalk[data-phase="origin"] .thw-layer--origin {
    opacity: 1;
}

.thw-timewalk[data-phase="1755"] .thw-layer--origin {
    opacity: 0.72;
}

.thw-timewalk[data-phase="1755"] .thw-layer--1755 {
    opacity: 1;
}

.thw-timewalk[data-phase="1850"] .thw-plan-base {
    opacity: 1;
}

.thw-timewalk[data-phase="1850"] .thw-layer--origin {
    opacity: 0.62;
}

.thw-timewalk[data-phase="1850"] .thw-layer--1755 {
    opacity: 0.8;
}

.thw-timewalk[data-phase="1850"] .thw-layer--1850 {
    opacity: 1;
}

.thw-hotspots {
    position: absolute;
    z-index: 3;
    inset: 0;
    transition: opacity 180ms ease;
}

.thw-timewalk[data-rooms="hidden"] .thw-hotspots {
    pointer-events: none;
    opacity: 0;
}

.thw-timewalk[data-phase="origin"] .thw-hotspot:not([data-room-phase="origin"]),
.thw-timewalk[data-phase="1755"] .thw-hotspot[data-room-phase="1850"] {
    pointer-events: none;
    opacity: 0;
}

.thw-hotspot {
    position: absolute;
    left: var(--thw-x);
    top: var(--thw-y);
    display: grid;
    place-items: center;
    width: clamp(28px, 2.1vw, 34px);
    min-width: clamp(28px, 2.1vw, 34px);
    height: clamp(28px, 2.1vw, 34px);
    min-height: clamp(28px, 2.1vw, 34px);
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.88);
    border-radius: 50%;
    background: rgba(28, 27, 24, 0.77);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.28);
    color: #fff !important;
    font-size: clamp(0.68rem, 0.78vw, 0.82rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.1;
    white-space: nowrap;
    transform: translate(-50%, -50%);
    cursor: pointer;
    transition: transform 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.thw-hotspot:hover,
.thw-hotspot.is-selected {
    z-index: 4;
    background: #000;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.78), 0 5px 16px rgba(0, 0, 0, 0.35);
    transform: translate(-50%, -50%) scale(1.2);
}

.thw-plan-hint {
    margin: 11px 2px 0;
    color: #686158;
    font-size: 0.8rem;
}

.thw-story-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(240px, 0.7fr);
    min-width: 0;
    border: 1px solid rgba(36, 34, 29, 0.2);
    background: rgba(255, 255, 255, 0.54);
}

.thw-phase-card,
.thw-room-card {
    position: relative;
    padding: clamp(20px, 2.5vw, 32px);
}

.thw-phase-card {
    min-height: 0;
}

.thw-timewalk:not(.has-selected-room) .thw-phase-card {
    grid-column: 1 / -1;
}

.thw-phase-card__year {
    margin: 0 0 8px;
    color: #191815;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.3rem, 4vw, 4.4rem);
    line-height: 0.95;
}

.thw-phase-card h3,
.thw-room-card h3 {
    margin: 0 0 12px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.2rem, 1.8vw, 1.65rem);
    font-weight: 500;
    line-height: 1.14;
}

.thw-phase-card p:last-of-type,
.thw-room-card p {
    color: #575149;
    font-size: 0.9rem;
}

.thw-progress {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-top: 30px;
}

.thw-progress span {
    height: 4px;
    background: #d6cdbc;
    transition: background-color 180ms ease, transform 180ms ease;
}

.thw-timewalk[data-phase="origin"] [data-progress-step="origin"] { background: var(--thw-red); }
.thw-timewalk[data-phase="1755"] [data-progress-step="origin"] { background: rgba(216, 43, 38, 0.5); }
.thw-timewalk[data-phase="1755"] [data-progress-step="1755"] { background: var(--thw-gold); }
.thw-timewalk[data-phase="1850"] [data-progress-step="origin"] { background: rgba(216, 43, 38, 0.5); }
.thw-timewalk[data-phase="1850"] [data-progress-step="1755"] { background: rgba(217, 167, 0, 0.62); }
.thw-timewalk[data-phase="1850"] [data-progress-step="1850"] { background: var(--thw-blue); }

.thw-room-card {
    border-left: 1px solid var(--thw-line);
    background: #fff;
}

.thw-room-card[hidden] {
    display: none;
}

.thw-room-card__close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 1.55rem;
    cursor: pointer;
}

.thw-room-card__number {
    margin: 0 0 4px !important;
    color: #756c5e !important;
    font-size: 0.75rem !important;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.thw-room-card__dimensions:empty {
    display: none;
}

.thw-room-card__dimensions {
    margin: 0 0 12px;
    color: #1f1d19 !important;
    font-weight: 750;
}

.thw-room-card__source {
    margin-bottom: 0;
    color: #777064 !important;
    font-size: 0.77rem !important;
}

.thw-key {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 19px 22px;
    border-top: 1px solid var(--thw-line);
    background: rgba(232, 222, 205, 0.56);
}

.thw-key__item {
    display: grid;
    grid-template-columns: 12px 1fr;
    gap: 10px;
    align-items: center;
    color: #5c554c;
    font-size: 0.78rem;
}

.thw-key__swatch {
    width: 11px;
    height: 11px;
    border: 1px solid rgba(0, 0, 0, 0.18);
}

.thw-key__swatch--red { background: var(--thw-red); }
.thw-key__swatch--gold { background: var(--thw-gold); }
.thw-key__swatch--blue { background: var(--thw-blue); }

.thw-directory {
    margin-top: 18px;
    border: 1px solid var(--thw-line);
    background: rgba(255, 255, 255, 0.56);
}

.thw-directory summary {
    padding: 16px 19px;
    color: #38342e;
    font-size: 0.9rem;
    font-weight: 750;
    cursor: pointer;
}

.thw-directory[open] summary {
    border-bottom: 1px solid var(--thw-line);
}

.thw-directory__list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    margin: 0;
    padding: 8px;
    list-style: none;
    counter-reset: none;
}

.thw-directory__list li {
    margin: 0;
    border-bottom: 1px solid rgba(36, 34, 29, 0.09);
}

.thw-directory__list li.is-selected {
    background: #fff;
    box-shadow: inset 3px 0 0 var(--thw-ink);
}

.thw-directory__list button {
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 8px;
    align-items: start;
    width: 100%;
    min-height: 54px;
    padding: 10px 12px;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.thw-directory__list button:hover {
    background: rgba(255, 255, 255, 0.82);
}

.thw-directory__number {
    color: #766f65;
    font-size: 0.76rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.thw-directory__list strong {
    display: block;
    color: #38342e;
    font-size: 0.83rem;
    font-weight: 720;
}

.thw-directory__list small {
    display: block;
    margin-top: 2px;
    color: #777064;
    font-size: 0.71rem;
}

.thw-noscript {
    padding: 12px 15px;
    border: 1px solid #b5473f;
    background: #fff4f2;
    color: #6b241f;
}

@media (max-width: 760px) {
    .thw-timewalk {
        padding: 20px 14px 26px;
    }

    .thw-header {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .thw-phase-tabs {
        grid-template-columns: 1fr;
    }

    .thw-phase-tab {
        grid-template-columns: 12px 62px 1fr;
        min-height: 50px;
    }

    .thw-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .thw-playback,
    .thw-view-options {
        justify-content: center;
    }

    .thw-plan-column {
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .thw-plan-stage {
        min-width: 760px;
    }

    .thw-plan-hint::after {
        content: " Swipe horizontally to inspect the full plan.";
    }

    .thw-story-panel {
        grid-template-columns: 1fr;
    }

    .thw-timewalk .thw-phase-card {
        grid-column: auto;
    }

    .thw-room-card,
    .thw-key {
        border-left: 0;
        border-top: 1px solid var(--thw-line);
    }

    .thw-key {
        grid-template-columns: 1fr;
    }

    .thw-directory__list {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 520px) {
    .thw-play-button {
        flex: 1;
        min-width: 0;
    }

    .thw-view-options {
        display: grid;
        grid-template-columns: 1fr;
    }

    .thw-option-button {
        justify-content: center;
    }

    .thw-directory__list {
        grid-template-columns: 1fr;
    }
}

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

@media (forced-colors: active) {
    .thw-hotspot,
    .thw-phase-tab__dot,
    .thw-key__swatch {
        forced-color-adjust: none;
    }
}
