/* Zoe's Block Blast - Styles */

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

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

:root {
    --bg-top: #667eea;
    --bg-bottom: #764ba2;
    --card-bg: rgba(255, 255, 255, 0.12);
    --card-border: rgba(255, 255, 255, 0.2);
    --text-white: #ffffff;
    --text-light: rgba(255, 255, 255, 0.8);
    --text-dim: rgba(255, 255, 255, 0.5);
    --accent: #FFD700;
    --accent-glow: rgba(255, 215, 0, 0.4);
    --danger: #FF6B6B;
}

html, body {
    height: 100%;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

body {
    font-family: 'Fredoka', sans-serif;
    background: linear-gradient(145deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-white);
}

/* ===== SHARED ===== */

.hidden {
    display: none !important;
}

/* ===== TITLE SCREEN ===== */

#title-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
    padding: 20px;
}

.title-character {
    width: 160px;
    height: auto;
    filter: drop-shadow(0 4px 15px rgba(0, 0, 0, 0.3));
    animation: title-bounce 2s ease-in-out infinite;
}

@keyframes title-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.title-text {
    font-family: 'Caveat', cursive;
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.1;
    text-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.title-sub {
    font-size: 1.1rem;
    color: var(--text-light);
}

.title-high-score {
    font-size: 1.2rem;
    color: var(--accent);
    font-weight: 600;
}

.play-btn {
    background: var(--accent);
    color: #333;
    border: none;
    padding: 16px 48px;
    border-radius: 50px;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 20px var(--accent-glow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 30px var(--accent-glow);
}

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

/* Auth link */
.auth-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.sign-in-link {
    font-size: 0.85rem;
    color: var(--text-dim);
    cursor: pointer;
    text-decoration: underline;
    background: none;
    border: none;
    font-family: 'Fredoka', sans-serif;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-light);
}

.sign-out-link {
    font-size: 0.75rem;
    color: var(--text-dim);
    cursor: pointer;
    background: none;
    border: none;
    font-family: 'Fredoka', sans-serif;
    text-decoration: underline;
}

/* ===== GAME SCREEN ===== */

#game-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 520px;
    padding: 10px;
    gap: 8px;
}

/* Score bar */
.score-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 500px;
    padding: 8px 16px;
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--card-border);
}

.score-section {
    text-align: center;
}

.score-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
}

.score-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 60px;
}

.high-score-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-light);
}

.streak-indicator {
    font-size: 1.3rem;
    font-weight: 700;
    min-width: 60px;
    text-align: center;
    color: var(--accent);
    animation: pulse 0.6s ease-in-out infinite alternate;
}

.mute-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    opacity: 0.7;
}

.mute-btn:hover {
    opacity: 1;
}

/* Game area with Zoe */
.game-area {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

/* Zoe reaction face — hidden by default, shown on desktop/landscape only */
.zoe-reaction {
    display: none;
    position: absolute;
    left: -110px;
    top: 10px;
    z-index: 10;
    pointer-events: none;
    transition: transform 0.3s ease;
}

.zoe-reaction img {
    width: 100px;
    height: auto;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Zoe reaction animations */
.zoe-reaction.bounce img {
    animation: zoe-bounce 0.4s ease;
}

.zoe-reaction.wiggle img {
    animation: zoe-wiggle 0.5s ease;
}

.zoe-reaction.celebrate img {
    animation: zoe-celebrate 0.6s ease;
}

@keyframes zoe-bounce {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-12px); }
    70% { transform: translateY(-4px); }
}

@keyframes zoe-wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-8deg); }
    75% { transform: rotate(8deg); }
}

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

/* Game over Zoe */
.gameover-zoe {
    width: 100px;
    height: auto;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.gameover-zoe.celebrating {
    animation: zoe-celebrate 0.8s ease infinite;
}

/* Show Zoe on desktop */
@media (min-width: 768px) {
    .zoe-reaction { display: block; }
}

/* Show Zoe on landscape (with enough width for the sidebar) */
@media (orientation: landscape) and (min-width: 640px) {
    .zoe-reaction { display: block; }
}

/* Canvas container */
.canvas-container {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1;
    border-radius: 16px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    border: 2px solid var(--card-border);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.canvas-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Block tray */
.block-tray-container {
    width: 100%;
    max-width: 500px;
    padding: 10px;
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--card-border);
}

#block-tray {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    min-height: 126px;
}

.tray-block {
    padding: 8px;
    border-radius: 10px;
    cursor: grab;
    transition: transform 0.2s, opacity 0.2s;
    touch-action: none;
}

.tray-block:hover {
    transform: scale(1.1);
}

.tray-block:active,
.tray-block.dragging {
    transform: scale(1.15);
    cursor: grabbing;
    opacity: 0.5;
}

.tray-block.used {
    opacity: 0;
    pointer-events: none;
    width: 50px;
    height: 50px;
}

/* ===== GAME OVER SCREEN ===== */

#game-over-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
    padding: 20px;
    max-height: 100dvh;
    overflow-y: auto;
}

.game-over-title {
    font-family: 'Caveat', cursive;
    font-size: 2.8rem;
    font-weight: 700;
    text-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.final-score-section {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 20px 40px;
    border: 1px solid var(--card-border);
}

.final-score-label {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.final-score-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent);
}

.final-high-score {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 4px;
}

.new-high-score {
    font-size: 1.2rem;
    color: var(--accent);
    font-weight: 600;
    animation: pulse 0.6s ease-in-out infinite alternate;
}

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

/* Leaderboard */
.leaderboard-section {
    width: 100%;
    max-width: 300px;
}

.leaderboard-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-light);
}

.leaderboard-row {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    background: var(--card-bg);
    border-radius: 10px;
    margin-bottom: 4px;
}

.lb-rank {
    width: 30px;
    font-size: 1rem;
}

.lb-name {
    flex: 1;
    text-align: left;
    font-size: 0.9rem;
    color: var(--text-light);
}

.lb-score {
    font-weight: 700;
    color: var(--accent);
    font-size: 0.95rem;
}

.leaderboard-empty {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-style: italic;
}

/* Footer */
.page-footer {
    text-align: center;
    padding: 10px;
    font-size: 0.75rem;
    color: var(--text-dim);
    position: fixed;
    bottom: 8px;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 400px) {
    .title-text { font-size: 2.4rem; }
    .play-btn { padding: 14px 36px; font-size: 1.2rem; }
    .score-value { font-size: 1.3rem; }
}

@media (min-height: 900px) {
    #game-screen { gap: 12px; }
}

@media (max-height: 700px) {
    #game-over-screen { gap: 10px; padding: 12px; }
    .game-over-title { font-size: 2rem; }
    .gameover-zoe { width: 70px; }
    .final-score-section { padding: 12px 30px; }
    .final-score-value { font-size: 2.2rem; }
}

/* Desktop: widen game screen to accommodate Zoe sidebar */
@media (min-width: 768px) {
    #game-screen {
        max-width: 580px;
    }
}
