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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #091f36;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Canvas */
#bubble-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* Splash screen */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: rgba(9, 31, 54, 0.85);
    transition: opacity 0.6s ease;
    touch-action: none;
}

#splash-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

#splash-content {
    text-align: center;
    color: #fff;
    padding: 2rem;
}

#splash-title {
    font-family: 'Georgia', serif;
    font-size: clamp(2.5rem, 7vw, 5rem);
    font-weight: 700;
    color: #7fdbda;
    text-shadow: 0 0 30px rgba(127, 219, 218, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3);
    margin-bottom: 0.3em;
    line-height: 1.1;
}

#splash-subtitle {
    font-family: 'Georgia', serif;
    font-size: clamp(1rem, 3vw, 1.8rem);
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 2em;
    font-style: italic;
}

#splash-cta {
    font-family: sans-serif;
    font-size: clamp(1.3rem, 4vw, 2.2rem);
    color: #fff;
    font-weight: 600;
    animation: pulse-cta 2s ease-in-out infinite;
    margin-bottom: 2em;
}

#splash-branding {
    font-family: sans-serif;
    font-size: clamp(0.7rem, 1.8vw, 1rem);
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.05em;
}

@keyframes pulse-cta {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

/* Answer overlay — radial reveal from pop position */
#answer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
    z-index: 50;
    background: rgba(9, 31, 54, 0.88);
    --pop-x: 50%;
    --pop-y: 50%;
    clip-path: circle(150% at var(--pop-x) var(--pop-y));
    transition: clip-path 0.4s ease-out, opacity 0.3s ease;
    padding: 2rem;
    overflow-y: auto;
    touch-action: none;
}

#answer-overlay.hidden {
    clip-path: circle(0% at var(--pop-x) var(--pop-y));
    opacity: 0;
    pointer-events: none;
}

#answer-content {
    max-width: 700px;
    width: 100%;
    text-align: center;
    color: #fff;
    font-family: sans-serif;
}

/* Answer type: bar-chart */
.bar-chart-title {
    font-size: clamp(1.3rem, 3.5vw, 2rem);
    font-weight: 700;
    color: #7fdbda;
    margin-bottom: 1.5rem;
}

.bar-row {
    display: flex;
    align-items: center;
    margin-bottom: 0.8rem;
    gap: 0.6rem;
}

.bar-icon {
    font-size: 1.8rem;
    width: 2.5rem;
    text-align: center;
    flex-shrink: 0;
}

.bar-label {
    width: 7rem;
    text-align: right;
    font-size: clamp(0.85rem, 2vw, 1.1rem);
    color: rgba(255, 255, 255, 0.9);
    flex-shrink: 0;
}

.bar-track {
    flex: 1;
    height: 2rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    overflow: hidden;
    position: relative;
}

.bar-fill {
    height: 100%;
    border-radius: 1rem;
    width: 0;
    transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.6rem;
}

.bar-value {
    font-size: clamp(0.7rem, 1.6vw, 0.9rem);
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.bar-fun-fact {
    margin-top: 1.5rem;
    font-size: clamp(0.95rem, 2.2vw, 1.2rem);
    color: rgba(255, 255, 255, 0.85);
    opacity: 0;
    transition: opacity 0.6s ease;
    line-height: 1.5;
}

.bar-fun-fact.visible {
    opacity: 1;
}

/* Answer type: big-reveal */
.big-reveal-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.big-reveal-label {
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.5rem;
}

.big-reveal-number {
    font-size: clamp(3rem, 10vw, 7rem);
    font-weight: 900;
    color: #7fdbda;
    text-shadow: 0 0 40px rgba(127, 219, 218, 0.6), 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: scale(0);
    animation: reveal-pop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    line-height: 1;
}

.big-reveal-unit {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
    color: #f4a261;
    margin-top: -0.3rem;
}

.big-reveal-comparison {
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    color: rgba(255, 255, 255, 0.85);
    opacity: 0;
    animation: fade-in-up 0.5s ease 0.8s forwards;
    line-height: 1.5;
    max-width: 500px;
}

@keyframes reveal-pop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

@keyframes fade-in-up {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Answer type: text-fact */
.text-fact-title {
    font-size: clamp(1.3rem, 3.5vw, 2rem);
    font-weight: 700;
    color: #7fdbda;
    margin-bottom: 1.5rem;
}

.text-fact-list {
    list-style: none;
    text-align: left;
    max-width: 550px;
    margin: 0 auto;
}

.text-fact-item {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    margin-bottom: 1rem;
    font-size: clamp(0.95rem, 2.2vw, 1.2rem);
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.text-fact-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.text-fact-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

/* Dismiss button */
#dismiss-btn {
    margin-top: 2rem;
    padding: 0.8rem 2.5rem;
    min-height: 48px;
    min-width: 140px;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    font-weight: 600;
    color: #fff;
    background: rgba(127, 219, 218, 0.25);
    border: 2px solid rgba(127, 219, 218, 0.5);
    border-radius: 2rem;
    cursor: pointer;
    transition: background 0.2s ease;
    font-family: sans-serif;
    -webkit-tap-highlight-color: transparent;
}

#dismiss-btn:active {
    background: rgba(127, 219, 218, 0.4);
}

/* Feedback button */
#finish-btn {
    position: fixed;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    left: calc(1rem + env(safe-area-inset-left, 0px));
    z-index: 200;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease, opacity 0.3s ease;
}

#finish-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

#finish-btn.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Mute button */
#mute-btn {
    position: fixed;
    top: calc(1rem + env(safe-area-inset-top, 0px));
    right: calc(1rem + env(safe-area-inset-right, 0px));
    z-index: 200;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease;
}

#mute-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

#mute-icon {
    pointer-events: none;
}

/* Answer type: icon-grid */
.icon-grid-title {
    font-size: clamp(1.3rem, 3.5vw, 2rem);
    font-weight: 700;
    color: #7fdbda;
    margin-bottom: 1.5rem;
}

.icon-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
    max-width: 450px;
    margin: 0 auto;
}

.icon-grid-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.2rem 0.8rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 1rem;
    opacity: 0;
    transform: scale(0.7) translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icon-grid-cell.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.icon-grid-emoji {
    font-size: clamp(2.5rem, 7vw, 3.5rem);
    line-height: 1;
}

.icon-grid-label {
    font-size: clamp(0.85rem, 2vw, 1.1rem);
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    line-height: 1.3;
}

/* Learn more links */
.learn-more {
    margin-top: 1.5rem;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.learn-more.visible {
    opacity: 1;
    transform: translateY(0);
}

.learn-more-label {
    font-size: clamp(0.75rem, 1.8vw, 0.9rem);
    color: rgba(127, 219, 218, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.6rem;
}

.learn-more-links {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.learn-more-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.6rem 1.4rem;
    min-height: 48px;
    font-size: clamp(0.9rem, 2.2vw, 1.1rem);
    font-weight: 600;
    font-family: sans-serif;
    color: #fff;
    background: linear-gradient(135deg, rgba(244, 162, 97, 0.5), rgba(224, 152, 80, 0.35));
    border: 1.5px solid rgba(244, 162, 97, 0.6);
    border-radius: 2rem;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    animation: link-glow 2.5s ease-in-out infinite;
}

.learn-more-link::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { left: -100%; }
    50% { left: 150%; }
}

@keyframes link-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(244, 162, 97, 0.2); }
    50% { box-shadow: 0 0 16px rgba(244, 162, 97, 0.4), 0 0 30px rgba(244, 162, 97, 0.15); }
}

.learn-more-link:active {
    background: linear-gradient(135deg, rgba(244, 162, 97, 0.7), rgba(224, 152, 80, 0.5));
    border-color: rgba(244, 162, 97, 0.9);
    transform: scale(0.96);
}

.learn-more-icon {
    font-size: 0.85em;
    opacity: 0.7;
}

/* Badge row (for big-reveal stats) */
.badge-row {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.5rem 0.8rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 0.8rem;
    min-width: 4.5rem;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.badge.visible {
    opacity: 1;
    transform: translateY(0);
}

.badge-highlight {
    background: rgba(127, 219, 218, 0.2);
    border: 1px solid rgba(127, 219, 218, 0.4);
}

.badge-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.badge-value {
    font-size: clamp(0.85rem, 2vw, 1.1rem);
    font-weight: 700;
    color: #7fdbda;
}

.badge-label {
    font-size: clamp(0.65rem, 1.5vw, 0.8rem);
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Idle countdown warning */
#idle-warning {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 150;
    background: rgba(9, 31, 54, 0.9);
    border: 1px solid rgba(127, 219, 218, 0.4);
    border-radius: 1.5rem;
    padding: 0.8rem 1.8rem;
    color: rgba(255, 255, 255, 0.9);
    font-family: sans-serif;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    white-space: nowrap;
    animation: idle-pulse 1s ease-in-out infinite;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

#idle-warning.hidden {
    display: none;
}

@keyframes idle-pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; border-color: rgba(127, 219, 218, 0.7); }
}

/* Exit survey overlay */
#exit-survey {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 160;
    background: rgba(9, 31, 54, 0.92);
    transition: opacity 0.4s ease;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

#exit-survey.hidden {
    opacity: 0;
    pointer-events: none;
}

#survey-content {
    max-width: 500px;
    width: 90%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
    margin: 0 auto;
    text-align: center;
    color: #fff;
    font-family: sans-serif;
    padding: 1rem 1.5rem;
}

#survey-content h2 {
    font-family: 'Georgia', serif;
    font-size: clamp(1.4rem, 4vw, 2rem);
    color: #7fdbda;
    margin-bottom: 0.8rem;
    text-shadow: 0 0 20px rgba(127, 219, 218, 0.4);
}

.survey-q {
    font-size: clamp(0.85rem, 2.2vw, 1.1rem);
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 0.4rem;
    margin-top: 0.8rem;
}

.survey-options {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
}

.survey-options button {
    min-height: 44px;
    padding: 0.4rem 0.8rem;
    font-size: clamp(0.8rem, 2vw, 0.95rem);
    font-family: sans-serif;
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(127, 219, 218, 0.3);
    border-radius: 0.8rem;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}

.survey-options button:active {
    transform: scale(0.96);
}

.survey-options button.selected {
    background: rgba(127, 219, 218, 0.25);
    border-color: #7fdbda;
    color: #7fdbda;
}

#survey-done {
    display: block;
    margin: 1rem auto 0;
    min-height: 44px;
    padding: 0.5rem 2rem;
    font-size: clamp(0.95rem, 2.5vw, 1.15rem);
    font-family: sans-serif;
    font-weight: 700;
    color: #fff;
    background: rgba(127, 219, 218, 0.3);
    border: 2px solid rgba(127, 219, 218, 0.6);
    border-radius: 2rem;
    cursor: pointer;
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

#survey-done:active {
    background: rgba(127, 219, 218, 0.5);
}

#survey-skip {
    display: block;
    margin: 1rem auto 0;
    min-height: 44px;
    padding: 0.6rem 2rem;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    font-family: sans-serif;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    background: transparent;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 2rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

#survey-skip:active {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

/* QR prompt overlay */
#qr-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 165;
    background: rgba(9, 31, 54, 0.92);
    transition: opacity 0.4s ease;
}

#qr-prompt.hidden {
    opacity: 0;
    pointer-events: none;
}

#qr-prompt-content {
    max-width: 360px;
    width: 90%;
    text-align: center;
    color: #fff;
    font-family: sans-serif;
    padding: 2rem;
}

#qr-prompt-content p {
    font-family: 'Georgia', serif;
    font-size: clamp(1.3rem, 4vw, 1.8rem);
    color: #7fdbda;
    margin-bottom: 1.5rem;
    text-shadow: 0 0 20px rgba(127, 219, 218, 0.4);
}

#qr-msform {
    display: block;
    margin: 0 auto 1.5rem;
    border-radius: 0.8rem;
    background: white;
    padding: 0.8rem;
}

#qr-dismiss {
    display: block;
    margin: 0 auto;
    min-height: 48px;
    padding: 0.6rem 2rem;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    font-family: sans-serif;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    background: transparent;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 2rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

#qr-dismiss:active {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

/* Data export overlay */
#data-export {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 250;
    background: rgba(9, 31, 54, 0.95);
    transition: opacity 0.3s ease;
}

#data-export.hidden {
    opacity: 0;
    pointer-events: none;
}

#export-content {
    max-width: 440px;
    width: 90%;
    text-align: center;
    color: #fff;
    font-family: sans-serif;
    padding: 2rem;
}

#export-content h2 {
    font-size: 1.6rem;
    color: #7fdbda;
    margin-bottom: 1rem;
}

#export-stats {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

#export-copy-btn,
#export-clear-btn,
#export-close-btn {
    display: block;
    width: 100%;
    margin-bottom: 0.8rem;
    padding: 0.7rem 1.5rem;
    min-height: 48px;
    font-size: 1rem;
    font-family: sans-serif;
    font-weight: 600;
    color: #fff;
    border: 2px solid rgba(127, 219, 218, 0.4);
    border-radius: 1.5rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease;
}

#export-copy-btn {
    background: rgba(127, 219, 218, 0.25);
}

#export-clear-btn {
    background: rgba(230, 57, 70, 0.25);
    border-color: rgba(230, 57, 70, 0.5);
}

#export-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}
