/* ==========================================================================
   KIBO ECO-CLIMB: EXPEDICAO MOCAMBIQUE
   Estilos Principais - Perspetiva Top-Down e Paineis Rigorosamente Centralizados
   Padrao Mocambique - Sem uso de emojis.
   ========================================================================== */

:root {
    --color-bg-dark: #f8fafc;
    --color-bg-panel: rgba(255, 255, 255, 0.96);
    --color-bg-card: #ffffff;
    --color-border: rgba(15, 23, 42, 0.12);
    --color-border-focus: #059669;

    --color-primary: #059669;
    --color-primary-hover: #047857;
    --color-amber: #d97706;
    --color-amber-hover: #b45309;
    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    --color-cyan: #0284c7;
    --color-blue: #2563eb;

    --color-text-main: #0f172a;
    --color-text-sub: #334155;
    --color-text-muted: #64748b;

    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --shadow-card: 0 12px 32px rgba(15, 23, 42, 0.09), 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-elevated: 0 20px 48px rgba(15, 23, 42, 0.16);
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--color-bg-dark);
    font-family: var(--font-main);
    color: var(--color-text-main);
}

/* Contentor Principal do Jogo */
.game-viewport {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #e0f2fe 0%, #bae6fd 100%);
    overflow: hidden;
}

/* Canvas da Simulacao Top-Down */
#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
}

/* Camada de Interface Superior (UI Layer) */
.ui-overlay-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.interactive {
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   1. ECRA INICIAL (HOME) - RIGOROSAMENTE CENTRALIZADO
   ========================================================================== */
.screen-home {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: radial-gradient(circle at center, rgba(240, 249, 255, 0.7) 0%, rgba(224, 242, 254, 0.92) 100%);
    backdrop-filter: blur(8px);
    z-index: 20;
    overflow-y: auto;
}

.home-main-centered-card {
    width: 100%;
    max-width: 520px;
    background: var(--color-bg-card);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
    box-shadow: var(--shadow-elevated);
    margin: auto;
}

.home-top-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.home-badge-country {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fef3c7;
    padding: 6px 14px;
    border-radius: var(--radius-lg);
    border: 1.5px solid rgba(217, 119, 6, 0.3);
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--color-amber);
}

.home-wallet-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ecfdf5;
    border: 1.5px solid rgba(5, 150, 105, 0.3);
    padding: 6px 16px;
    border-radius: var(--radius-lg);
    font-weight: 800;
    font-size: 1rem;
    color: var(--color-primary);
}

.home-body-grid {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.home-col-hero, .home-col-actions {
    width: 100%;
}

.home-center-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
}

.home-hero-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.home-logo-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 900;
    letter-spacing: -0.5px;
    text-transform: uppercase;
    background: linear-gradient(135deg, #d97706 0%, #059669 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 6px rgba(5, 150, 105, 0.2));
}

.home-subtitle {
    font-size: clamp(0.9rem, 1.8vw, 1.1rem);
    font-weight: 700;
    color: var(--color-text-sub);
    line-height: 1.4;
    max-width: 440px;
}

.home-hero-img-box {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: #ffffff;
    border: 4px solid #059669;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    box-shadow: 0 10px 24px rgba(5, 150, 105, 0.22);
    margin-top: 4px;
}

.home-hero-img-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.home-menu-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-primary-large {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #ffffff;
    font-family: var(--font-main);
    font-size: 1.2rem;
    font-weight: 800;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.35);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-primary-large:active {
    transform: scale(0.97);
}

.home-btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn-secondary {
    padding: 11px 16px;
    background: #f8fafc;
    border: 1.5px solid var(--color-border);
    color: var(--color-text-main);
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 800;
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
    transition: background 0.12s ease, transform 0.12s ease;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-secondary:active {
    transform: scale(0.97);
}

/* ==========================================================================
   2. ECRA DE SELECAO DE PROVINCIAS (STAGES) - CENTRALIZADO
   ========================================================================== */
.screen-stages {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--color-bg-panel);
    backdrop-filter: blur(12px);
    padding: 20px;
    z-index: 25;
    overflow-y: auto;
}

.stages-centered-container {
    max-width: 1080px;
    width: 100%;
    margin: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    width: 100%;
}

.stage-card {
    background: var(--color-bg-card);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.stage-card:hover {
    transform: translateY(-4px);
    border-color: var(--color-primary);
    box-shadow: 0 10px 24px rgba(5, 150, 105, 0.2);
}

.stage-badge {
    align-self: flex-start;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.badge-iniciante {
    background: rgba(5, 150, 105, 0.15);
    color: #047857;
}

.badge-medio {
    background: rgba(217, 119, 6, 0.15);
    color: #b45309;
}

.badge-avancado {
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
}

.stage-name {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--color-text-main);
}

.stage-province {
    font-size: 0.85rem;
    color: var(--color-amber);
    font-weight: 700;
}

.stage-description {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    line-height: 1.35;
    font-weight: 600;
}

.stage-best-score {
    font-size: 0.85rem;
    color: var(--color-cyan);
    font-weight: 800;
    margin-top: auto;
}

.stages-footer-actions {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 8px;
}

/* ==========================================================================
   3. ECRA DA OFICINA DO KIBO (UPGRADES) - CENTRALIZADO
   ========================================================================== */
.screen-workshop {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--color-bg-panel);
    backdrop-filter: blur(14px);
    padding: 20px;
    z-index: 25;
    overflow-y: auto;
}

.workshop-centered-container {
    max-width: 1000px;
    width: 100%;
    margin: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.workshop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.workshop-title {
    font-size: 1.7rem;
    font-weight: 900;
    color: var(--color-amber);
}

.workshop-container {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 18px;
    align-items: start;
    width: 100%;
}

@media (max-width: 820px) {
    .workshop-container {
        grid-template-columns: 1fr;
    }
}

.vehicle-preview-card {
    background: var(--color-bg-card);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-card);
}

.vehicle-selector-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.nav-arrow-btn {
    background: #f1f5f9;
    border: 1.5px solid var(--color-border);
    color: var(--color-text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.12s ease;
}

.nav-arrow-btn:hover {
    background: #e2e8f0;
}

.vehicle-name-tag {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--color-text-main);
    text-align: center;
}

.vehicle-canvas-display {
    width: 100%;
    height: 180px;
    background: radial-gradient(circle, #f0fdf4 0%, #e2e8f0 90%);
    border-radius: var(--radius-md);
    border: 1.5px solid var(--color-border);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.vehicle-desc-text {
    font-size: 0.9rem;
    color: var(--color-text-sub);
    text-align: center;
    line-height: 1.35;
    font-weight: 600;
}

.upgrades-list-card {
    background: var(--color-bg-card);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-card);
}

.upgrade-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border: 1.5px solid var(--color-border);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    gap: 10px;
}

.upgrade-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.upgrade-name {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--color-text-main);
}

.upgrade-meter-track {
    width: 100%;
    height: 7px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.upgrade-meter-fill {
    height: 100%;
    background: linear-gradient(90deg, #059669 0%, #10b981 100%);
    width: 20%;
    transition: width 0.25s ease;
}

.upgrade-level-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-weight: 700;
}

.btn-upgrade-action {
    padding: 8px 14px;
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-family: var(--font-main);
    font-weight: 800;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(217, 119, 6, 0.25);
}

.btn-upgrade-action:disabled {
    background: #cbd5e1;
    color: #64748b;
    cursor: not-allowed;
    box-shadow: none;
}

/* ==========================================================================
   4. INTERFACE DE JOGO (HUD - HEAD-UP DISPLAY)
   ========================================================================== */
.screen-hud {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 14px 18px;
    z-index: 15;
    pointer-events: none;
}

.hud-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.hud-left-metrics {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hud-pill {
    background: rgba(255, 255, 255, 0.94);
    border: 1.5px solid var(--color-border);
    backdrop-filter: blur(8px);
    padding: 5px 12px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 800;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.pill-distance { color: var(--color-cyan); }
.pill-coins { color: var(--color-primary); }

.hud-center-energy {
    flex: 1;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.energy-bar-capsule {
    width: 100%;
    height: 20px;
    background: #ffffff;
    border: 2px solid rgba(15, 23, 42, 0.15);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.energy-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #059669 0%, #f59e0b 80%, #d97706 100%);
    transition: width 0.1s linear, background 0.3s ease;
}

.energy-bar-fill.critical {
    background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
    animation: regenWarning 1s infinite;
}

.energy-label {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-sub);
}

.hud-right-actions {
    display: flex;
    gap: 8px;
}

.btn-hud-icon {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.94);
    border: 1.5px solid var(--color-border);
    color: var(--color-text-main);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-family: var(--font-main);
    font-weight: 800;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(8px);
}

.hud-telemetry-badge {
    position: absolute;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    background: rgba(255, 255, 255, 0.94);
    border: 1.5px solid var(--color-border);
    backdrop-filter: blur(10px);
    padding: 4px 16px;
    border-radius: 20px;
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--color-text-sub);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.10);
    z-index: 16;
    white-space: nowrap;
    max-width: 95%;
}

.telemetry-item {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.telemetry-val {
    color: var(--color-primary);
    font-weight: 900;
}

.hud-notification-banner {
    position: absolute;
    top: 92px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #ffffff;
    font-weight: 800;
    padding: 6px 18px;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(5, 150, 105, 0.3);
    pointer-events: none;
    font-size: 0.9rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 18;
}

.hud-notification-banner.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Controlos Inferiores: Painel de Direção e Pedais Top-Down */
.hud-bottom-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
    pointer-events: none;
    padding: 0 16px 10px 16px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    gap: 12px;
}

/* Controlos Esquerdos: Virar Esquerda / Direita Realistas */
.steering-controls-group {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    pointer-events: auto;
}

.steer-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.steer-btn-realistic {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    outline: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transform-origin: center center;
    transition: transform 0.08s ease, filter 0.08s ease;
    filter: drop-shadow(0 6px 14px rgba(15, 23, 42, 0.25));
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.steer-svg-img {
    width: 86px;
    height: 86px;
    display: block;
}

.steer-btn-realistic:active, .steer-btn-realistic.pressed {
    transform: scale(0.91) translateY(4px);
    filter: drop-shadow(0 2px 5px rgba(15, 23, 42, 0.4));
}

.steer-label-plate {
    position: absolute;
    bottom: -6px;
    padding: 3px 8px;
    border-radius: 6px;
    font-family: var(--font-main);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
    pointer-events: none;
    white-space: nowrap;
}

.label-steer {
    background: #0284c7;
    border: 1px solid #0369a1;
    color: #ffffff;
}

.pedals-controls-group {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    pointer-events: auto;
}

.pedal-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pedal-btn-realistic {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    outline: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transform-origin: bottom center;
    transition: transform 0.08s ease, filter 0.08s ease;
    filter: drop-shadow(0 6px 14px rgba(15, 23, 42, 0.22));
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.pedal-brake-img .pedal-svg-img {
    width: 90px;
    height: 90px;
    display: block;
}

.pedal-gas-img .pedal-svg-img {
    width: 74px;
    height: 120px;
    display: block;
}

.pedal-btn-realistic:active, .pedal-btn-realistic.pressed {
    transform: perspective(400px) rotateX(15deg) translateY(4px) scale(0.95);
    filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.35));
}

.pedal-label-plate {
    position: absolute;
    bottom: -6px;
    padding: 3px 8px;
    border-radius: 6px;
    font-family: var(--font-main);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
    pointer-events: none;
    white-space: nowrap;
}

.label-brake {
    background: #dc2626;
    border: 1px solid #b91c1c;
    color: #ffffff;
}

.label-gas {
    background: #059669;
    border: 1px solid #047857;
    color: #ffffff;
}

/* ==========================================================================
   5. MODAIS RIGOROSAMENTE CENTRALIZADOS
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 80;
    padding: 16px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    pointer-events: auto !important;
}

.modal-card {
    background: #ffffff;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    max-width: 500px;
    width: 100%;
    display: flex;
    flex-direction: column;
    text-align: center;
    gap: 14px;
    box-shadow: var(--shadow-elevated);
    position: relative;
    pointer-events: auto !important;
    margin: auto;
    max-height: 92vh;
    overflow-y: auto;
}

.modal-kibo-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.pause-stats-bar {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    background: #f8fafc;
    padding: 10px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--color-border);
}

.pause-stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.pause-stat-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    font-weight: 700;
    text-transform: uppercase;
}

.pause-stat-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--color-text-main);
}

.modal-header-tag {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--color-amber);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--color-text-main);
    line-height: 1.2;
}

.modal-body-text {
    font-size: 0.95rem;
    color: var(--color-text-sub);
    line-height: 1.45;
    font-weight: 600;
}

.quiz-options-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    pointer-events: auto !important;
}

.quiz-option-btn {
    padding: 12px 16px;
    background: #f8fafc;
    border: 1.5px solid var(--color-border);
    color: var(--color-text-main);
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
    pointer-events: auto !important;
}

.quiz-option-btn:hover {
    background: #f1f5f9;
    border-color: var(--color-primary);
    transform: translateX(3px);
}

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

.quiz-option-btn.correct {
    background: #dcfce7 !important;
    border-color: #10b981 !important;
    color: #047857 !important;
    font-weight: 800;
}

.quiz-option-btn.wrong {
    background: #fee2e2 !important;
    border-color: #ef4444 !important;
    color: #dc2626 !important;
    font-weight: 800;
}

.quiz-feedback-box {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: #f0fdf4;
    border: 2px solid #059669;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #065f46;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-weight: 600;
    text-align: left;
}

.btn-quiz-continue {
    padding: 10px 18px;
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: #ffffff;
    font-family: var(--font-main);
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    align-self: flex-end;
    pointer-events: auto !important;
}

.modal-actions-row {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-top: 4px;
}

.summary-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    background: #f8fafc;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--color-border);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-weight: 700;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--color-text-main);
}

/* ==========================================================================
   6. RESPONSIVIDADE ADAPTATIVA: MODO RETRATO E HORIZONTAL (LANDSCAPE MOBILE)
   ========================================================================== */

/* --------------------------------------------------------------------------
   A. MODO RETRATO (MOBILE PORTRAIT - ECRÃS ESTREITOS E ALTOS)
   -------------------------------------------------------------------------- */
@media (max-width: 600px) and (orientation: portrait) {
    .hud-bottom-controls {
        padding: 0 8px 8px 8px;
    }
    
    .steering-controls-group {
        gap: 8px;
    }

    .steer-svg-img {
        width: 66px;
        height: 66px;
    }

    .steer-label-plate {
        font-size: 0.58rem;
        padding: 2px 6px;
        bottom: -4px;
    }

    .pedals-controls-group {
        gap: 10px;
    }

    .pedal-brake-img .pedal-svg-img {
        width: 68px;
        height: 68px;
    }

    .pedal-gas-img .pedal-svg-img {
        width: 56px;
        height: 92px;
    }

    .pedal-label-plate {
        font-size: 0.58rem;
        padding: 2px 6px;
        bottom: -4px;
    }

    .home-hero-img-box {
        width: 110px;
        height: 110px;
    }

    .home-logo-title {
        font-size: 2.2rem;
    }
}

/* --------------------------------------------------------------------------
   B. MODO HORIZONTAL (LANDSCAPE MOBILE - ECRÃS LARGOS COM ALTURA REDUZIDA)
   Garante que todos os elementos apareçam perfeitamente proporcionados sem cortes.
   -------------------------------------------------------------------------- */
@media (orientation: landscape) and (max-height: 540px), (max-height: 500px) {

    /* Contentores Gerais e Áreas Seguras */
    .screen-home,
    .screen-stages,
    .screen-workshop {
        padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
    }

    /* 1. Ecrã Inicial (Home) em Grelha Horizontal */
    .home-main-centered-card {
        max-width: 740px;
        width: 96%;
        padding: 12px 18px;
        gap: 8px;
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-card);
        margin: auto;
    }

    .home-top-bar {
        margin-bottom: 2px;
    }

    .home-badge-country {
        padding: 3px 10px;
        font-size: 0.78rem;
    }

    .home-wallet-pill {
        padding: 3px 12px;
        font-size: 0.85rem;
    }

    .home-body-grid {
        display: grid;
        grid-template-columns: 1.15fr 1fr;
        gap: 14px;
        align-items: center;
        width: 100%;
    }

    .home-center-hero {
        flex-direction: row;
        text-align: left;
        align-items: center;
        gap: 12px;
    }

    .home-hero-text {
        align-items: flex-start;
        text-align: left;
        gap: 3px;
    }

    .home-hero-img-box {
        width: 76px;
        height: 76px;
        min-width: 76px;
        margin-top: 0;
        border-width: 3px;
        box-shadow: 0 4px 14px rgba(5, 150, 105, 0.2);
    }

    .home-logo-title {
        font-size: clamp(1.4rem, 3.8vw, 1.7rem);
        line-height: 1.1;
    }

    .home-subtitle {
        font-size: 0.76rem;
        line-height: 1.25;
        max-width: 100%;
    }

    .home-menu-actions {
        gap: 8px;
    }

    .btn-primary-large {
        padding: 9px 14px;
        font-size: 0.95rem;
        border-radius: var(--radius-sm);
        box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
    }

    .home-btn-group {
        gap: 8px;
    }

    .btn-secondary {
        padding: 7px 10px;
        font-size: 0.82rem;
        border-radius: var(--radius-sm);
    }

    /* 2. Ecrã da Oficina do Kibo */
    .workshop-centered-container {
        max-width: 820px;
        width: 98%;
        gap: 6px;
        margin: auto;
    }

    .workshop-header {
        margin-bottom: 2px;
    }

    .workshop-title {
        font-size: 1.2rem;
    }

    .workshop-container {
        grid-template-columns: 1fr 1.18fr;
        gap: 10px;
        align-items: stretch;
    }

    .vehicle-preview-card {
        padding: 8px 12px;
        gap: 6px;
        border-radius: var(--radius-md);
    }

    .vehicle-selector-nav {
        width: 100%;
    }

    .nav-arrow-btn {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

    .vehicle-name-tag {
        font-size: 0.98rem;
    }

    .vehicle-canvas-display {
        height: 85px;
        border-radius: var(--radius-sm);
    }

    .vehicle-desc-text {
        font-size: 0.72rem;
        line-height: 1.22;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    #btn-vehicle-unlock {
        font-size: 0.85rem !important;
        padding: 6px 12px !important;
    }

    .upgrades-list-card {
        padding: 8px 12px;
        gap: 5px;
        border-radius: var(--radius-md);
    }

    .upgrade-item-row {
        padding: 4px 8px;
        gap: 8px;
        border-radius: var(--radius-sm);
    }

    .upgrade-name {
        font-size: 0.78rem;
    }

    .upgrade-meter-track {
        height: 5px;
    }

    .upgrade-level-label {
        font-size: 0.65rem;
    }

    .btn-upgrade-action {
        padding: 5px 10px;
        font-size: 0.75rem;
        border-radius: 6px;
    }

    #btn-workshop-back {
        margin-top: 3px;
        padding: 6px 12px;
        font-size: 0.82rem;
    }

    /* 3. Ecrã de Seleção de Províncias (Stages) */
    .stages-centered-container {
        max-width: 840px;
        width: 98%;
        gap: 6px;
        margin: auto;
    }

    .stages-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        max-height: calc(100vh - 90px);
        overflow-y: auto;
        padding-right: 4px;
    }

    .stage-card {
        padding: 8px 10px;
        gap: 4px;
        border-radius: var(--radius-md);
    }

    .stage-badge {
        padding: 2px 6px;
        font-size: 0.65rem;
    }

    .stage-name {
        font-size: 0.92rem;
    }

    .stage-province {
        font-size: 0.72rem;
    }

    .stage-description {
        font-size: 0.68rem;
        line-height: 1.2;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .stage-best-score {
        font-size: 0.72rem;
        margin-top: 2px;
    }

    .stages-footer-actions {
        margin-top: 4px;
    }

    #btn-stages-back {
        padding: 6px 14px;
        font-size: 0.82rem;
        max-width: 180px !important;
    }

    /* 4. HUD em Condução Top-Down */
    .screen-hud {
        padding: 6px 12px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-top: max(6px, env(safe-area-inset-top));
        padding-bottom: max(6px, env(safe-area-inset-bottom));
    }

    .hud-top-bar {
        gap: 8px;
        align-items: center;
    }

    .hud-left-metrics {
        flex-direction: row;
        gap: 6px;
    }

    .hud-pill {
        padding: 4px 8px;
        font-size: 0.78rem;
        gap: 4px;
    }

    .hud-center-energy {
        max-width: 220px;
        gap: 2px;
    }

    .energy-bar-capsule {
        height: 14px;
        border-radius: 7px;
    }

    .energy-label {
        font-size: 0.62rem;
    }

    .btn-hud-icon {
        padding: 4px 10px;
        font-size: 0.78rem;
    }

    .hud-telemetry-badge {
        top: 48px;
        padding: 2px 12px;
        font-size: 0.70rem;
        gap: 8px;
        border-radius: 16px;
    }

    .hud-notification-banner {
        top: 70px;
        padding: 4px 14px;
        font-size: 0.8rem;
    }

    .hud-bottom-controls {
        padding: 0 10px 4px 10px;
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
        padding-bottom: max(4px, env(safe-area-inset-bottom));
    }

    .label-key-hint {
        display: none;
    }

    .steering-controls-group {
        gap: 12px;
        align-items: flex-end;
    }

    .steer-svg-img {
        width: 56px;
        height: 56px;
    }

    .steer-label-plate {
        font-size: 0.52rem;
        padding: 1px 5px;
        bottom: -2px;
        letter-spacing: 0.2px;
    }

    .pedals-controls-group {
        gap: 12px;
        align-items: flex-end;
    }

    .pedal-brake-img .pedal-svg-img {
        width: 56px;
        height: 56px;
    }

    .pedal-gas-img .pedal-svg-img {
        width: 46px;
        height: 78px;
    }

    .pedal-label-plate {
        font-size: 0.52rem;
        padding: 1px 5px;
        bottom: -2px;
        letter-spacing: 0.2px;
    }

    /* 5. Modais Centralizados em Landscape */
    .modal-backdrop {
        padding: 8px;
    }

    .modal-card {
        max-width: 540px;
        padding: 10px 16px;
        gap: 7px;
        max-height: 95vh;
        border-radius: var(--radius-md);
    }

    .modal-header-tag {
        font-size: 0.68rem;
    }

    .modal-title {
        font-size: 1.15rem;
    }

    .modal-body-text {
        font-size: 0.8rem;
        line-height: 1.25;
    }

    /* Modal de Pausa */
    .pause-stats-bar {
        padding: 5px 8px;
        gap: 6px;
    }

    .pause-stat-label {
        font-size: 0.6rem;
    }

    .pause-stat-value {
        font-size: 0.92rem;
    }

    .modal-actions-row {
        gap: 6px;
    }

    .modal-actions-row button, .modal-card > button {
        padding: 6px 12px !important;
        font-size: 0.82rem !important;
    }

    /* Modal de Quiz Científico em Grelha 2x2 */
    .quiz-options-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .quiz-option-btn {
        padding: 6px 10px;
        font-size: 0.78rem;
        border-radius: var(--radius-sm);
    }

    .quiz-feedback-box {
        padding: 6px 10px;
        font-size: 0.78rem;
        gap: 4px;
    }

    .btn-quiz-continue {
        padding: 5px 12px;
        font-size: 0.8rem;
    }

    /* Modal de Fim de Jogo */
    .summary-stats-grid {
        grid-template-columns: repeat(4, 1fr);
        padding: 5px 8px;
        gap: 4px;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    .stat-value {
        font-size: 0.95rem;
    }
}

/* --------------------------------------------------------------------------
   C. DISPOSITIVOS ULTRA-COMPACTOS NA HORIZONTAL (ALTURA <= 340PX)
   -------------------------------------------------------------------------- */
@media (max-height: 340px) {
    .screen-home,
    .screen-stages,
    .screen-workshop {
        padding: 4px max(10px, env(safe-area-inset-right)) 4px max(10px, env(safe-area-inset-left));
    }

    .home-main-centered-card {
        padding: 8px 14px;
        gap: 6px;
    }

    .home-hero-img-box {
        width: 58px;
        height: 58px;
        min-width: 58px;
    }

    .home-logo-title {
        font-size: 1.30rem;
    }

    .home-subtitle {
        font-size: 0.68rem;
    }

    .btn-primary-large {
        padding: 7px 12px;
        font-size: 0.88rem;
    }

    .btn-secondary {
        padding: 5px 8px;
        font-size: 0.78rem;
    }

    .vehicle-canvas-display {
        height: 62px;
    }

    .stages-grid {
        max-height: 140px;
    }

    .steer-svg-img {
        width: 48px;
        height: 48px;
    }

    .pedal-brake-img .pedal-svg-img {
        width: 48px;
        height: 48px;
    }

    .pedal-gas-img .pedal-svg-img {
        width: 40px;
        height: 64px;
    }

    .hud-telemetry-badge {
        top: 40px;
        font-size: 0.64rem;
        padding: 2px 8px;
        gap: 6px;
    }

    .energy-bar-capsule {
        height: 12px;
    }
}


