@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700;800;900&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Poppins', sans-serif;
    background: #0b0f1a;
    color: #fff;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

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

/* --- Screens --- */
.screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}
.screen.active {
    display: flex;
}

/* --- Home Screen --- */
#screen-home {
    background: linear-gradient(160deg, #0b0f1a 0%, #111638 40%, #1a1040 70%, #0b0f1a 100%);
    padding: 20px;
    padding-bottom: 50px;
    position: relative;
}
#screen-home::before {
    content: '';
    position: absolute;
    top: -120px; right: -80px;
    width: 300px; height: 300px;
    background: radial-gradient(circle, rgba(102,126,234,0.15) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}
#screen-home::after {
    content: '';
    position: absolute;
    bottom: -100px; left: -60px;
    width: 250px; height: 250px;
    background: radial-gradient(circle, rgba(255,107,107,0.1) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.home-header {
    text-align: center;
    padding: 28px 0 6px;
    position: relative;
    z-index: 1;
}

.app-title {
    font-size: 2.4rem;
    font-weight: 900;
    letter-spacing: 4px;
    line-height: 1.1;
    background: linear-gradient(135deg, #00d2ff 0%, #7b2ff7 40%, #ff6b6b 80%, #ffd200 100%);
    background-size: 200% 200%;
    animation: gradientShift 4s ease infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 10px rgba(123,47,247,0.3));
}
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.app-title span {
    font-size: 1.7rem;
    font-weight: 700;
}

.app-subtitle {
    color: rgba(255,255,255,0.45);
    font-size: 0.85rem;
    margin-top: 8px;
    letter-spacing: 3px;
    text-transform: uppercase;
    font-weight: 600;
}

.section-label {
    font-size: 0.7rem;
    letter-spacing: 4px;
    color: rgba(255,255,255,0.35);
    margin: 28px 0 14px;
    padding-left: 6px;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.menu-sections {
    position: relative;
    z-index: 1;
}

/* --- Cards --- */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.card {
    border-radius: 22px;
    padding: 28px 16px 22px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.card::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%; right: -50%; bottom: -50%;
    background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.08) 0%, transparent 60%);
    pointer-events: none;
}
.card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    border-radius: 0 0 22px 22px;
    opacity: 0;
    transition: opacity 0.3s;
}
.card:hover {
    transform: translateY(-4px) scale(1.02);
}
.card:active {
    transform: scale(0.96);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 6px 12px rgba(0,0,0,0.4));
    transition: transform 0.3s;
}
.card:hover .card-icon {
    transform: scale(1.12) translateY(-2px);
}

.card-name {
    font-weight: 700;
    font-size: 0.92rem;
    position: relative;
    z-index: 1;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Individual card styles with stronger colors */
.card-arquitectura {
    background: linear-gradient(145deg, rgba(102,126,234,0.25) 0%, rgba(118,75,162,0.2) 100%);
    border: 1px solid rgba(102,126,234,0.35);
    box-shadow: 0 4px 20px rgba(102,126,234,0.1);
}
.card-arquitectura::after { background: linear-gradient(90deg, #667eea, #764ba2); }
.card-arquitectura:hover { box-shadow: 0 8px 32px rgba(102,126,234,0.25); }
.card-arquitectura:hover::after { opacity: 1; }

.card-interiorismo {
    background: linear-gradient(145deg, rgba(196,113,245,0.25) 0%, rgba(250,113,205,0.2) 100%);
    border: 1px solid rgba(196,113,245,0.35);
    box-shadow: 0 4px 20px rgba(196,113,245,0.1);
}
.card-interiorismo::after { background: linear-gradient(90deg, #c471f5, #fa71cd); }
.card-interiorismo:hover { box-shadow: 0 8px 32px rgba(196,113,245,0.25); }
.card-interiorismo:hover::after { opacity: 1; }

.card-medico {
    background: linear-gradient(145deg, rgba(240,147,251,0.2) 0%, rgba(245,87,108,0.2) 100%);
    border: 1px solid rgba(240,147,251,0.35);
    box-shadow: 0 4px 20px rgba(240,147,251,0.1);
}
.card-medico::after { background: linear-gradient(90deg, #f093fb, #f5576c); }
.card-medico:hover { box-shadow: 0 8px 32px rgba(240,147,251,0.25); }
.card-medico:hover::after { opacity: 1; }

.card-cocina {
    background: linear-gradient(145deg, rgba(255,236,210,0.2) 0%, rgba(252,182,159,0.2) 100%);
    border: 1px solid rgba(252,182,159,0.35);
    box-shadow: 0 4px 20px rgba(252,182,159,0.1);
}
.card-cocina::after { background: linear-gradient(90deg, #ffecd2, #fcb69f); }
.card-cocina:hover { box-shadow: 0 8px 32px rgba(252,182,159,0.2); }
.card-cocina:hover::after { opacity: 1; }

.card-bombero {
    background: linear-gradient(145deg, rgba(255,81,47,0.2) 0%, rgba(240,147,34,0.2) 100%);
    border: 1px solid rgba(255,81,47,0.35);
    box-shadow: 0 4px 20px rgba(255,81,47,0.1);
}
.card-bombero::after { background: linear-gradient(90deg, #ff512f, #f09322); }
.card-bombero:hover { box-shadow: 0 8px 32px rgba(255,81,47,0.2); }
.card-bombero:hover::after { opacity: 1; }

.card-viajes {
    background: linear-gradient(145deg, rgba(67,233,123,0.2) 0%, rgba(56,249,215,0.15) 100%);
    border: 1px solid rgba(67,233,123,0.35);
    box-shadow: 0 4px 20px rgba(67,233,123,0.1);
}
.card-viajes::after { background: linear-gradient(90deg, #43e97b, #38f9d7); }
.card-viajes:hover { box-shadow: 0 8px 32px rgba(67,233,123,0.2); }
.card-viajes:hover::after { opacity: 1; }

.card-deporte {
    background: linear-gradient(145deg, rgba(0,210,255,0.2) 0%, rgba(58,123,213,0.2) 100%);
    border: 1px solid rgba(0,210,255,0.35);
    box-shadow: 0 4px 20px rgba(0,210,255,0.1);
}
.card-deporte::after { background: linear-gradient(90deg, #00d2ff, #3a7bd5); }
.card-deporte:hover { box-shadow: 0 8px 32px rgba(0,210,255,0.25); }
.card-deporte:hover::after { opacity: 1; }

.card-conducir {
    background: linear-gradient(145deg, rgba(250,112,154,0.2) 0%, rgba(254,225,64,0.15) 100%);
    border: 1px solid rgba(250,112,154,0.35);
    box-shadow: 0 4px 20px rgba(250,112,154,0.1);
}
.card-conducir::after { background: linear-gradient(90deg, #fa709a, #fee140); }
.card-conducir:hover { box-shadow: 0 8px 32px rgba(250,112,154,0.2); }
.card-conducir:hover::after { opacity: 1; }

.card-musica {
    background: linear-gradient(145deg, rgba(161,140,209,0.2) 0%, rgba(251,194,235,0.15) 100%);
    border: 1px solid rgba(161,140,209,0.35);
    box-shadow: 0 4px 20px rgba(161,140,209,0.1);
}
.card-musica::after { background: linear-gradient(90deg, #a18cd1, #fbc2eb); }
.card-musica:hover { box-shadow: 0 8px 32px rgba(161,140,209,0.25); }
.card-musica:hover::after { opacity: 1; }

.card-pintura {
    background: linear-gradient(145deg, rgba(247,151,30,0.2) 0%, rgba(255,210,0,0.15) 100%);
    border: 1px solid rgba(247,151,30,0.35);
    box-shadow: 0 4px 20px rgba(247,151,30,0.1);
}
.card-pintura::after { background: linear-gradient(90deg, #f7971e, #ffd200); }
.card-pintura:hover { box-shadow: 0 8px 32px rgba(247,151,30,0.2); }
.card-pintura:hover::after { opacity: 1; }

.card-ajedrez {
    background: linear-gradient(145deg, rgba(189,195,199,0.15) 0%, rgba(44,62,80,0.2) 100%);
    border: 1px solid rgba(189,195,199,0.3);
    box-shadow: 0 4px 20px rgba(189,195,199,0.08);
}
.card-ajedrez::after { background: linear-gradient(90deg, #bdc3c7, #606c88); }
.card-ajedrez:hover { box-shadow: 0 8px 32px rgba(189,195,199,0.2); }
.card-ajedrez:hover::after { opacity: 1; }

.card-universidad {
    background: linear-gradient(145deg, rgba(102,126,234,0.2) 0%, rgba(67,233,123,0.15) 100%);
    border: 1px solid rgba(102,126,234,0.35);
    box-shadow: 0 4px 20px rgba(102,126,234,0.1);
}
.card-universidad::after { background: linear-gradient(90deg, #667eea, #43e97b); }
.card-universidad:hover { box-shadow: 0 8px 32px rgba(102,126,234,0.2); }
.card-universidad:hover::after { opacity: 1; }

/* --- Difficulty Selector --- */
.difficulty-selector {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    margin-bottom: 4px;
    backdrop-filter: blur(8px);
}
.diff-label {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    margin-right: 4px;
    font-weight: 600;
    letter-spacing: 1px;
}
.diff-btn {
    padding: 7px 18px;
    border-radius: 22px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.6);
    font-family: 'Poppins', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
}
.diff-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.diff-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(102,126,234,0.35);
}

/* 5th card spans full width */
.cards-grid .card:nth-child(5) {
    grid-column: 1 / -1;
}

/* --- Subtypes Screen --- */
#screen-subtypes {
    background: linear-gradient(160deg, #0b0f1a 0%, #111638 40%, #1a1040 70%, #0b0f1a 100%);
    padding: 20px;
}

.screen-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
    flex-shrink: 0;
}
.screen-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.7) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.btn-back {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.8);
    padding: 8px 18px;
    border-radius: 14px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.25s;
    backdrop-filter: blur(8px);
}
.btn-back:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.25);
}
.btn-back:active {
    background: rgba(255,255,255,0.18);
    transform: scale(0.97);
}

.subtypes-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.subtype-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(8px);
    position: relative;
    overflow: hidden;
}
.subtype-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, rgba(102,126,234,0.05) 0%, rgba(123,47,247,0.03) 100%);
    opacity: 0;
    transition: opacity 0.3s;
}
.subtype-card:hover::before {
    opacity: 1;
}
.subtype-card:hover {
    border-color: rgba(102,126,234,0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}
.subtype-card:active {
    transform: scale(0.98);
}
.subtype-card h3 {
    font-size: 1.05rem;
    margin-bottom: 4px;
    position: relative;
}
.subtype-card p {
    color: rgba(255,255,255,0.45);
    font-size: 0.78rem;
    line-height: 1.4;
    position: relative;
}
.subtype-card .subtype-icon {
    font-size: 1.8rem;
    margin-bottom: 8px;
    position: relative;
}

/* --- Game Screen --- */
#screen-game {
    background: #0b0f1a;
}

.game-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(12px);
    flex-shrink: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.game-header h2 {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    color: rgba(255,255,255,0.9);
}

.game-score {
    background: linear-gradient(135deg, #667eea, #764ba2);
    padding: 6px 16px;
    border-radius: 22px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 3px 12px rgba(102,126,234,0.3);
}

#game-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#game-ui {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}
#game-ui > * {
    pointer-events: auto;
}

#game-controls {
    flex-shrink: 0;
    padding: 12px;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    min-height: 60px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.control-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    padding: 10px 18px;
    border-radius: 14px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.control-btn:active {
    background: rgba(255,255,255,0.2);
    transform: scale(0.95);
}
.control-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}
.control-btn.danger {
    background: linear-gradient(135deg, rgba(255,81,47,0.5), rgba(240,147,34,0.5));
    border-color: #ff512f;
}

/* --- Game UI elements --- */
.game-grid {
    display: grid;
    gap: 4px;
    padding: 10px;
    width: 100%;
    height: 100%;
}

.grid-cell {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.2s;
}
.grid-cell:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(102,126,234,0.3);
}
.grid-cell.occupied {
    background: rgba(102, 126, 234, 0.15);
    border-color: rgba(102, 126, 234, 0.3);
}

/* Toolbar for building games */
.toolbar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 12px;
    -webkit-overflow-scrolling: touch;
}
.toolbar::-webkit-scrollbar { display: none; }

.tool-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    cursor: pointer;
    min-width: 70px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.tool-item.selected {
    background: linear-gradient(135deg, rgba(102,126,234,0.25), rgba(118,75,162,0.25));
    border-color: #667eea;
    box-shadow: 0 3px 12px rgba(102,126,234,0.2);
}
.tool-item .tool-icon { font-size: 1.5rem; }
.tool-item .tool-label {
    font-size: 0.6rem;
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
}

/* Info panel */
.info-panel {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(11,15,26,0.95);
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255,255,255,0.08);
    border-radius: 22px 22px 0 0;
    padding: 22px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 20;
    max-height: 60vh;
    overflow-y: auto;
}
.info-panel.show {
    transform: translateY(0);
}
.info-panel h3 {
    margin-bottom: 10px;
    font-size: 1.1rem;
}
.info-panel p {
    color: rgba(255,255,255,0.5);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Stars rating */
.stars {
    display: flex;
    gap: 4px;
    font-size: 1.5rem;
}
.star.filled { color: #ffd700; filter: drop-shadow(0 2px 4px rgba(255,215,0,0.4)); }
.star.empty { color: #222; }

/* Results overlay */
.result-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(11,15,26,0.94);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 30;
    padding: 30px;
    text-align: center;
}
.result-overlay h2 {
    font-size: 1.8rem;
    background: linear-gradient(135deg, #00d2ff, #7b2ff7, #ff6b6b);
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.result-overlay .result-score {
    font-size: 3.2rem;
    font-weight: 900;
    text-shadow: 0 4px 20px rgba(102,126,234,0.3);
}
.result-overlay .result-msg {
    color: rgba(255,255,255,0.5);
    font-size: 0.9rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    padding: 14px 42px;
    border-radius: 18px;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s;
    margin-top: 10px;
    box-shadow: 0 4px 18px rgba(102,126,234,0.3);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102,126,234,0.4);
}
.btn-primary:active {
    transform: scale(0.97);
}

/* Country cards for travel agent */
.country-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px;
    overflow-y: auto;
    height: 100%;
}
.country-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.25s;
    backdrop-filter: blur(6px);
}
.country-card:hover { border-color: rgba(67,233,123,0.3); transform: translateY(-2px); }
.country-card:active { transform: scale(0.98); }
.country-card .country-flag { font-size: 2.5rem; }
.country-card h3 { margin: 6px 0 2px; font-size: 1rem; }
.country-card p { color: rgba(255,255,255,0.4); font-size: 0.75rem; }

/* Notes / evaluation */
.eval-section {
    padding: 16px;
    overflow-y: auto;
    height: 100%;
}
.eval-item {
    background: rgba(255,255,255,0.04);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 10px;
    backdrop-filter: blur(4px);
}
.eval-item .label {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.eval-item .value {
    font-size: 0.95rem;
    font-weight: 600;
}
.eval-good { border-left: 3px solid #43e97b; }
.eval-bad { border-left: 3px solid #ff512f; }
.eval-neutral { border-left: 3px solid #667eea; }

/* Sport selector */
.sport-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 10px;
    overflow-y: auto;
    height: 100%;
}
.sport-item {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    padding: 16px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
}
.sport-item:hover { border-color: rgba(0,210,255,0.3); transform: translateY(-2px); }
.sport-item:active { transform: scale(0.95); }
.sport-item .sport-icon { font-size: 2rem; margin-bottom: 4px; }
.sport-item .sport-name { font-size: 0.7rem; font-weight: 600; }

/* Drum pads */
.drum-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
    height: 100%;
    align-content: center;
}
.drum-pad {
    aspect-ratio: 1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.1s;
    user-select: none;
    border: 3px solid rgba(255,255,255,0.15);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.drum-pad:active {
    transform: scale(0.9);
    filter: brightness(1.5);
}
.drum-pad .pad-label { font-size: 0.65rem; color: rgba(255,255,255,0.7); margin-top: 4px; }

/* Gear shift */
.gear-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 20px;
    padding: 20px;
}
.speedometer {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 4px solid rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: radial-gradient(circle, rgba(102,126,234,0.1) 0%, transparent 70%);
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.speed-value {
    font-size: 3rem;
    font-weight: 900;
}
.speed-unit {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.4);
}
.gear-indicator {
    font-size: 1.2rem;
    font-weight: 700;
    color: #667eea;
}
.gear-shifter {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 250px;
}
.gear-btn {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: rgba(255,255,255,0.06);
    border: 2px solid rgba(255,255,255,0.12);
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s;
}
.gear-btn:active { transform: scale(0.9); }
.gear-btn.active-gear {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(102,126,234,0.35);
}
.pedals {
    display: flex;
    gap: 16px;
}
.pedal {
    width: 100px;
    height: 80px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.1s;
}
.pedal:active { transform: scale(0.95); }
.pedal-gas {
    background: linear-gradient(135deg, rgba(67,233,123,0.25), rgba(56,249,215,0.2));
    border: 2px solid #43e97b;
    color: #43e97b;
}
.pedal-brake {
    background: linear-gradient(135deg, rgba(255,81,47,0.25), rgba(240,147,34,0.2));
    border: 2px solid #ff512f;
    color: #ff512f;
}
.pedal-clutch {
    background: linear-gradient(135deg, rgba(102,126,234,0.25), rgba(118,75,162,0.2));
    border: 2px solid #667eea;
    color: #667eea;
}

/* Recipe steps */
.recipe-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 12px;
    gap: 10px;
    overflow-y: auto;
}
.recipe-step {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 14px;
    transition: all 0.3s;
}
.recipe-step.done {
    background: rgba(67, 233, 123, 0.08);
    border-color: rgba(67, 233, 123, 0.25);
}
.recipe-step .step-num {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}
.recipe-step.done .step-num {
    background: #43e97b;
    color: #000;
}
.recipe-step .step-text { font-size: 0.85rem; }

/* Ingredient shelf */
.ingredients-shelf {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 12px;
    -webkit-overflow-scrolling: touch;
}
.ingredients-shelf::-webkit-scrollbar { display: none; }
.ingredient-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    cursor: pointer;
    min-width: 65px;
    flex-shrink: 0;
    transition: all 0.15s;
}
.ingredient-item:active { transform: scale(0.9); }
.ingredient-item .ing-icon { font-size: 1.6rem; }
.ingredient-item .ing-name { font-size: 0.55rem; color: rgba(255,255,255,0.5); white-space: nowrap; }

/* Fire game */
.fire-scene {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Scrollbar */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

/* Animations */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in {
    animation: fadeIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fireFlicker {
    0%, 100% { transform: scaleY(1) scaleX(1); opacity: 1; }
    25% { transform: scaleY(1.1) scaleX(0.9); opacity: 0.9; }
    50% { transform: scaleY(0.9) scaleX(1.1); opacity: 1; }
    75% { transform: scaleY(1.05) scaleX(0.95); opacity: 0.85; }
}

.fire-emoji {
    animation: fireFlicker 0.5s ease-in-out infinite;
    display: inline-block;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

/* Sport game canvas area */
.sport-game-area {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
}

/* ========================================
   MOBILE RESPONSIVE - 320px to 428px
   ======================================== */

@media screen and (max-width: 428px) {

    /* --- Base adjustments --- */
    body {
        overflow-x: hidden;
    }

    #app {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* --- Home Screen --- */
    #screen-home {
        padding: 14px;
        padding-bottom: 40px;
    }

    .home-header {
        padding: 16px 0 4px;
    }

    /* Header title: prevent overflow on small screens */
    .app-title {
        font-size: 1.6rem;
        letter-spacing: 2px;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    .app-title span {
        font-size: 1.2rem;
    }

    .app-subtitle {
        font-size: 0.72rem;
        letter-spacing: 2px;
        margin-top: 6px;
    }

    .section-label {
        font-size: 0.62rem;
        letter-spacing: 3px;
        margin: 20px 0 10px;
    }

    /* --- Cards grid: 2 columns with proper gaps --- */
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .card {
        border-radius: 16px;
        padding: 18px 10px 16px;
        /* Ensure minimum 44px touch target */
        min-height: 44px;
    }

    .card-icon {
        font-size: 2.2rem;
        margin-bottom: 6px;
    }

    .card-name {
        font-size: 0.78rem;
        line-height: 1.2;
    }

    /* 5th card still spans full */
    .cards-grid .card:nth-child(5) {
        grid-column: 1 / -1;
    }

    /* --- Difficulty Selector: no horizontal overflow --- */
    .difficulty-selector {
        flex-wrap: wrap;
        gap: 6px;
        padding: 10px;
    }
    .diff-label {
        width: 100%;
        text-align: center;
        margin-right: 0;
        margin-bottom: 2px;
        font-size: 11px;
    }
    .diff-btn {
        padding: 8px 14px;
        font-size: 11px;
        /* 44px minimum touch target */
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* --- Subtypes Screen --- */
    #screen-subtypes {
        padding: 14px;
    }

    .screen-header {
        gap: 10px;
        margin-bottom: 16px;
    }
    .screen-header h2 {
        font-size: 1.1rem;
    }

    .btn-back {
        padding: 10px 16px;
        font-size: 0.78rem;
        /* 44px touch target */
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Subtype list items: proper padding for touch */
    .subtype-card {
        padding: 16px;
        border-radius: 14px;
        /* 44px minimum touch height */
        min-height: 44px;
    }
    .subtype-card h3 {
        font-size: 0.95rem;
    }
    .subtype-card p {
        font-size: 0.73rem;
    }
    .subtype-card .subtype-icon {
        font-size: 1.5rem;
        margin-bottom: 6px;
    }

    /* --- Game Screen --- */
    .game-header {
        padding: 8px 10px;
        gap: 8px;
    }
    .game-header h2 {
        font-size: 0.82rem;
    }
    .game-score {
        padding: 5px 12px;
        font-size: 0.72rem;
    }

    /* Canvas container fills available space */
    #game-container {
        flex: 1;
        min-height: 0;
        width: 100%;
    }
    #game-canvas {
        width: 100%;
        height: 100%;
    }

    /* Game controls: scrollable if overflows */
    #game-controls {
        padding: 8px 10px;
        gap: 6px;
        max-height: 40vh;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .control-btn {
        padding: 10px 14px;
        font-size: 0.78rem;
        border-radius: 12px;
        /* 44px touch target */
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* --- Game grid cells --- */
    .game-grid {
        gap: 3px;
        padding: 6px;
    }
    .grid-cell {
        border-radius: 8px;
        font-size: 1.4rem;
        /* touch target */
        min-width: 44px;
        min-height: 44px;
    }

    /* --- Toolbar --- */
    .toolbar {
        padding: 6px 8px;
        gap: 5px;
    }
    .tool-item {
        padding: 8px 10px;
        min-width: 60px;
        min-height: 44px;
        border-radius: 12px;
    }
    .tool-item .tool-icon {
        font-size: 1.3rem;
    }
    .tool-item .tool-label {
        font-size: 0.55rem;
    }

    /* --- Info panel / modal: properly sized for mobile --- */
    .info-panel {
        padding: 16px;
        border-radius: 18px 18px 0 0;
        max-height: 70vh;
    }
    .info-panel h3 {
        font-size: 1rem;
    }
    .info-panel p {
        font-size: 0.8rem;
    }

    /* --- Result overlay (modal) --- */
    .result-overlay {
        padding: 20px 16px;
    }
    .result-overlay h2 {
        font-size: 1.4rem;
    }
    .result-overlay .result-score {
        font-size: 2.4rem;
    }
    .result-overlay .result-msg {
        font-size: 0.82rem;
    }

    .btn-primary {
        padding: 14px 32px;
        font-size: 0.9rem;
        border-radius: 16px;
        /* 44px touch target */
        min-height: 48px;
        width: 100%;
        max-width: 280px;
    }

    /* --- Country cards (travel agent) --- */
    .country-cards {
        padding: 8px;
        gap: 10px;
    }
    .country-card {
        padding: 14px;
        border-radius: 14px;
        min-height: 44px;
    }
    .country-card .country-flag {
        font-size: 2rem;
    }
    .country-card h3 {
        font-size: 0.9rem;
    }
    .country-card p {
        font-size: 0.7rem;
    }

    /* --- Eval section --- */
    .eval-section {
        padding: 12px;
    }
    .eval-item {
        padding: 12px;
        border-radius: 12px;
    }
    .eval-item .label {
        font-size: 0.65rem;
    }
    .eval-item .value {
        font-size: 0.85rem;
    }

    /* --- Sport grid --- */
    .sport-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 8px;
    }
    .sport-item {
        padding: 14px 6px;
        border-radius: 14px;
        /* 44px touch target */
        min-height: 44px;
    }
    .sport-item .sport-icon {
        font-size: 1.6rem;
    }
    .sport-item .sport-name {
        font-size: 0.65rem;
    }

    /* --- Drum pads --- */
    .drum-grid {
        gap: 10px;
        padding: 12px;
    }
    .drum-pad {
        font-size: 0.7rem;
        min-width: 44px;
        min-height: 44px;
    }
    .drum-pad .pad-label {
        font-size: 0.58rem;
    }

    /* --- Driving game --- */
    .gear-display {
        gap: 14px;
        padding: 14px;
    }
    .speedometer {
        width: 150px;
        height: 150px;
        border-width: 3px;
    }
    .speed-value {
        font-size: 2.2rem;
    }
    .speed-unit {
        font-size: 0.7rem;
    }
    .gear-indicator {
        font-size: 1rem;
    }
    .gear-shifter {
        gap: 6px;
        max-width: 200px;
    }
    .gear-btn {
        width: 50px;
        height: 50px;
        border-radius: 14px;
        font-size: 1rem;
    }
    .pedals {
        gap: 10px;
    }
    .pedal {
        width: 80px;
        height: 60px;
        border-radius: 14px;
        font-size: 0.72rem;
        /* 44px touch target */
        min-height: 44px;
        min-width: 44px;
    }

    /* --- Recipe --- */
    .recipe-area {
        padding: 8px;
        gap: 8px;
    }
    .recipe-step {
        padding: 12px;
        gap: 10px;
        border-radius: 12px;
    }
    .recipe-step .step-text {
        font-size: 0.78rem;
    }

    /* --- Ingredients shelf --- */
    .ingredients-shelf {
        padding: 6px 8px;
        gap: 6px;
    }
    .ingredient-item {
        padding: 8px 10px;
        min-width: 58px;
        min-height: 44px;
        border-radius: 12px;
    }
    .ingredient-item .ing-icon {
        font-size: 1.3rem;
    }
    .ingredient-item .ing-name {
        font-size: 0.5rem;
    }

    /* --- Stars --- */
    .stars {
        font-size: 1.2rem;
    }
}

/* Extra-small screens (320px) */
@media screen and (max-width: 350px) {

    .app-title {
        font-size: 1.35rem;
        letter-spacing: 1px;
    }
    .app-title span {
        font-size: 1.05rem;
    }

    .app-subtitle {
        font-size: 0.65rem;
        letter-spacing: 1.5px;
    }

    .cards-grid {
        gap: 8px;
    }

    .card {
        padding: 14px 8px 12px;
        border-radius: 14px;
    }
    .card-icon {
        font-size: 1.9rem;
        margin-bottom: 4px;
    }
    .card-name {
        font-size: 0.7rem;
    }

    .diff-btn {
        padding: 8px 10px;
        font-size: 10px;
    }

    .screen-header h2 {
        font-size: 0.95rem;
    }

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

    .speedometer {
        width: 120px;
        height: 120px;
    }
    .speed-value {
        font-size: 1.8rem;
    }
    .gear-btn {
        width: 44px;
        height: 44px;
        font-size: 0.9rem;
    }
    .pedal {
        width: 65px;
        height: 50px;
        font-size: 0.65rem;
    }

    .result-overlay h2 {
        font-size: 1.2rem;
    }
    .result-overlay .result-score {
        font-size: 2rem;
    }
}
