/* ═══════════════════════════════════════════════════════════════
   WORD CRAFT — Minecraft-style letter mining game
   Pixel-art / block aesthetic using pure CSS
═══════════════════════════════════════════════════════════════ */

:root {
    --sky:       #5B9DD9;   /* Minecraft sky blue */
    --dirt-top:  #8DB360;   /* Grass top */
    --dirt:      #866043;   /* Dirt */
    --stone:     #888888;   /* Stone */
    --coal:      #444444;   /* Coal ore */
    --iron:      #b89b78;   /* Iron ore */
    --gold:      #FFD700;   /* Gold ore */
    --diamond:   #77ecf5;   /* Diamond ore */
    --wood:      #9E7F48;   /* Wood plank */
    --sand:      #ddc968;   /* Sand */
    --lava:      #ff6600;   /* Lava */
    --text:      #1a1a2e;
    --text-light:#5a5a7a;
    --bg:        #2b2b3a;   /* Dark bg like Minecraft menu */
    --card:      #1a1a2e;
    --radius:    4px;       /* Blocky, minimal radius */
    --shadow:    0 4px 16px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Fredoka One', cursive;
    background: var(--bg);
    color: #ffffff;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ─── Screen System ─────────────────────────────────────────── */
.screen { display: none; flex-direction: column; align-items: center;
    width: 100%; padding: 20px 12px 40px; animation: fadeIn 0.18s ease; }
.screen.active { display: flex; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Pixel-border utility ──────────────────────────────────── */
/* Classic Minecraft panel outline (2px border with shadow) */
.mc-panel {
    border: 3px solid #555;
    box-shadow: inset 0 0 0 2px #888, 0 4px 0 #111;
}

/* ─── HOME ──────────────────────────────────────────────────── */
.wc-home-header {
    text-align: center;
    padding: 8px 0 20px;
}

.wc-logo {
    font-size: 4rem;
    line-height: 1;
    margin-bottom: 4px;
    animation: float 3s ease-in-out infinite;
}

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

.wc-home-header h1 {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(2.2rem, 7vw, 3rem);
    color: #FFD700;
    text-shadow: 3px 3px 0 #b8860b, -1px -1px 0 #b8860b;
    letter-spacing: 2px;
}

.wc-home-header p {
    font-family: 'Lexend Deca', system-ui, sans-serif;
    font-size: 1rem;
    color: #aaa;
    margin: 4px 0 12px;
}

.wc-stars-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #2e2e40;
    border: 2px solid #FFD700;
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 1rem;
    color: #FFD700;
}

/* ─── Biome grid ────────────────────────────────────────────── */
.wc-biome-select { width: 100%; max-width: 640px; }

.biome-label {
    font-family: 'Lexend Deca', system-ui, sans-serif;
    font-size: 0.82rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: center;
    margin-bottom: 10px;
}

.biome-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.biome-btn {
    padding: 18px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
    border: 3px solid rgba(255,255,255,0.1);
    transition: transform 0.12s, border-color 0.12s;
    background: var(--card);
    color: #fff;
}
.biome-btn:hover { transform: scale(1.04); border-color: #FFD700; }

.biome-icon { font-size: 2rem; display: block; margin-bottom: 6px; }
.biome-name { font-family: 'Fredoka One', cursive; font-size: 1.1rem; display: block; }
.biome-desc { font-family: 'Lexend Deca', system-ui, sans-serif; font-size: 0.75rem; color: #aaa; }

.biome-btn[data-biome="grass"]   { border-top: 4px solid var(--dirt-top); }
.biome-btn[data-biome="stone"]   { border-top: 4px solid var(--stone); }
.biome-btn[data-biome="desert"]  { border-top: 4px solid var(--sand); }
.biome-btn[data-biome="cave"]    { border-top: 4px solid var(--coal); }

.biome-levels {
    font-family: 'Lexend Deca', system-ui, sans-serif;
    font-size: 0.72rem;
    color: #FFD700;
    margin-top: 4px;
}

/* ─── Home Footer ───────────────────────────────────────────── */
.wc-home-footer {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: center;
    padding-top: 20px;
    flex-wrap: wrap;
}

.wc-back-link {
    color: #888;
    font-family: 'Lexend Deca', system-ui, sans-serif;
    font-size: 0.88rem;
    text-decoration: none;
    transition: color 0.15s;
}
.wc-back-link:hover { color: #fff; }

.wc-reset-btn {
    background: none;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 5px 12px;
    font-family: 'Lexend Deca', system-ui, sans-serif;
    font-size: 0.8rem;
    color: #888;
    cursor: pointer;
    transition: all 0.15s;
}
.wc-reset-btn:hover { border-color: #ef476f; color: #ef476f; }

/* ─── GAME SCREEN ───────────────────────────────────────────── */
.wc-game-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    max-width: 520px;
    margin-bottom: 16px;
}

.wc-quit-btn {
    width: 40px; height: 40px;
    background: #2e2e40;
    border: 2px solid #444;
    border-radius: var(--radius);
    color: #888;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.12s;
}
.wc-quit-btn:hover { border-color: #ef476f; color: #ef476f; }

.wc-target-word {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.wc-target-label {
    font-family: 'Lexend Deca', system-ui, sans-serif;
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.wc-target-tiles {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.wc-tile {
    width: 44px;
    height: 44px;
    background: #2e2e40;
    border: 3px solid #555;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-family: 'Fredoka One', cursive;
    color: #aaa;
    transition: all 0.25s;
    box-shadow: inset 0 -3px 0 rgba(0,0,0,0.3);
}

.wc-tile.found {
    background: var(--dirt-top);
    border-color: #5a8040;
    color: #fff;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.4);
    transform: scale(1.08);
}

.wc-lives {
    font-size: 1.2rem;
    letter-spacing: 2px;
    flex-shrink: 0;
    align-self: center;
}

/* ─── BLOCK GRID ────────────────────────────────────────────── */
.wc-grid-container {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    width: 100%;
    max-width: 360px;
    padding: 4px;
}

.wc-block {
    aspect-ratio: 1;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s;
    border: 2px solid rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.5rem, 3vw, 1rem);
    font-family: 'Fredoka One', cursive;
}

/* Pixel highlight/shadow to give 3D block feel */
.wc-block::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 50%;
    background: rgba(255,255,255,0.12);
    pointer-events: none;
}
.wc-block::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    width: 100%; height: 50%;
    background: rgba(0,0,0,0.15);
    pointer-events: none;
}

.wc-block:active:not(.dug) { transform: scale(0.92); }
.wc-block:hover:not(.dug)  { filter: brightness(1.15); }

/* Block types */
.block-dirt   { background: var(--dirt);  }
.block-grass  { background: var(--dirt-top); }
.block-stone  { background: var(--stone); }
.block-sand   { background: var(--sand);  color: #555; }
.block-coal   { background: var(--coal);  }
.block-wood   { background: var(--wood);  }

/* Crack overlays on hit */
.wc-block[data-hits="1"]::before { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cline x1='10' y1='5' x2='20' y2='20' stroke='rgba(0,0,0,0.3)' stroke-width='2'/%3E%3C/svg%3E") center/cover, rgba(255,255,255,0.1); }
.wc-block[data-hits="2"]::before { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cline x1='5' y1='5' x2='35' y2='35' stroke='rgba(0,0,0,0.4)' stroke-width='2'/%3E%3Cline x1='35' y1='5' x2='5' y2='35' stroke='rgba(0,0,0,0.4)' stroke-width='2'/%3E%3C/svg%3E") center/cover, rgba(255,255,255,0.05); }

/* Dug state */
.wc-block.dug {
    background: #111 !important;
    border-color: #222;
    cursor: default;
    animation: digBurst 0.25s ease;
    pointer-events: none;
}

@keyframes digBurst {
    0%   { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1);    opacity: 0.4; }
}

/* Letter-containing block (not visible until dug, but glows slightly) */
.wc-block.has-letter {
    /* Subtle shimmer to hint there's something inside — visible at lower opacity */
    animation: shimmer 2.5s ease-in-out infinite;
}
@keyframes shimmer {
    0%, 100% { filter: brightness(1); }
    50%       { filter: brightness(1.25); }
}

/* Revealed letter flying to target */
.letter-reveal {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #FFD700;
    text-shadow: 0 0 8px rgba(255,215,0,0.8);
    z-index: 10;
    animation: letterPop 0.4s ease forwards;
    pointer-events: none;
}
@keyframes letterPop {
    0%   { transform: scale(0);   opacity: 0; }
    50%  { transform: scale(1.5); opacity: 1; }
    100% { transform: scale(0);   opacity: 0; }
}

/* ─── HUD ───────────────────────────────────────────────────── */
.wc-hud {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 12px;
}

.wc-hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: #2e2e40;
    border: 2px solid #444;
    border-radius: var(--radius);
    padding: 8px 16px;
    min-width: 60px;
}

.wc-hud-item span {
    font-family: 'Fredoka One', cursive;
    font-size: 1.4rem;
    color: #FFD700;
}

.wc-hud-item label {
    font-family: 'Lexend Deca', system-ui, sans-serif;
    font-size: 0.7rem;
    color: #888;
}

/* ─── WIN SCREEN ────────────────────────────────────────────── */
.wc-win-card {
    background: #1a1a2e;
    border: 4px solid #FFD700;
    border-radius: 8px;
    padding: 36px 28px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.wc-win-stars { font-size: 2.4rem; letter-spacing: 4px; margin-bottom: 10px; }

.wc-win-word {
    font-size: 2.5rem;
    color: #FFD700;
    letter-spacing: 6px;
    text-shadow: 3px 3px 0 #b8860b;
    margin-bottom: 8px;
}

.wc-win-card h2 {
    font-family: 'Fredoka One', cursive;
    font-size: 1.6rem;
    color: #fff;
    margin-bottom: 6px;
}

.wc-win-card p {
    font-family: 'Lexend Deca', system-ui, sans-serif;
    font-size: 0.9rem;
    color: #aaa;
    line-height: 1.55;
    margin-bottom: 20px;
}

.wc-win-stats {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 22px;
}

.wc-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #2e2e40;
    border-radius: var(--radius);
    padding: 10px 14px;
    min-width: 60px;
}
.wc-stat span { font-family: 'Fredoka One', cursive; font-size: 1.5rem; color: #FFD700; }
.wc-stat label { font-family: 'Lexend Deca', system-ui, sans-serif; font-size: 0.72rem; color: #888; }

.wc-win-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.wc-btn-primary {
    padding: 12px 24px;
    background: #FFD700;
    color: #1a1a2e;
    border: none;
    border-radius: var(--radius);
    font-family: 'Fredoka One', cursive;
    font-size: 1rem;
    cursor: pointer;
    transition: filter 0.12s;
    box-shadow: 0 3px 0 #b8860b;
}
.wc-btn-primary:hover { filter: brightness(1.1); }

.wc-btn-secondary {
    padding: 12px 24px;
    background: #3d3d5a;
    color: #fff;
    border: 2px solid #555;
    border-radius: var(--radius);
    font-family: 'Fredoka One', cursive;
    font-size: 1rem;
    cursor: pointer;
    transition: filter 0.12s;
}
.wc-btn-secondary:hover { filter: brightness(1.2); }

.wc-btn-ghost {
    background: none;
    border: 1px solid #444;
    border-radius: var(--radius);
    padding: 8px 18px;
    font-family: 'Lexend Deca', system-ui, sans-serif;
    font-size: 0.85rem;
    color: #888;
    cursor: pointer;
    transition: all 0.12s;
}
.wc-btn-ghost:hover { border-color: #888; color: #fff; }

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 380px) {
    .wc-grid-container { gap: 3px; }
    .wc-tile { width: 36px; height: 36px; font-size: 1.1rem; }
}

/* ─── Inventory Row ──────────────────────────────────────────── */
.wc-inventory {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 0 0 14px;
    min-height: 32px;
}
.inv-badge {
    background: #2e2e40;
    border: 2px solid #FFD700;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 1rem;
    color: #FFD700;
    font-family: 'Fredoka One', cursive;
}
.inv-hint {
    font-family: 'Lexend Deca', system-ui, sans-serif;
    font-size: 0.8rem;
    color: #555;
}

/* ─── Special biome buttons ──────────────────────────────────── */
.biome-btn.biome-special {
    border: 3px solid transparent;
    background: linear-gradient(#1a1a2e, #1a1a2e) padding-box,
                linear-gradient(135deg, #FFD700, #ff6bff, #77ecf5) border-box;
    animation: specialGlow 2s ease-in-out infinite alternate;
}
@keyframes specialGlow {
    from { box-shadow: 0 0 8px #FFD70088; }
    to   { box-shadow: 0 0 22px #ff6bff88; }
}

/* ─── Special block types ────────────────────────────────────── */
.block-diamond { background: #1a5a6e; }
.block-rainbow {
    background: linear-gradient(135deg, #ff6b6b, #ffd166, #06d6a0, #74b9ff, #a29bfe);
    background-size: 200% 200%;
    animation: rainbowBlock 3s ease infinite;
}
@keyframes rainbowBlock {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ─── Treasure block shimmer (stronger than letter shimmer) ──── */
.wc-block.has-treasure {
    animation: treasureShimmer 1.5s ease-in-out infinite;
}
@keyframes treasureShimmer {
    0%, 100% { filter: brightness(1); }
    50%       { filter: brightness(1.4) saturate(1.3); }
}

/* ─── Treasure reveal pop ────────────────────────────────────── */
.treasure-reveal {
    font-size: 2rem !important;
}

/* ─── Treasure Popup ──────────────────────────────────────────── */
.treasure-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500;
    background: #1a1a2e;
    border: 3px solid var(--t-color, #FFD700);
    border-radius: 16px;
    padding: 28px 32px;
    text-align: center;
    box-shadow: 0 0 40px var(--t-color, #FFD700), 0 8px 32px rgba(0,0,0,0.6);
    animation: popupBounce 0.4s cubic-bezier(0.175,0.885,0.32,1.275);
    max-width: 320px;
    width: 90%;
}
.treasure-popup.treasure-rare {
    border-width: 4px;
    animation: popupBounce 0.4s cubic-bezier(0.175,0.885,0.32,1.275),
               rareGlow 1.5s 0.4s ease-in-out infinite alternate;
}
@keyframes rareGlow {
    from { box-shadow: 0 0 20px var(--t-color, #FFD700); }
    to   { box-shadow: 0 0 50px var(--t-color, #FFD700), 0 0 80px rgba(255,107,255,0.5); }
}
@keyframes popupBounce {
    from { transform: translate(-50%,-50%) scale(0.4); opacity:0; }
    to   { transform: translate(-50%,-50%) scale(1);   opacity:1; }
}
.tp-emoji {
    font-size: 3.5rem;
    line-height: 1;
    margin-bottom: 10px;
    animation: float 1s ease-in-out infinite;
}
.tp-label {
    font-family: 'Fredoka One', cursive;
    font-size: 1.3rem;
    color: var(--t-color, #FFD700);
    margin-bottom: 6px;
}
.tp-effect {
    font-family: 'Lexend Deca', system-ui, sans-serif;
    font-size: 0.88rem;
    color: #aaa;
    margin-bottom: 18px;
    line-height: 1.5;
}
.tp-close {
    padding: 10px 28px;
    background: var(--t-color, #FFD700);
    color: #1a1a2e;
    border: none;
    border-radius: 8px;
    font-family: 'Fredoka One', cursive;
    font-size: 1rem;
    cursor: pointer;
    transition: filter 0.12s;
}
.tp-close:hover { filter: brightness(1.15); }

/* ─── Win inventory hint ──────────────────────────────────────── */
.win-inventory-hint {
    font-family: 'Lexend Deca', system-ui, sans-serif;
    font-size: 0.82rem;
    color: #FFD700;
    min-height: 20px;
    margin-bottom: 12px;
}

/* ─── Axolotl-specific popup enhancements ───────────────────── */
.axolotl-emoji {
    display: inline-block;
    font-size: 4rem !important;
    /* filter is applied inline per variant */
    animation: float 0.8s ease-in-out infinite, axolotlSpin 0.5s ease-out;
}

@keyframes axolotlSpin {
    from { transform: rotate(-20deg) scale(0.6); }
    to   { transform: rotate(0deg)   scale(1); }
}

/* Confetti particle fall */
@keyframes confettiFall {
    0%   { transform: translateY(0)   rotate(0deg);   opacity: 1; }
    100% { transform: translateY(60vh) rotate(540deg); opacity: 0; }
}
