:root {
    --bg: #efe2c3;
    --surface: #fff8e8;
    --fg: #17353c;
    --muted: #746a56;
    --border: #b9a77e;
    --accent: #e44f38;

    --accent-soft: color-mix(in oklch, var(--accent) 16%, transparent);
    --fg-soft: color-mix(in oklch, var(--fg) 8%, transparent);
    --surface-soft: color-mix(in oklch, var(--surface) 72%, transparent);
    --font-display: "Cooper Black", "Iowan Old Style", Georgia, "Times New Roman", serif;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, monospace;
    --radius: 8px;
    --shadow: 8px 8px 0 var(--fg);
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

button, select, input {
    font: inherit;
}

button, select, input[type="range"], .hand-selector {
    cursor: pointer;
}

h1, h2, p {
    margin: 0;
}

h1, h2 {
    font-family: var(--font-display);
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

.page-shell {
    width: min(1500px, calc(100% - 32px));
    margin: 16px auto;
    background: var(--surface);
    border: 2px solid var(--fg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.header {
    position: relative;
    min-height: 240px;
    background: var(--surface);
    border-bottom: 2px solid var(--fg);
    overflow: hidden;
}

.header::after {
    content: "";
    position: absolute;
    right: clamp(80px, 12vw, 180px);
    top: 50%;
    width: 96px;
    aspect-ratio: 1;
    border: 2px solid var(--fg);
    border-radius: 50%;
    box-shadow:
        0 0 0 14px var(--surface),
        0 0 0 16px var(--fg),
        0 0 0 30px var(--surface),
        0 0 0 32px var(--fg),
        0 0 0 46px var(--surface),
        0 0 0 48px var(--fg);
    opacity: 0.12;
    transform: translate(50%, -50%);
    pointer-events: none;
}

.header-stripe {
    height: 18px;
    background: var(--accent);
    border-bottom: 2px solid var(--fg);
}

.header-inner {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: clamp(24px, 4vw, 64px);
    padding: clamp(32px, 5vw, 64px);
}

.label-mark {
    width: clamp(84px, 9vw, 124px);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border: 3px solid var(--fg);
    border-radius: 50%;
    background: var(--fg);
    color: var(--surface);
    box-shadow: inset 0 0 0 9px var(--surface), inset 0 0 0 12px var(--fg);
}

.label-mark span {
    font-family: var(--font-display);
    font-size: clamp(40px, 5vw, 68px);
    font-style: italic;
    transform: translateX(-2px);
}

.eyebrow,
.panel-stamp,
.catalog-meta,
.metric-label,
.setting > label:not(.hand-selector),
.setting-label,
.hand-badge,
.status,
.mono,
.track-number,
.footer {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.eyebrow {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.title {
    font-size: clamp(3rem, 7vw, 6.5rem);
    line-height: 0.82;
    letter-spacing: -0.055em;
}

.title span,
.title em {
    display: block;
}

.title em {
    margin-left: 0.45em;
    font-weight: 400;
}

.subtitle {
    margin-top: 20px;
    color: var(--muted);
    font-size: clamp(1rem, 1.7vw, 1.25rem);
    letter-spacing: 0.02em;
}

.header-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
}

.catalog-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.catalog-meta span:first-child {
    padding: 3px 8px;
    border: 1px solid var(--fg);
    border-radius: 999px;
    color: var(--fg);
}

.about-link {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-decoration: none;
    text-transform: uppercase;
}

.about-link:hover,
.about-link:focus-visible {
    color: var(--fg);
    text-decoration: underline;
    text-underline-offset: 4px;
}

.power-toggle {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    border: 1px solid var(--fg);
    border-radius: 999px;
    background: var(--fg);
    color: var(--surface);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.power-toggle:hover {
    background: var(--surface);
    color: var(--fg);
}

.power-toggle:focus-visible {
    outline: 3px solid var(--accent-soft);
    outline-offset: 3px;
}

.power-symbol {
    position: relative;
    width: 15px;
    height: 15px;
    border: 2px solid currentColor;
    border-radius: 50%;
}

.power-symbol::before {
    content: "";
    position: absolute;
    left: 50%;
    top: -4px;
    width: 2px;
    height: 8px;
    background: currentColor;
    box-shadow: 0 0 0 2px var(--fg);
    transform: translateX(-50%);
}

.power-toggle:hover .power-symbol::before {
    box-shadow: 0 0 0 2px var(--surface);
}

body.is-powered-off .power-toggle {
    background: var(--surface);
    color: var(--fg);
}

body.is-powered-off .power-toggle:hover {
    background: var(--fg);
    color: var(--surface);
}

body.is-powered-off .power-toggle .power-symbol::before {
    box-shadow: 0 0 0 2px var(--surface);
}

body.is-powered-off .power-toggle:hover .power-symbol::before {
    box-shadow: 0 0 0 2px var(--fg);
}

body.is-powered-off #webcam,
body.is-powered-off #overlay {
    opacity: 0.22;
}

body.is-powered-off .controls-panel {
    opacity: 0.64;
}

body.is-powered-off .record-light {
    background: var(--muted);
    opacity: 0.55;
}

.main {
    display: grid;
    grid-template-columns: minmax(0, 1.18fr) minmax(420px, 0.82fr);
    gap: clamp(28px, 4vw, 64px);
    padding: clamp(28px, 4vw, 60px);
    background: var(--bg);
    align-items: start;
}

.webcam-panel {
    position: sticky;
    top: 24px;
    min-width: 0;
}

.panel-heading,
.card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.panel-heading {
    margin-bottom: 18px;
}

.panel-heading h2,
.card-heading h2 {
    font-size: clamp(1.8rem, 3vw, 2.7rem);
    line-height: 1;
    letter-spacing: -0.03em;
}

.panel-stamp {
    flex: 0 0 auto;
    padding: 6px 9px;
    border: 1px solid var(--fg);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.webcam-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--fg);
    border: 3px solid var(--fg);
    box-shadow: var(--shadow);
}

#webcam,
#overlay {
    width: 100%;
    height: 100%;
    transform: scaleX(-1);
}

#webcam {
    display: block;
    object-fit: cover;
    filter: saturate(0.82) contrast(1.05) sepia(0.06);
}

#overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.no-camera {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 32px;
    background: color-mix(in oklch, var(--fg) 92%, transparent);
    color: var(--surface);
    text-align: center;
}

#no-camera-title {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    line-height: 1;
}

.no-camera .small {
    max-width: 42ch;
    color: color-mix(in oklch, var(--surface) 72%, transparent);
    font-size: 0.88rem;
}

.camera-retry {
    margin-top: 12px;
    padding: 10px 16px;
    border: 2px solid var(--surface);
    border-radius: var(--radius);
    background: transparent;
    color: var(--surface);
    font-weight: 700;
}

.camera-retry:hover {
    background: var(--surface);
    color: var(--fg);
}

.camera-retry:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.camera-retry:disabled {
    cursor: wait;
    opacity: 0.55;
}

.camera-retry[hidden] {
    display: none;
}

.stage-footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}

.card {
    padding: clamp(22px, 3vw, 34px);
    background: var(--surface);
    border: 2px solid var(--fg);
    border-radius: var(--radius);
    box-shadow: 5px 5px 0 var(--fg);
}

.card-heading {
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.card-heading.compact {
    margin-bottom: 8px;
}

.record-light {
    width: 14px;
    height: 14px;
    margin-top: 4px;
    border: 2px solid var(--fg);
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 0 0 4px var(--fg-soft);
}

.hand-row {
    padding: 14px 0;
}

.hand-row + .hand-row {
    border-top: 1px solid var(--border);
}

.hand-row.hidden {
    display: none;
}

.hand-badge {
    display: inline-flex;
    margin-bottom: 10px;
    padding: 3px 8px;
    border: 1px solid var(--fg);
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.hand-badge.coral {
    background: var(--fg);
    color: var(--surface);
}

.hand-badge.turquoise {
    background: transparent;
    color: var(--fg);
}

.metrics-row {
    display: grid;
    grid-template-columns: 1.4fr 0.8fr 0.8fr;
    gap: 16px;
}

.metric {
    min-width: 0;
}

.metric-label {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.metric-value {
    display: block;
    overflow: hidden;
    color: var(--fg);
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 2.2vw, 1.75rem);
    font-weight: 700;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.status-dot {
    width: 10px;
    height: 10px;
    border: 2px solid var(--muted);
    border-radius: 50%;
}

.status.active {
    color: var(--fg);
}

.status.active .status-dot {
    border-color: var(--accent);
    background: var(--accent);
    animation: pulse 1.4s ease-in-out infinite;
}

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

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px 14px;
}

.setting {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 7px;
}

.setting-wide {
    grid-column: span 2;
}

.setting > label:not(.hand-selector),
.setting-label {
    color: var(--muted);
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.setting > label:not(.hand-selector) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.setting-hint {
    color: var(--fg);
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}

.setting select {
    width: 100%;
    min-width: 0;
    padding: 9px 28px 9px 10px;
    border: 1px solid var(--fg);
    border-radius: 4px;
    background: var(--bg);
    color: var(--fg);
    font-size: 0.78rem;
    font-weight: 650;
}

.setting select:hover {
    background: var(--surface);
}

.setting select:focus-visible,
input[type="range"]:focus-visible,
.hand-selector input:focus-visible ~ .hand-option {
    outline: 3px solid var(--accent-soft);
    outline-offset: 2px;
}

input[type="range"] {
    width: 100%;
    height: 18px;
    margin: 3px 0 0;
    appearance: none;
    background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border: 1px solid var(--fg);
    background: var(--surface);
}

input[type="range"]::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
    margin-top: -8px;
    appearance: none;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--fg);
    box-shadow: 0 0 0 1px var(--fg);
}

input[type="range"]::-moz-range-track {
    height: 4px;
    border: 1px solid var(--fg);
    background: var(--surface);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--fg);
    box-shadow: 0 0 0 1px var(--fg);
}

.hands-setting {
    justify-content: flex-end;
}

.hand-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    border: 1px solid var(--fg);
    border-radius: 4px;
    overflow: hidden;
}

.hand-selector input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.hand-option {
    display: grid;
    min-height: 36px;
    padding: 6px 8px;
    place-items: center;
    background: var(--bg);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 800;
    line-height: 1.15;
    text-align: center;
    transition: background 160ms ease, color 160ms ease;
}

.hand-option + .hand-option {
    border-left: 1px solid var(--fg);
}

.hand-selector:hover .hand-option {
    color: var(--fg);
}

.hand-selector input:not(:checked) ~ .hand-option-one,
.hand-selector input:checked ~ .hand-option-two {
    background: var(--fg);
    color: var(--surface);
}

.setting-help {
    color: var(--muted);
    font-size: 0.68rem;
    line-height: 1.3;
}

.track-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.track-list li {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 14px;
    align-items: start;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.track-list li:last-child {
    border-bottom: 0;
}

.track-number {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.track-list div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.track-list strong {
    font-family: var(--font-display);
    font-size: 1rem;
}

.track-list div span {
    color: var(--muted);
    font-size: 0.8rem;
}

.about-section {
    padding: clamp(48px, 7vw, 88px) clamp(28px, 7vw, 104px);
    border-top: 2px solid var(--fg);
    background: var(--surface);
}

.about-inner {
    display: grid;
    grid-template-columns: minmax(180px, 0.65fr) minmax(0, 1.35fr);
    gap: clamp(36px, 7vw, 96px);
    align-items: center;
    max-width: 1040px;
    margin: 0 auto;
}

.maker-logo {
    display: block;
    width: min(100%, 280px);
    height: auto;
    object-fit: contain;
    transform: rotate(-4deg);
}

.about-copy h2 {
    max-width: 12ch;
    font-size: clamp(2.3rem, 5vw, 4.8rem);
    line-height: 0.95;
    letter-spacing: -0.04em;
}

.about-copy > p:not(.eyebrow) {
    max-width: 58ch;
    margin-top: 18px;
    color: var(--muted);
}

.about-copy .about-lead {
    color: var(--fg);
    font-family: var(--font-display);
    font-size: clamp(1.15rem, 2vw, 1.45rem);
    line-height: 1.35;
}

.maker-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
}

.maker-tags span {
    padding: 5px 10px;
    border: 1px solid var(--fg);
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.footer {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding: 20px clamp(28px, 4vw, 60px);
    border-top: 2px solid var(--fg);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

@media (max-width: 1060px) {
    .header-inner {
        grid-template-columns: auto 1fr;
    }

    .header-actions {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
    }

    .catalog-meta {
        display: none;
    }

    .main {
        grid-template-columns: 1fr;
    }

    .webcam-panel {
        position: static;
    }

    .settings-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    :root {
        --shadow: 5px 5px 0 var(--fg);
    }

    .page-shell {
        width: min(100% - 16px, 1500px);
        margin: 8px auto;
    }

    .header {
        min-height: 0;
    }

    .header::after {
        display: none;
    }

    .header-inner {
        grid-template-columns: 1fr;
        gap: 22px;
        padding: 28px 22px 34px;
    }

    .header-actions {
        grid-column: auto;
        width: 100%;
        justify-content: space-between;
    }

    .label-mark {
        width: 68px;
    }

    .title {
        font-size: clamp(3rem, 15vw, 4.7rem);
    }

    .title em {
        margin-left: 0.15em;
    }

    .main {
        gap: 38px;
        padding: 28px 18px 36px;
    }

    .about-section {
        padding: 46px 22px;
    }

    .about-inner {
        grid-template-columns: 1fr;
        gap: 34px;
    }

    .maker-logo {
        width: 170px;
    }

    .panel-heading,
    .card-heading {
        align-items: flex-end;
    }

    .stage-footer,
    .footer {
        flex-direction: column;
        gap: 6px;
    }

    .card {
        padding: 22px 18px;
        box-shadow: 4px 4px 0 var(--fg);
    }

    .settings-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .setting-wide {
        grid-column: span 2;
    }

    .hands-setting {
        justify-content: flex-end;
    }
}

@media (max-width: 420px) {
    .metrics-row {
        grid-template-columns: 1fr 1fr;
    }

    .metric:first-child {
        grid-column: span 2;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .setting-wide {
        grid-column: span 1;
    }

    .hands-setting {
        align-items: flex-start;
    }

    .panel-stamp {
        display: none;
    }
}

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