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

:root {
    --primary: #2196F3;
    --primary-dark: #1565C0;
    --primary-light: #64B5F6;
    --accent: #FF7043;
    --accent-dark: #E64A19;
    --accent-light: #FFAB91;
    --bg: #FFF8E1;
    --bg-card: #FFFFFF;
    --bg-dark: #F5E6C8;
    --success: #66BB6A;
    --success-light: #A5D6A7;
    --warning: #FFA726;
    --text: #37474F;
    --text-light: #78909C;
    --text-white: #FFFFFF;
    --shadow: rgba(0, 0, 0, 0.12);
    --shadow-strong: rgba(0, 0, 0, 0.2);
    --radius: 16px;
    --radius-lg: 24px;
    --radius-round: 50%;
    --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    --transition: 0.2s ease;

    /* Difficulty-themed gradients */
    --bg-easy: linear-gradient(135deg, #FFB3A7 0%, #FFC3A0 40%, #FFECB3 100%);
    --bg-medium: linear-gradient(135deg, #43CEA2 0%, #3BB2D0 40%, #185A9D 100%);
    --bg-hard: linear-gradient(135deg, #8E2DE2 0%, #6A1B9A 40%, #4A148C 100%);

    /* Underwater palette extras */
    --ocean-light: #E0F7FA;
    --ocean-mid: #4DD0E1;
    --ocean-deep: #006064;
    --coral: #FF8A80;
    --coral-dark: #D32F2F;
    --sand: #FFF8E1;
    --gold: #FFD700;
    --gold-dark: #FFA000;
    --bubble: rgba(255, 255, 255, 0.5);
}

/* Per-profile palettes — applied via #app[data-profile="<id>"] */
#app {
    /* Fallback defaults so vars always resolve */
    --profile-color:       #E91E63;
    --profile-color-dark:  #AD1457;
    --profile-color-light: #F8BBD0;
    --profile-gradient:    linear-gradient(135deg, #F06292 0%, #E91E63 50%, #AD1457 100%);
    --profile-gradient-v:  linear-gradient(180deg, #AD1457, #E91E63 40%, #F06292);
}
#app[data-profile="ziva"] {
    --profile-color:       #E91E63;
    --profile-color-dark:  #AD1457;
    --profile-color-light: #F8BBD0;
    --profile-gradient:    linear-gradient(135deg, #F06292 0%, #E91E63 50%, #AD1457 100%);
    --profile-gradient-v:  linear-gradient(180deg, #AD1457, #E91E63 40%, #F06292);
}
#app[data-profile="ava"] {
    --profile-color:       #00BCD4;
    --profile-color-dark:  #00838F;
    --profile-color-light: #B2EBF2;
    --profile-gradient:    linear-gradient(135deg, #4DD0E1 0%, #00BCD4 50%, #00838F 100%);
    --profile-gradient-v:  linear-gradient(180deg, #00838F, #00BCD4 40%, #4DD0E1);
}
#app[data-profile="ella"] {
    --profile-color:       #66BB6A;
    --profile-color-dark:  #2E7D32;
    --profile-color-light: #C8E6C9;
    --profile-gradient:    linear-gradient(135deg, #81C784 0%, #66BB6A 50%, #2E7D32 100%);
    --profile-gradient-v:  linear-gradient(180deg, #2E7D32, #66BB6A 40%, #81C784);
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    background: linear-gradient(170deg, #E0F7FA 0%, #B2EBF2 25%, #80DEEA 50%, #4DD0E1 75%, #00ACC1 100%);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    touch-action: manipulation;
}

#app {
    width: 100%;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

h1 {
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1.2;
}

h2 {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.3;
}

h3 {
    font-size: 1.35rem;
    font-weight: 600;
}

p {
    font-size: 1.2rem;
    line-height: 1.5;
}

/* -------------------------------------------------------------------------
   Heart-pip strip — shown in challenge & practice screen headers.
   Shakes on each wrong answer; fills from left to right.
   ------------------------------------------------------------------------- */
.challenge-header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.heart-strip {
    display: inline-flex;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.55);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    font-size: 1rem;
    line-height: 1;
}
.heart-pip {
    color: rgba(220, 60, 70, 0.25);
    transition: color 0.2s ease, transform 0.25s ease;
    transform: scale(1);
}
.heart-pip-filled {
    color: #E53935;
    text-shadow: 0 0 3px rgba(229, 57, 53, 0.5);
    transform: scale(1.15);
}

/* -------------------------------------------------------------------------
   Stacked island + profile-sidekick mascot
   ------------------------------------------------------------------------- */
.mascot-stack {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    cursor: pointer;
    min-width: 56px;
}
.mascot-stack .mascot-island {
    font-size: 2rem;
    line-height: 1;
}
.mascot-stack .mascot-profile {
    font-size: 1.3rem;
    margin-top: -6px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}
.mascot-speech {
    position: absolute;
    right: calc(100% + 6px);
    top: 4px;
    background: #FFF;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    pointer-events: none;
    transition: opacity 0.25s ease;
    max-width: 180px;
    white-space: normal;
    text-align: right;
}
.mascot-speech::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 12px;
    border: 6px solid transparent;
    border-left-color: #FFF;
    border-right: 0;
}

/* -------------------------------------------------------------------------
   Profile theme classes — light tints on body / cards when a profile theme
   class is applied. Island themes still render their own backgrounds.
   ------------------------------------------------------------------------- */
.theme-ziva .profile-deco,
.theme-ava  .profile-deco,
.theme-ella .profile-deco {
    position: absolute;
    pointer-events: none;
    opacity: 0.35;
    animation: float-gentle 4s ease-in-out infinite;
    user-select: none;
}
@keyframes float-gentle {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

/* Decorative sidekick floating next to greeting */
.islands-hello-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 12px 0;
}
.islands-hello {
    margin: 0;
    font-weight: 600;
    font-size: 1.15rem;
}
.islands-sidekick {
    font-size: 2.2rem;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.15));
}

/* Screen-wide ambient layer (non-interactive) */
.screen-ambient {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

/* Map header sidekick chip */
.map-header-sidekick {
    font-size: 1.4rem;
    margin-left: 4px;
    vertical-align: middle;
}

/* Results sidekick stack */
.results-mascot-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: -4px;
}
.results-sidekick {
    margin-top: -8px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

/* User-card sidekick (shown in users screen) */
.user-card {
    position: relative;
}
.user-card-sidekick {
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 1.6rem;
    opacity: 0.85;
}

/* Profile screen sidekick / accent */
.profile-card-sidekick {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 2rem;
    opacity: 0.9;
    animation: float-gentle 3s ease-in-out infinite;
}
.profile-card-accent {
    position: absolute;
    top: 10px;
    left: 12px;
    font-size: 1.6rem;
    opacity: 0.75;
}

/* -------------------------------------------------------------------------
   Lockout screen
   ------------------------------------------------------------------------- */
.lockout-screen {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    overflow: hidden;
    color: var(--text);
}
.lockout-ambient {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}
.lockout-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    text-align: center;
    max-width: 380px;
}
.lockout-mascot-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.lockout-speech {
    background: #FFF;
    padding: 10px 14px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    font-weight: 600;
    font-size: 1rem;
    max-width: 220px;
    position: relative;
}
.lockout-speech::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 18px;
    border: 8px solid transparent;
    border-left-color: #FFF;
    border-right: 0;
}
.lockout-mascot {
    position: relative;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lockout-mascot-main {
    font-size: 3.8rem;
    line-height: 1;
}
.lockout-mascot-side {
    position: absolute;
    bottom: -4px;
    right: -8px;
    font-size: 2rem;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
}
.lockout-timer-wrap {
    position: relative;
    width: 180px;
    height: 180px;
}
.lockout-ring {
    position: absolute;
    inset: 0;
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}
.lockout-ring-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.45);
    stroke-width: 8;
}
.lockout-ring-progress {
    fill: none;
    stroke: var(--profile-color, #E91E63);
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear;
}
.lockout-timer {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.6rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #FFF;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.lockout-encouragement {
    font-size: 1.05rem;
    font-weight: 600;
    color: #FFF;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.lockout-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}
.lockout-home-btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}
.lockout-home-mini {
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
    opacity: 0.9;
    margin-left: 6px;
}
.lockout-why-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.25);
    color: #FFF;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    margin-top: 4px;
}
.lockout-why-label {
    display: block;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 2px;
}
.lockout-modal {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 20px;
}
.lockout-modal[hidden] { display: none; }
.lockout-modal-card {
    background: #FFF;
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.lockout-modal-title {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 12px;
}
.lockout-modal-body {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 16px;
}
.lockout-release-caption {
    position: absolute;
    bottom: 32px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 800;
    color: #FFF;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    z-index: 2;
}

/* Theme-specific lockout backgrounds */
.theme-bg-crystal {
    background: linear-gradient(160deg, #6A1B9A 0%, #9C27B0 40%, #CE93D8 100%);
}
.theme-bg-pitch {
    background: linear-gradient(160deg, #1B5E20 0%, #388E3C 40%, #81C784 100%);
}
.theme-bg-forest {
    background: linear-gradient(160deg, #0D1B2A 0%, #1B263B 35%, #2E4057 70%, #4A6741 100%);
}
.theme-bg-jungle {
    background: linear-gradient(160deg, #3E2723 0%, #5D4037 30%, #6D8E4B 70%, #8BC34A 100%);
}

/* -------------------------------------------------------------------------
   Theme-tinted results / progress card surrounds — keeps results screen on
   theme so the celebration feels continuous with the island.
   ------------------------------------------------------------------------- */
.results-container.theme-ava {
    background:
        radial-gradient(ellipse at 50% -10%, rgba(255, 241, 118, 0.18) 0%, transparent 55%),
        linear-gradient(180deg, #1B263B 0%, #2E4057 60%, #4A6741 100%);
    color: #F5F5F0;
}
.results-container.theme-ava .results-message,
.results-container.theme-ava p {
    color: #F5F5F0;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}
.results-container.theme-ava .reward-badge {
    background: rgba(20, 30, 50, 0.55);
    color: #FFF8E1;
    border: 1.5px solid rgba(255, 235, 130, 0.4);
}
.results-container.theme-ziva {
    background:
        radial-gradient(ellipse at 50% -10%, rgba(206, 147, 216, 0.25) 0%, transparent 55%),
        linear-gradient(180deg, #4A148C 0%, #6A1B9A 60%, #9C27B0 100%);
    color: #FFF8E1;
}
.results-container.theme-ziva .results-message,
.results-container.theme-ziva p {
    color: #FFF8E1;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.results-container.theme-ziva .reward-badge {
    background: rgba(40, 10, 60, 0.55);
    color: #FFF8E1;
    border: 1.5px solid rgba(206, 147, 216, 0.5);
}
.results-container.theme-ella {
    background:
        radial-gradient(ellipse at 50% -10%, rgba(255, 204, 128, 0.25) 0%, transparent 55%),
        linear-gradient(180deg, #5D4037 0%, #6D8E4B 60%, #8BC34A 100%);
    color: #FFFDE7;
}
.results-container.theme-ella .results-message,
.results-container.theme-ella p {
    color: #FFFDE7;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.results-container.theme-ella .reward-badge {
    background: rgba(60, 30, 20, 0.55);
    color: #FFF8E1;
    border: 1.5px solid rgba(255, 204, 128, 0.45);
}
