/**
 * Game CSS - English Bubble Game
 * Styles for play.php and related game pages
 */

/* ================================
   Hero Section
   ================================ */
.hero-section {
    text-align: center;
    padding: 60px 20px 80px;
    animation: fadeUp 0.8s ease-out;
}

.hero-title {
    font-size: 48px;
    font-weight: 800;
    color: white;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    margin-bottom: 15px;
    animation: slideIn 0.7s ease-out 0.1s backwards;
}

.hero-subtitle {
    font-size: 20px;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    margin-bottom: 30px;
    animation: slideIn 0.7s ease-out 0.2s backwards;
}

.hero-image {
    margin: 30px 0;
    animation: popIn 0.8s ease-out 0.3s backwards;
}

/* ================================
   Tests Grid
   ================================ */
.tests-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin: 50px 0;
}

.test-card {
    background: var(--white-glass);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-large);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    animation: fadeUp 0.6s ease-out;
}

.test-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--blue-pastel), var(--purple-lavender), var(--pink-baby));
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.test-card:hover::before {
    opacity: 1;
}

.test-card:hover {
    transform: translateY(-12px);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 0.6);
}

.test-icon {
    font-size: 48px;
    margin-bottom: 15px;
    animation: bounce 2s ease-in-out infinite;
}

.test-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-dark);
}

.test-description {
    font-size: 14px;
    color: rgba(31, 41, 55, 0.8);
    margin-bottom: 15px;
    min-height: 40px;
}

.test-meta {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    padding: 15px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.test-meta-item {
    text-align: center;
}

.test-meta-label {
    font-size: 12px;
    color: rgba(31, 41, 55, 0.7);
    text-transform: uppercase;
}

.test-meta-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
}

.test-start-btn {
    width: 100%;
    margin-top: 20px;
}

@media (max-width: 1024px) {
    .tests-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .tests-grid {
        grid-template-columns: 1fr;
    }
    
    .hero-title {
        font-size: 32px;
    }
    
    .hero-subtitle {
        font-size: 16px;
    }
}

/* ================================
   Start Page - Ready to Play
   ================================ */
.start-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.start-card {
    background: var(--white-glass);
    backdrop-filter: blur(15px);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-xl);
    padding: 50px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.15);
    animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.start-icon {
    font-size: 64px;
    text-align: center;
    margin-bottom: 20px;
    animation: bounce 2s ease-in-out infinite;
}

.start-title {
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 10px;
    color: var(--text-dark);
}

.start-test-info {
    text-align: center;
    margin: 20px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-medium);
}

.start-test-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--purple-dark);
    margin-bottom: 10px;
}

.start-test-meta {
    display: flex;
    justify-content: space-around;
    font-size: 14px;
    color: var(--text-dark);
}

.start-input-group {
    margin: 30px 0;
}

.start-input-label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-dark);
}

.start-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 18px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-medium);
    background: var(--white-glass-strong);
    font-family: 'Nunito', 'Fredoka', sans-serif;
    transition: all var(--transition-fast);
}

.start-input:focus {
    outline: none;
    border-color: var(--blue-dark);
    box-shadow: 0 0 20px rgba(14, 165, 233, 0.4);
}

.start-buttons {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.start-buttons .btn {
    flex: 1;
}

@media (max-width: 768px) {
    .start-card {
        padding: 30px;
    }
    
    .start-title {
        font-size: 24px;
    }
}

/* ================================
   Countdown Overlay
   ================================ */
.countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.countdown-number {
    font-size: 200px;
    font-weight: 900;
    color: white;
    text-shadow: 0 10px 40px rgba(0, 0, 0, 0.5),
                 0 0 40px rgba(126, 211, 252, 0.5);
    animation: countdownPop 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes countdownPop {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        opacity: 0;
        transform: scale(1);
    }
}

/* ================================
   Game Top Bar
   ================================ */
.game-top-bar {
    background: var(--white-glass);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-large);
    padding: 15px 25px;
    margin: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-soft);
}

.game-question-info,
.game-title,
.game-timer {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.game-icon {
    font-size: 20px;
}

.game-counter-text {
    font-size: 14px;
}

.game-counter-number {
    font-size: 18px;
    font-weight: 700;
    color: var(--blue-dark);
}

.game-title {
    font-size: 16px;
    color: var(--text-dark);
}

.game-timer-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-dark);
}

@media (max-width: 768px) {
    .game-top-bar {
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .game-title {
        order: 3;
        flex-basis: 100%;
        text-align: center;
    }
}

/* ================================
   Game Container
   ================================ */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    gap: 40px;
    flex: 1;
}

/* ================================
   Bubbles Area
   ================================ */
.bubbles-area {
    width: 100%;
    max-width: 900px;
    min-height: 380px;
    position: relative;
    overflow: hidden;
    padding: 40px;
    perspective: 1000px;
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 80px rgba(255, 255, 255, 0.12),
                0 25px 80px rgba(126, 211, 252, 0.16);
    isolation: isolate;
}

.bubbles-area::before,
.bubbles-area::after {
    content: '';
    position: absolute;
    border-radius: 999px;
    filter: blur(4px);
    opacity: 0.65;
    pointer-events: none;
    z-index: 0;
}

.bubbles-area::before {
    width: 180px;
    height: 180px;
    left: 8%;
    top: 12%;
    background: radial-gradient(circle, rgba(255,255,255,.35), rgba(126,211,252,.08), transparent 70%);
    animation: softOrbMove 8s ease-in-out infinite alternate;
}

.bubbles-area::after {
    width: 220px;
    height: 220px;
    right: 8%;
    bottom: 8%;
    background: radial-gradient(circle, rgba(249,168,212,.28), rgba(196,181,253,.1), transparent 70%);
    animation: softOrbMove 10s ease-in-out infinite alternate-reverse;
}

.bubble {
    position: absolute;
    left: 0;
    top: 0;
    padding: 16px 24px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.65);
    font-weight: 800;
    font-size: 17px;
    cursor: pointer;
    background: radial-gradient(circle at 28% 18%, rgba(255,255,255,0.95), rgba(255,255,255,0.42) 18%, transparent 28%),
                linear-gradient(135deg, rgba(126, 211, 252, 0.72), rgba(196, 181, 253, 0.72), rgba(249, 168, 212, 0.62));
    color: var(--text-dark);
    box-shadow: inset 0 3px 14px rgba(255, 255, 255, 0.72),
                inset 0 -8px 18px rgba(126, 211, 252, 0.18),
                0 14px 32px rgba(0, 0, 0, 0.12),
                0 0 24px rgba(255, 255, 255, 0.22);
    transition: opacity 0.18s ease, box-shadow 0.16s ease, filter 0.16s ease, scale 0.12s ease, border-color 0.16s ease;
    white-space: nowrap;
    user-select: none;
    z-index: 2;
    filter: hue-rotate(var(--bubble-hue, 0deg));
    will-change: transform;
    scale: 1;
    touch-action: manipulation;
}

.bubble::after {
    content: '';
    position: absolute;
    width: 34%;
    height: 28%;
    left: 17%;
    top: 12%;
    border-radius: 999px;
    background: rgba(255,255,255,0.48);
    filter: blur(1px);
    pointer-events: none;
}

/* 
   Hover fix:
   Do not scale too much.
   Large scale made the hover area flicker and caused hard-to-click jitter.
*/
.bubble:hover,
.bubble.bubble-hovered {
    scale: 1.035;
    box-shadow: inset 0 3px 14px rgba(255, 255, 255, 0.9),
                inset 0 -8px 18px rgba(126, 211, 252, 0.22),
                0 18px 46px rgba(126, 211, 252, 0.42),
                0 0 28px rgba(255, 255, 255, 0.62);
    border-color: rgba(255, 255, 255, 0.92);
}

.bubble.bubble-hovered {
    z-index: 30;
}

.bubble.selected {
    opacity: 0;
    pointer-events: none;
    scale: 0.65;
}

.bubble.fly-back-flash {
    opacity: 1;
    animation: flyBackFlash 0.45s ease-out;
}

.bubble.bubble-bump {
    animation: bubbleBump 0.18s ease-out;
    box-shadow: inset 0 3px 14px rgba(255, 255, 255, 0.9),
                inset 0 -8px 18px rgba(126, 211, 252, 0.24),
                0 18px 42px rgba(126, 211, 252, 0.34),
                0 0 30px rgba(255, 255, 255, 0.72);
}

@keyframes bubbleBump {
    0% { scale: 1; }
    50% { scale: 1.07; }
    100% { scale: 1; }
}

@keyframes softOrbMove {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(34px, -24px) scale(1.1); }
}

@keyframes flyBackFlash {
    0% { scale: 0.55; filter: brightness(1.6) hue-rotate(var(--bubble-hue, 0deg)); }
    60% { scale: 1.1; filter: brightness(1.25) hue-rotate(var(--bubble-hue, 0deg)); }
    100% { scale: 1; filter: brightness(1) hue-rotate(var(--bubble-hue, 0deg)); }
}

@keyframes dropToAnswer {
    0% {
        opacity: 1;
        translate: 0 0;
    }
    100% {
        opacity: 0;
        translate: 0 150px;
    }
}

.bubble.dropping {
    animation: dropToAnswer 0.4s ease-in forwards;
}

/* ================================
   Answer Line
   ================================ */
.answer-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.answer-line {
    min-height: 80px;
    position: relative;
    background: var(--white-glass);
    backdrop-filter: blur(15px);
    border: 2px dashed rgba(126, 211, 252, 0.5);
    border-radius: var(--radius-large);
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    gap: 10px;
    transition: all var(--transition-fast);
}

.answer-line.empty::after {
    content: 'Tap the bubbles to build the sentence';
    position: absolute;
    color: rgba(31, 41, 55, 0.5);
    font-size: 14px;
    font-style: italic;
}

.answer-line.shake {
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.answer-line.correct-glow {
    border-color: var(--mint-green);
    box-shadow: 0 0 30px rgba(134, 239, 172, 0.5);
}

.answer-line.wrong-glow {
    border-color: var(--red-light);
    box-shadow: 0 0 30px rgba(252, 165, 165, 0.55);
}

.answer-word {
    background: linear-gradient(135deg, var(--blue-pastel), var(--purple-lavender));
    color: white;
    padding: 10px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.answer-word:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.answer-word[disabled],
.answer-word.locked {
    pointer-events: none;
}

@keyframes dropIn {
    0% {
        opacity: 0;
        transform: translateY(-20px) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.answer-word.drop-in {
    animation: dropIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ================================
   Game Controls
   ================================ */
.game-controls {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.game-controls .btn {
    flex: 0 1 auto;
}

/* ================================
   Correct Feedback
   ================================ */
.correct-box {
    position: fixed;
    top: 50%;
    left: 50%;
    translate: -50% -50%;
    transform: scale(1);
    background: var(--white-glass);
    backdrop-filter: blur(15px);
    border: 2px solid rgba(134, 239, 172, 0.5);
    border-radius: var(--radius-xl);
    padding: 40px;
    max-width: 500px;
    width: min(500px, calc(100vw - 32px));
    text-align: center;
    z-index: 500;
    box-shadow: 0 50px 100px rgba(0, 0, 0, 0.2);
    pointer-events: auto;
    will-change: transform, opacity;
}

.correct-box.correct-box-show {
    animation: correctBoxPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes correctBoxPop {
    0% {
        opacity: 0;
        transform: scale(0.78);
    }
    65% {
        opacity: 1;
        transform: scale(1.045);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.correct-label {
    font-size: 48px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--mint-green), var(--blue-pastel));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
    text-shadow: 0 0 30px rgba(134, 239, 172, 0.3);
}

.correct-sentence {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 15px 0;
}

.correct-translation {
    font-size: 16px;
    color: rgba(31, 41, 55, 0.8);
    font-style: italic;
    margin: 10px 0 30px;
}

.correct-box .btn {
    width: 100%;
}

/* ================================
   Wrong Feedback
   ================================ */
.wrong-message {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(252, 165, 165, 0.2);
    backdrop-filter: blur(10px);
    border: 2px solid var(--red-light);
    border-radius: var(--radius-large);
    padding: 20px 40px;
    text-align: center;
    z-index: 400;
    animation: fadeUp 0.3s ease-out;
}

.wrong-message-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--pink-dark);
}

/* ================================
   Result Page
   ================================ */
.result-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.result-card {
    background: var(--white-glass);
    backdrop-filter: blur(15px);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-xl);
    padding: 50px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.15);
    animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-align: center;
}

.result-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: bounce 1s ease-in-out infinite;
}

.result-title {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 15px;
    background: var(--gradient-blue-pink);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-student {
    font-size: 18px;
    color: rgba(31, 41, 55, 0.8);
    margin-bottom: 20px;
}

.result-score-ring {
    width: 150px;
    height: 150px;
    margin: 30px auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-score-circle {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(var(--mint-green) 0deg, var(--mint-green) var(--score-angle, 270deg), rgba(255, 255, 255, 0.3) var(--score-angle, 270deg));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(134, 239, 172, 0.3);
}

.result-score-text {
    font-size: 42px;
    font-weight: 800;
    color: var(--text-dark);
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 30px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-large);
}

.result-stat {
    text-align: center;
}

.result-stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--blue-dark);
}

.result-stat-label {
    font-size: 12px;
    color: rgba(31, 41, 55, 0.7);
    text-transform: uppercase;
    margin-top: 5px;
}

.result-message {
    font-size: 18px;
    font-weight: 700;
    margin: 20px 0;
    color: var(--text-dark);
}

.result-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 30px;
}

.result-actions .btn {
    width: 100%;
}

@media (max-width: 768px) {
    .result-card {
        padding: 30px;
    }
    
    .result-stats {
        grid-template-columns: 1fr;
    }
    
    .result-actions {
        grid-template-columns: 1fr;
    }
    
    .result-title {
        font-size: 28px;
    }
}

/* ================================
   Review Page
   ================================ */
.review-container {
    padding: 40px 20px;
    max-width: 900px;
    margin: 0 auto;
}

.review-header {
    margin-bottom: 40px;
}

.review-back-btn {
    display: inline-flex;
    gap: 8px;
    color: var(--blue-dark);
    text-decoration: none;
    font-weight: 600;
    margin-bottom: 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.review-back-btn:hover {
    gap: 12px;
}

.review-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 10px;
}

.review-info {
    font-size: 14px;
    color: rgba(31, 41, 55, 0.7);
}

.review-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 40px;
}

.review-summary-card {
    background: var(--white-glass);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-large);
    padding: 20px;
    text-align: center;
}

.review-summary-icon {
    font-size: 28px;
    margin-bottom: 10px;
}

.review-summary-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--blue-dark);
    margin-bottom: 5px;
}

.review-summary-label {
    font-size: 12px;
    color: rgba(31, 41, 55, 0.7);
    text-transform: uppercase;
}

.review-questions {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.review-question {
    background: var(--white-glass);
    backdrop-filter: blur(15px);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-large);
    padding: 25px;
    animation: fadeUp 0.6s ease-out;
}

.review-question.correct {
    border-color: rgba(134, 239, 172, 0.5);
}

.review-question.wrong {
    border-color: rgba(252, 165, 165, 0.5);
}

.review-question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.review-question-number {
    font-weight: 700;
    color: var(--text-dark);
}

.review-question-correct {
    font-size: 14px;
    font-weight: 700;
}

.review-answer-group {
    margin: 15px 0;
}

.review-answer-label {
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
    color: rgba(31, 41, 55, 0.7);
    margin-bottom: 5px;
}

.review-answer-text {
    background: rgba(255, 255, 255, 0.5);
    padding: 10px 15px;
    border-radius: var(--radius-medium);
    font-size: 15px;
    color: var(--text-dark);
}

.review-translation {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 14px;
    font-style: italic;
    color: rgba(31, 41, 55, 0.8);
}

.review-attempts {
    font-size: 12px;
    color: rgba(31, 41, 55, 0.7);
    margin-top: 10px;
}

@media (max-width: 768px) {
    .review-summary {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .review-summary {
        grid-template-columns: 1fr;
    }
}

/* ================================
   Footer
   ================================ */
.footer {
    text-align: center;
    padding: 30px 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    margin-top: 40px;
}

.footer-icons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
    font-size: 18px;
}