:root {
    --color-primary: #031E42;
    --color-accent: #009BB3;
    --color-accent-light: #00B0EA;
    --color-accent-mid: #0094A9;
    --color-accent-green: #009778;
    --color-white: #ffffff;
    --color-bg: #f5f7fa;
    --color-text: #031E42;
    --color-muted: #5a6b7d;
    --color-success: #009778;
    --color-danger: #c0392b;
    --shadow: 0 8px 32px rgba(3, 30, 66, 0.12);
    --radius: 20px;
    --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --touch-min: 72px;
}

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

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    background: var(--color-primary);
    color: var(--color-text);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
}

.screen.active {
    display: flex;
}

/* ---------- Slideshow ---------- */
#screen-slideshow {
    flex-direction: column;
    background: var(--color-white);
}

.slideshow-stage {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
    background: var(--color-white);
}

.slide-canvas {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    background: var(--color-white);
    flex: 0 0 auto;
}

.slide-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center center;
    background: var(--color-white);
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease-in-out;
    z-index: 1;
}

.slide-image.is-active {
    opacity: 1;
    z-index: 2;
}

.start-hotspot {
    position: absolute;
    inset: 0;
    z-index: 5;
    border: none;
    background: transparent;
    cursor: pointer;
}

.start-hotspot:focus-visible {
    outline: 4px solid var(--color-accent);
    outline-offset: -8px;
}

.start-hotspot[hidden] {
    display: none !important;
}

.slideshow-footer .btn[hidden] {
    visibility: hidden;
    pointer-events: none;
    display: inline-flex !important;
}

.slideshow-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 0.75rem 1.5rem;
    background: var(--color-primary);
    color: var(--color-white);
    height: 88px;
    min-height: 88px;
    max-height: 88px;
    flex: 0 0 88px;
    z-index: 10;
}

.slideshow-footer .dots {
    display: flex;
    gap: 0.85rem;
    align-items: center;
}

.dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.25);
    padding: 0;
    cursor: pointer;
    transition: background 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
    touch-action: manipulation;
}

.dot:hover,
.dot:focus-visible {
    background: rgba(255, 255, 255, 0.55);
    outline: none;
}

.dot.active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    transform: scale(1.2);
}

.btn {
    appearance: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    border-radius: 999px;
    padding: 1rem 2rem;
    font-size: 1.15rem;
    min-height: var(--touch-min);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, filter 0.15s ease;
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-touch {
    min-height: 80px;
    padding: 1.1rem 2.4rem;
    font-size: 1.35rem;
}

.btn-primary {
    background: var(--color-accent);
    color: var(--color-white);
    box-shadow: 0 4px 16px rgba(0, 155, 179, 0.35);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-white);
    border: 2px solid rgba(255, 255, 255, 0.45);
}

.btn-ghost:active:not(:disabled) {
    background: rgba(0, 155, 179, 0.25);
    border-color: var(--color-accent);
}

/* ---------- Quiz ---------- */
#screen-quiz {
    flex-direction: column;
    background: var(--color-bg);
}

.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1rem 2rem;
    background: var(--color-primary);
    color: var(--color-white);
    min-height: 96px;
}

.quiz-header .meta {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-weight: 700;
}

.meta-title {
    font-size: 1.5rem;
}

.meta-progress {
    font-size: 1.35rem;
    padding: 0.55rem 1.1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
}

.quiz-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 0.85rem 2rem;
    background: var(--color-white);
    border-bottom: 1px solid rgba(3, 30, 66, 0.08);
}

.quiz-logo {
    height: 52px;
    width: auto;
    object-fit: contain;
    margin-left: auto;
}

.btn-abort {
    background: #fff;
    color: var(--color-primary);
    border: 2px solid rgba(3, 30, 66, 0.28);
    border-radius: 16px;
    min-width: 240px;
}

.btn-abort:active:not(:disabled) {
    border-color: var(--color-danger);
    color: var(--color-danger);
    background: #fef2f2;
}

.timer-wrap {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.timer-label {
    font-size: 1.15rem;
    font-weight: 600;
}

.timer-ring {
    width: 84px;
    height: 84px;
    position: relative;
    flex-shrink: 0;
}

.timer-ring svg {
    width: 100%;
    height: 100%;
    display: block;
    transform: rotate(-90deg);
}

.timer-ring circle {
    fill: none;
    stroke-width: 6;
}

.timer-ring .track {
    stroke: rgba(255, 255, 255, 0.2);
}

.timer-ring .progress {
    stroke: var(--color-accent);
    stroke-linecap: round;
    stroke-dasharray: 100;
    stroke-dashoffset: 0;
}

.timer-ring.warning .progress {
    stroke: #f59e0b;
}

.timer-ring.danger .progress {
    stroke: #ef4444;
}

.timer-value {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    pointer-events: none;
}

.quiz-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 1.5rem;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.email-frame {
    width: min(1400px, 100%);
    height: 100%;
    background: var(--color-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    align-items: stretch;
    justify-content: center;
    border: 1px solid rgba(3, 30, 66, 0.08);
    position: relative;
}

.email-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: auto;
}

.email-image[hidden],
.email-eml[hidden] {
    display: none !important;
}

.email-eml {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    background: #fff;
}

.eml-headers {
    flex-shrink: 0;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(3, 30, 66, 0.1);
    background: #f8fafc;
    display: grid;
    gap: 0.45rem;
}

.eml-row {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 0.75rem;
    align-items: baseline;
}

.eml-label {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
}

.eml-value {
    font-size: 1.05rem;
    color: var(--color-primary);
    word-break: break-word;
}

.eml-subject {
    font-weight: 700;
    font-size: 1.2rem;
}

.eml-body-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: #fff;
}

.eml-body {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

.eml-guard {
    position: absolute;
    inset: 0;
    z-index: 3;
    background: transparent;
    pointer-events: none;
}

.feedback-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(3, 30, 66, 0.55);
    z-index: 5;
}

.feedback-overlay.visible {
    display: flex;
    animation: fadeIn 0.25s ease;
}

.feedback-card {
    background: var(--color-white);
    border-radius: var(--radius);
    padding: 2.5rem 3rem;
    text-align: center;
    box-shadow: var(--shadow);
    min-width: min(420px, 90vw);
}

.feedback-card .icon {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    margin: 0 auto 1.25rem;
    font-size: 2.75rem;
    color: var(--color-white);
    font-weight: 700;
}

.feedback-card.correct .icon {
    background: var(--color-success);
}

.feedback-card.wrong .icon {
    background: var(--color-danger);
}

.feedback-card h2 {
    color: var(--color-primary);
    margin-bottom: 0.5rem;
    font-size: 2rem;
}

.feedback-card p {
    color: var(--color-muted);
    font-size: 1.25rem;
}

.quiz-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    padding: 1.25rem 1.75rem 1.5rem;
    background: var(--color-white);
    border-top: 1px solid rgba(3, 30, 66, 0.08);
    flex-shrink: 0;
}

.btn-answer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 120px;
    border-radius: 24px;
    padding: 1.25rem 1.5rem;
    color: var(--color-white);
    box-shadow: 0 8px 24px rgba(3, 30, 66, 0.18);
}

.btn-answer-title {
    font-size: clamp(1.4rem, 2.2vw, 2rem);
    font-weight: 800;
    line-height: 1.15;
}

.btn-answer-hint {
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    font-weight: 500;
    opacity: 0.9;
}

.btn-fake {
    background: var(--color-danger);
}

.btn-fake:active:not(:disabled) {
    filter: brightness(1.1);
}

.btn-real {
    background: var(--color-success);
}

.btn-real:active:not(:disabled) {
    filter: brightness(1.1);
}

/* ---------- Result ---------- */
#screen-result {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    background:
        linear-gradient(160deg, #031E42 0%, #0a3a5c 55%, #009BB3 100%);
    color: var(--color-white);
    text-align: center;
    padding: 2rem;
}

.result-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    padding: 3rem 3.5rem;
    min-width: min(520px, 100%);
}

.result-card h1 {
    font-size: clamp(1.75rem, 3.5vw, 2.5rem);
    margin-bottom: 0.75rem;
}

.result-score {
    font-size: clamp(3.5rem, 8vw, 5.5rem);
    font-weight: 800;
    color: var(--color-accent-light);
    line-height: 1;
    margin: 0.75rem 0 1rem;
}

.result-card p {
    opacity: 0.9;
    font-size: 1.35rem;
}

.result-countdown {
    font-size: 1.2rem;
    opacity: 0.75;
}

.app-version {
    position: fixed;
    left: 0.75rem;
    bottom: 0.55rem;
    z-index: 80;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.75);
    background: rgba(3, 30, 66, 0.55);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    pointer-events: none;
    font-variant-numeric: tabular-nums;
}

.offline-status {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 70;
    background: rgba(3, 30, 66, 0.92);
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: var(--shadow);
    max-width: 90%;
    text-align: center;
}

.offline-status[data-state="loading"] {
    background: rgba(0, 155, 179, 0.95);
}

.offline-status[data-state="ready"] {
    background: rgba(0, 151, 120, 0.95);
}

.offline-status[data-state="error"] {
    background: rgba(192, 57, 43, 0.95);
}

.footer-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-cache {
    min-height: 48px;
    padding: 0.55rem 1rem;
    font-size: 0.9rem;
    opacity: 0.85;
}

.error-banner {
    position: absolute;
    top: 4.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-danger);
    color: var(--color-white);
    padding: 1rem 1.5rem;
    border-radius: 14px;
    z-index: 60;
    display: none;
    max-width: 90%;
    text-align: center;
    box-shadow: var(--shadow);
    font-size: 1.15rem;
}

.error-banner.visible {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@media (max-width: 900px) {
    .quiz-actions {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }

    .btn-answer {
        min-height: 96px;
    }

    .btn-abort {
        min-width: 0;
    }
}
