/* Word Bubbles v2 — SVG Pixel Art Game */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@800&family=Press+Start+2P&display=swap');

.wb-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 0 10px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ── Game header ───────────────────────────────── */
.wb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border-radius: 12px;
    margin-bottom: 12px;
    font-family: 'Press Start 2P', monospace;
    color: #e0e0e0;
    image-rendering: pixelated;
}

.wb-stat {
    text-align: center;
    font-size: 10px;
    line-height: 1.6;
}

.wb-stat-value {
    display: block;
    font-size: 16px;
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.wb-stat-label {
    font-size: 7px;
    color: #8892b0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ── SVG game area ─────────────────────────────── */
.wb-game-area {
    position: relative;
    width: 100%;
    background: linear-gradient(180deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    border-radius: 16px;
    overflow: hidden;
    touch-action: manipulation;
    box-shadow: 0 0 30px rgba(108, 92, 231, 0.3), inset 0 0 60px rgba(0, 0, 0, 0.3);
}

.wb-game-area svg {
    display: block;
    width: 100%;
    height: auto;
}

/* ── Twinkling stars ───────────────────────────── */
.wb-stars { pointer-events: none; }

.wb-stars rect {
    opacity: var(--star-op, 0.3);
    animation: wb-twinkle var(--tw-dur, 3s) ease-in-out var(--tw-del, 0s) infinite alternate;
}

@keyframes wb-twinkle {
    0%, 100% { opacity: var(--star-op, 0.3); }
    50% { opacity: calc(var(--star-op, 0.3) + 0.4); }
}

/* ── Bubble styles ─────────────────────────────── */
.wb-bubble {
    cursor: pointer;
    transition: filter 0.15s ease;
}

.wb-bubble:hover {
    filter: brightness(1.15);
}

.wb-bubble-circle {
    transition: stroke-width 0.2s ease, stroke 0.2s ease;
}

.wb-bubble.selected .wb-bubble-circle {
    stroke: #ffd700;
    stroke-width: 3;
    filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.7));
}

.wb-bubble-text {
    fill: white;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

/* Pop animation */
@keyframes wb-pop {
    0% { transform: scale(1); opacity: 1; }
    30% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0); opacity: 0; }
}

.wb-bubble.popping {
    animation: wb-pop 0.4s ease-out forwards;
    pointer-events: none;
}

/* Wobble */
@keyframes wb-wobble {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.wb-bubble.wobble {
    animation: wb-wobble 0.4s ease-out;
}

/* Hint: briefly highlight correct pair on wrong match */
@keyframes wb-hint-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.6) drop-shadow(0 0 8px rgba(85, 239, 196, 0.8)); }
}

.wb-bubble.hint {
    animation: wb-hint-pulse 0.4s ease-in-out 2;
}

/* Confetti */
@keyframes wb-confetti {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}

.wb-confetti { pointer-events: none; }

/* Score float */
@keyframes wb-score-float {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-40px); }
}

.wb-score-float {
    font-family: 'Press Start 2P', monospace;
    fill: #ffd700;
    font-size: 14px;
    text-anchor: middle;
    pointer-events: none;
    animation: wb-score-float 0.8s ease-out forwards;
}

/* ── Mascot ────────────────────────────────────── */
.wb-mascot { /* no transition — it conflicts with SVG transform positioning */ }

@keyframes wb-mascot-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.wb-mascot.happy { animation: wb-mascot-bounce 0.4s ease-out 2; }

@keyframes wb-mascot-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

.wb-mascot.sad { animation: wb-mascot-shake 0.3s ease-out; }

@keyframes wb-mascot-dance {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-5deg) scale(1.1); }
    50% { transform: rotate(5deg) scale(1.15); }
    75% { transform: rotate(-3deg) scale(1.1); }
}

@keyframes wb-mascot-jump {
    0%, 100% { transform: translateY(0) scale(1); }
    30% { transform: translateY(-12px) scale(1.15); }
    60% { transform: translateY(-4px) scale(1.05); }
}

.wb-mascot.surprised { animation: wb-mascot-jump 0.6s ease-out; }

.wb-mascot.celebrate { animation: wb-mascot-dance 0.5s ease-out 3; }

/* ── Start screen ──────────────────────────────── */
.wb-start-screen {
    text-align: center;
    padding: 40px 20px;
    font-family: 'Press Start 2P', monospace;
    color: #e0e0e0;
    background: linear-gradient(180deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    border-radius: 16px;
    box-shadow: 0 0 30px rgba(108, 92, 231, 0.3);
}

.wb-start-mascot { margin-bottom: 8px; }

.wb-start-title {
    font-size: 20px;
    color: #ffd700;
    margin: 12px 0 20px;
    text-shadow: 0 0 16px rgba(255, 215, 0, 0.5);
}

.wb-instructions {
    margin: 20px 0;
    font-size: 9px;
    line-height: 2.4;
    color: #8892b0;
}

.wb-instructions p { margin: 4px 0; }

.wb-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.wb-dot.gold { background: #ffd700; }
.wb-dot.pink { background: #fd79a8; }
.wb-dot.green { background: #55efc4; }

.wb-returning {
    font-size: 8px;
    color: #6c5ce7;
    margin: 12px 0;
}

.wb-reset-link {
    display: block;
    margin-top: 12px;
    font-size: 7px;
    color: #8892b0;
    text-decoration: underline;
    font-family: 'Press Start 2P', monospace;
}

/* ── Round complete overlay ────────────────────── */
.wb-round-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 12, 41, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 16px;
    animation: wb-fade-in 0.3s ease;
}

@keyframes wb-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.wb-round-complete {
    text-align: center;
    font-family: 'Press Start 2P', monospace;
    color: #e0e0e0;
    padding: 24px;
}

.wb-round-complete h3 {
    font-size: 14px;
    color: #ffd700;
    margin-bottom: 12px;
}

.wb-round-score {
    font-size: 11px;
    color: #55efc4;
    margin-bottom: 16px;
}

.wb-round-words {
    font-size: 8px;
    line-height: 2;
    margin-bottom: 12px;
}

.wb-round-word {
    padding: 2px 8px;
    border-radius: 4px;
    margin: 2px;
    display: inline-block;
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
}

.wb-round-word.correct {
    background: rgba(0, 184, 148, 0.3);
    color: #55efc4;
}

.wb-round-word.wrong {
    background: rgba(225, 112, 85, 0.3);
    color: #fab1a0;
}

.wb-round-streak {
    font-size: 10px;
    color: #ffd700;
    margin-bottom: 12px;
    animation: wb-pulse 0.5s ease infinite alternate;
}

@keyframes wb-pulse {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

.wb-next-btn {
    font-size: 10px;
    padding: 10px 24px;
}

/* ── Milestone notification ────────────────────── */
.wb-milestone {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    z-index: 20;
    pointer-events: none;
    animation: wb-milestone-anim 1.5s ease-out forwards;
}

@keyframes wb-milestone-anim {
    0% { opacity: 0; transform: translateX(-50%) scale(0.5); }
    15% { opacity: 1; transform: translateX(-50%) scale(1.2); }
    30% { transform: translateX(-50%) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-30px); }
}

/* ── Language picker modal ─────────────────────── */
.wb-modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.wb-modal {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border-radius: 16px;
    padding: 32px;
    max-width: 360px;
    width: 90%;
    text-align: center;
    font-family: 'Press Start 2P', monospace;
    color: #e0e0e0;
    border: 2px solid #6c5ce7;
    box-shadow: 0 0 40px rgba(108, 92, 231, 0.4);
}

.wb-modal h3 { font-size: 14px; margin-bottom: 20px; color: #ffd700; }

.wb-modal select {
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    background: #24243e;
    color: #e0e0e0;
    border: 1px solid #6c5ce7;
    border-radius: 8px;
    font-size: 12px;
    font-family: inherit;
}

.wb-modal-btn {
    display: inline-block;
    margin-top: 16px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #6c5ce7, #a855f7);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.wb-modal-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.6);
}

/* ── Settings bar ──────────────────────────────── */
.wb-settings {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #8892b0;
}

.wb-settings label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 11px;
}

.wb-settings input[type="checkbox"] {
    accent-color: #6c5ce7;
}

/* ── End screen ────────────────────────────────── */
.wb-end-screen {
    text-align: center;
    padding: 40px 20px;
    font-family: 'Press Start 2P', monospace;
    color: #e0e0e0;
    background: linear-gradient(180deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    border-radius: 16px;
    box-shadow: 0 0 30px rgba(108, 92, 231, 0.3);
}

.wb-end-screen h2 {
    font-size: 18px;
    color: #ffd700;
    margin-bottom: 24px;
}

.wb-end-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 24px;
}

.wb-end-stat {
    background: rgba(108, 92, 231, 0.2);
    padding: 14px 8px;
    border-radius: 12px;
    border: 1px solid rgba(108, 92, 231, 0.3);
}

.wb-end-stat .value {
    font-size: 18px;
    color: #ffd700;
    display: block;
}

.wb-end-stat .label {
    font-size: 6px;
    color: #8892b0;
    margin-top: 4px;
    display: block;
}

.wb-play-btn {
    display: inline-block;
    padding: 14px 32px;
    background: linear-gradient(135deg, #00b894, #00cec9);
    color: #1a1a2e;
    border: none;
    border-radius: 12px;
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
}

.wb-play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 184, 148, 0.5);
    color: #1a1a2e;
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 400px) {
    .wb-header { padding: 8px 12px; }
    .wb-stat-value { font-size: 14px; }
    .wb-stat-label { font-size: 6px; }
    .wb-start-title { font-size: 16px; }
    .wb-end-stats { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 360px) {
    .wb-stat-value { font-size: 12px; }
    .wb-stat-label { font-size: 5px; }
}

@media (max-height: 500px) and (orientation: landscape) {
    .wb-container { max-width: 90vw; }
    .wb-header { padding: 6px 12px; margin-bottom: 6px; }
    .wb-stat-value { font-size: 12px; }
    .wb-settings { padding: 4px 8px; }
}

/* ── Fullscreen mode ──────────────────────────── */
.game-fullscreen {
    background: linear-gradient(180deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.game-fullscreen .wb-fs-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    padding: 10px 24px;
    box-sizing: border-box;
}

.game-fullscreen .wb-settings {
    color: #8892b0;
    flex-shrink: 0;
    padding: 8px 0;
}

.game-fullscreen .collapse {
    flex-shrink: 0;
}

.game-fullscreen .wb-container {
    max-width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.game-fullscreen .wb-container .wb-game-area {
    flex: 1;
}

.game-fullscreen .wb-container .wb-game-area svg {
    height: 100%;
    width: 100%;
}

.game-fullscreen .wb-container .wb-start-screen,
.game-fullscreen .wb-container .wb-end-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.game-fullscreen .wb-container .wb-header {
    flex-shrink: 0;
}

.game-fullscreen #wb-controls {
    flex-shrink: 0;
    padding: 10px 0;
}
