/* === CSS Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--color-text);
    touch-action: manipulation;
}

/* === Landscape Enforcement === */
#rotate-prompt {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-primary);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

#rotate-prompt .rotate-icon {
    font-size: 80px;
    animation: rotate-hint 2s ease-in-out infinite;
}

#rotate-prompt p {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-pink);
}

@media (orientation: portrait) {
    #rotate-prompt {
        display: flex;
    }
    #game-container {
        display: none !important;
    }
}

/* === Game Container === */
#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
    background: var(--bg-gradient);
}

/* === Screens === */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    padding: 20px;
    padding-top: env(safe-area-inset-top, 20px);
    padding-bottom: env(safe-area-inset-bottom, 20px);
    padding-left: env(safe-area-inset-left, 20px);
    padding-right: env(safe-area-inset-right, 20px);
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
}

/* === Screen Headers === */
.screen-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 8px 0;
    position: relative;
}

.screen-header h2 {
    font-size: 36px;
    font-weight: 800;
    color: var(--color-prompt);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
}

.screen-header .btn-back {
    position: absolute;
    left: 0;
}

.screen-header .btn-sticker-book {
    position: absolute;
    right: 0;
}

/* === Typography === */
h1 {
    font-size: 48px;
    font-weight: 900;
    color: var(--color-pink);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

h2 {
    font-size: 36px;
    font-weight: 800;
}

/* === Buttons === */
.btn {
    border: none;
    border-radius: var(--radius-medium);
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

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

.btn-large {
    min-width: 240px;
    min-height: 100px;
    font-size: 40px;
    padding: 20px 48px;
    border-radius: var(--radius-large);
}

.btn-medium {
    min-width: 160px;
    min-height: 80px;
    font-size: 28px;
    padding: 16px 32px;
}

.btn-small {
    min-width: 60px;
    min-height: 60px;
    font-size: 28px;
    padding: 12px 16px;
    border-radius: var(--radius-small);
}

.btn-primary {
    background: var(--btn-primary-bg);
    box-shadow: 0 6px 0 var(--btn-primary-shadow), 0 8px 20px rgba(0, 0, 0, 0.15);
}

.btn-primary:active {
    box-shadow: 0 2px 0 var(--btn-primary-shadow), 0 4px 10px rgba(0, 0, 0, 0.15);
    transform: translateY(4px) scale(0.98);
}

.btn-secondary {
    background: var(--btn-secondary-bg);
    box-shadow: 0 4px 0 var(--btn-secondary-shadow), 0 6px 16px rgba(0, 0, 0, 0.15);
}

.btn-secondary:active {
    box-shadow: 0 2px 0 var(--btn-secondary-shadow), 0 3px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(2px) scale(0.98);
}

.btn-back {
    background: rgba(255, 255, 255, 0.4);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    color: var(--color-pink);
    text-shadow: none;
}

.btn-sticker-book {
    background: rgba(255, 255, 255, 0.4);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-size: 32px;
}

/* === Splash Screen === */
.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.splash-character {
    font-size: 100px;
    line-height: 1;
}

.splash-title {
    text-align: center;
}

.splash-subtitle {
    font-size: 24px;
    font-weight: 600;
    color: var(--color-text-light);
}

/* === Activity Grid === */
.activity-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    width: 100%;
    max-width: 800px;
    padding: 16px 0;
}

.activity-card {
    min-height: 160px;
    border-radius: var(--radius-large);
    border: 3px solid var(--card-border);
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
    color: var(--color-text);
    box-shadow: 0 4px 12px rgba(255, 105, 180, 0.15);
    backdrop-filter: blur(8px);
}

.activity-card:active {
    transform: scale(0.95);
}

.activity-card .activity-icon {
    font-size: 56px;
    line-height: 1;
}

.activity-card .activity-name {
    font-size: 20px;
    font-weight: 800;
    text-align: center;
    color: var(--color-prompt);
}

/* === Gameplay === */
.gameplay-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 0;
}

.progress-hearts {
    flex: 1;
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    font-size: 36px;
}

.progress-hearts .heart {
    opacity: 0.3;
    transition: opacity 0.4s ease, transform 0.4s ease;
    filter: grayscale(1);
}

.progress-hearts .heart.filled {
    opacity: 1;
    filter: none;
    animation: pop-in 0.4s ease;
}

.gameplay-area {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.question-prompt {
    font-size: 36px;
    font-weight: 700;
    text-align: center;
    color: var(--color-prompt);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.08);
}

/* === Answer Buttons === */
.answer-btn {
    min-width: var(--touch-min);
    min-height: var(--touch-min-height);
    font-size: 52px;
    font-weight: 900;
    border: 4px solid var(--card-border);
    border-radius: var(--radius-large);
    background: var(--card-bg);
    box-shadow: 0 6px 0 rgba(255, 105, 180, 0.2), 0 8px 20px rgba(0, 0, 0, 0.08);
    color: var(--color-text);
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-family: inherit;
    backdrop-filter: blur(8px);
}

.answer-btn:active {
    transform: scale(0.95) translateY(3px);
    box-shadow: 0 2px 0 rgba(255, 105, 180, 0.2), 0 4px 10px rgba(0, 0, 0, 0.08);
}

.answer-btn .answer-label {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-light);
}

.answer-btn.correct {
    background: var(--color-correct-bg);
    border-color: var(--color-correct);
    animation: correct-bounce 0.5s ease;
}

.answer-btn.wrong {
    background: var(--color-wrong-bg);
    border-color: var(--color-wrong);
    animation: wrong-wobble 0.5s ease;
}

.answer-btn.hint-pulse {
    animation: pulse-hint 1s ease-in-out infinite;
    border-color: var(--color-pink);
}

/* === Answer Grid === */
.answers-grid {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
    max-width: 800px;
}

/* === Objects display for counting === */
.objects-display {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    align-items: center;
    max-width: 600px;
    min-height: 80px;
}

.objects-display .obj-item {
    font-size: 56px;
    animation: pop-in 0.3s ease backwards;
}

/* === Size Compare === */
.compare-container {
    display: flex;
    gap: 40px;
    align-items: center;
    justify-content: center;
}

.compare-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    border-radius: var(--radius-large);
    border: 4px solid var(--card-border);
    background: var(--card-bg);
    cursor: pointer;
    min-width: 180px;
    min-height: 160px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.compare-group:active {
    transform: scale(0.97);
}

.compare-group.correct {
    border-color: var(--color-correct);
    background: var(--color-correct-bg);
}

.compare-group.wrong {
    border-color: var(--color-wrong);
    background: var(--color-wrong-bg);
    animation: wrong-wobble 0.5s ease;
}

/* === Memory Game === */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    max-width: 400px;
}

.memory-card {
    width: 140px;
    height: 120px;
    border-radius: var(--radius-medium);
    border: 4px solid var(--card-border);
    background: var(--card-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    transition: transform 0.3s ease, background 0.3s ease;
    perspective: 600px;
}

.memory-card.face-down {
    background: linear-gradient(135deg, var(--color-pink-light), var(--color-pink));
    border-color: var(--color-pink);
}

.memory-card.face-down .card-face {
    display: none;
}

.memory-card.face-down .card-back {
    display: flex;
}

.memory-card .card-back {
    display: none;
    font-size: 40px;
}

.memory-card.matched {
    border-color: var(--color-correct);
    background: var(--color-correct-bg);
    pointer-events: none;
}

.memory-card:active {
    transform: scale(0.95);
}

/* === Shape display === */
.shape-display {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
}

.shape-target {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shape-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--color-pink);
}

.shape-square {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    background: #74b9ff;
}

.shape-triangle {
    width: 0;
    height: 0;
    border-left: 45px solid transparent;
    border-right: 45px solid transparent;
    border-bottom: 80px solid #fdcb6e;
}

.shape-star {
    font-size: 80px;
    line-height: 1;
    color: #fdcb6e;
}

.shape-heart {
    font-size: 80px;
    line-height: 1;
    color: var(--color-pink);
}

/* answer card for shapes */
.shape-answer-btn {
    min-width: var(--touch-min);
    min-height: var(--touch-min-height);
    border: 4px solid var(--card-border);
    border-radius: var(--radius-large);
    background: var(--card-bg);
    box-shadow: 0 6px 0 rgba(255, 105, 180, 0.2), 0 8px 20px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    padding: 12px;
}

.shape-answer-btn:active {
    transform: scale(0.95) translateY(3px);
}

.shape-answer-btn .shape-label {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text-light);
}

.shape-answer-btn.correct {
    background: var(--color-correct-bg);
    border-color: var(--color-correct);
    animation: correct-bounce 0.5s ease;
}

.shape-answer-btn.wrong {
    background: var(--color-wrong-bg);
    border-color: var(--color-wrong);
    animation: wrong-wobble 0.5s ease;
}

.shape-answer-btn.hint-pulse {
    animation: pulse-hint 1s ease-in-out infinite;
    border-color: var(--color-pink);
}

/* === Celebration Screen === */
.celebration-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.celebration-character {
    font-size: 100px;
    line-height: 1;
}

.celebration-content h2 {
    font-size: 44px;
    color: var(--color-pink);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.sticker-reveal {
    font-size: 72px;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.sticker-reveal .sticker-new {
    animation: sticker-appear 0.8s ease;
}

.sticker-reveal .sticker-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-prompt);
}

.celebration-buttons {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

/* === Sticker Book === */
.sticker-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    max-width: 900px;
    padding: 16px;
    overflow-y: auto;
    max-height: calc(100vh - 120px);
}

.sticker-slot {
    width: 100px;
    height: 100px;
    border-radius: var(--radius-medium);
    border: 3px dashed var(--color-pink-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 48px;
    background: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.sticker-slot:active {
    transform: scale(0.95);
}

.sticker-slot.earned {
    border-style: solid;
    border-color: var(--color-pink);
    background: rgba(255, 255, 255, 0.5);
}

.sticker-slot .sticker-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-light);
}

.sticker-slot.empty {
    opacity: 0.35;
}

.sticker-slot.empty::after {
    content: '💗';
    font-size: 32px;
    opacity: 0.4;
}

/* === Confetti Canvas === */
#confetti-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

/* === Hint display === */
.hint-text {
    font-size: 22px;
    color: var(--color-pink-dark);
    font-weight: 600;
    animation: fade-in 0.5s ease;
    text-align: center;
}
