/* ===== Play / Join Game Page ===== */

:root {
    --bg-dark: #180f04;
    --bg-dark-alt: #261608;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-white: #F8FAFC;
    --text-light: #CBD5E1;
    --text-muted: #64748B;
    --purple-light: #FB923C;
    --radius: 10px;
    --radius-lg: 16px;
    --transition: 0.2s ease;
    --font-display: 'Fredoka', 'Nunito', sans-serif;
    --font-body: 'Inter', 'Segoe UI', sans-serif;
}

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

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

body {
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-dark-alt) 100%);
    color: var(--text-white);
    font-family: var(--font-body);
    min-height: 100vh;
}

/* ===== Screens ===== */
.play-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.play-hidden {
    display: none !important;
}

.play-container {
    text-align: center;
    width: 100%;
    max-width: 420px;
}

.play-brand {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.play-title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-white);
    margin-bottom: 32px;
}

/* ===== Join Screen Badge Columns ===== */
.join-badges {
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: center;
    flex-shrink: 0;
}

.join-badges-left  { margin-right: 48px; }
.join-badges-right { margin-left: 48px; }

.join-badge {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: default;
}

.join-badge:hover {
    transform: translateY(-6px) rotate(5deg);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.join-badge:nth-child(2) { transform: translateX(12px); }
.join-badge:nth-child(2):hover { transform: translateX(12px) translateY(-6px) rotate(-5deg); }

.join-badge img {
    width: 68px;
    height: 68px;
    object-fit: contain;
}

@media (max-width: 800px) {
    .join-badges-left,
    .join-badges-right { display: none; }
}

/* ===== Join Form ===== */
.join-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.join-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
}

.join-input {
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 10px;
    color: var(--text-white);
    text-align: center;
    outline: none;
    transition: border-color var(--transition);
}

.join-input:focus {
    border-color: var(--purple-light);
}

.join-input::placeholder {
    color: rgba(255, 255, 255, 0.15);
    letter-spacing: 10px;
}

.join-input-name {
    font-family: var(--font-body, 'Lexend Deca', sans-serif);
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

.join-input-name::placeholder {
    letter-spacing: 0;
}

.join-error {
    color: #FF6B6B;
    font-size: 0.82rem;
    min-height: 20px;
}

/* ===== Play Buttons ===== */
.btn-play {
    padding: 14px 24px;
    border-radius: var(--radius-lg);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.btn-play-join {
    background: linear-gradient(135deg, #F97316, #FB923C);
    color: white;
    width: 100%;
    margin-top: 8px;
}

.btn-play-join:hover {
    background: linear-gradient(135deg, #EA6C0A, #F97316);
    box-shadow: 0 4px 20px rgba(249, 115, 22, 0.45);
}

.btn-play-join.loading .btn-text { opacity: 0; }
.btn-play-join.loading .spinner-play { display: block; }

.spinner-play {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ===== Waiting Screen ===== */
.wait-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    animation: popIn 0.4s ease;
}

@keyframes popIn {
    from { transform: scale(0); }
    50% { transform: scale(1.2); }
    to { transform: scale(1); }
}

.wait-name {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--purple-light);
    margin-bottom: 12px;
}

.wait-msg {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.wait-pulse {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(249, 115, 22, 0.3);
    margin: 0 auto;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.5); opacity: 0.1; }
}

/* ===== Game Active Screen ===== */
.game-active-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.game-hud {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 12px 20px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.hud-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hud-value {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-white);
}

#hudScore { color: #55EFC4; }
#hudMultiplier { color: #FACC15; }

.game-activity-frame {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.game-activity-frame iframe {
    width: 100%;
    height: 600px;
    border: none;
    border-radius: var(--radius-lg);
}

.loading-activity {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== Notifications ===== */
.game-notifications {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
    pointer-events: none;
}

.game-notif {
    background: rgba(30, 15, 5, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 10px 18px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-white);
    animation: notifSlide 0.3s ease, notifFade 0.3s ease 3s forwards;
}

.game-notif.steal { border-color: rgba(255, 107, 107, 0.5); }
.game-notif.swap { border-color: rgba(250, 204, 21, 0.5); }

@keyframes notifSlide {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes notifFade {
    to { opacity: 0; }
}

/* ===== Game Over ===== */
.final-placement {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 4px;
    min-height: 0;
}

.final-placement[data-rank="1"] { color: #FACC15; }
.final-placement[data-rank="2"] { color: #94A3B8; }
.final-placement[data-rank="3"] { color: #CD7F32; }

.final-score {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.final-score-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.final-score-value {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 3rem;
    font-weight: 800;
    color: #55EFC4;
}

.final-msg {
    color: var(--text-light);
    font-size: 1rem;
}

/* ===== Game Over Close Button ===== */
.game-over-close {
    position: absolute;
    top: 20px;
    right: 24px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-light);
    font-size: 1.6rem;
    line-height: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.game-over-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-white);
    border-color: rgba(255, 255, 255, 0.3);
}

/* ===== Prize Pick Overlay ===== */
.prize-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 5, 30, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    z-index: 200;
    animation: prizeIn 0.4s ease;
    padding: 16px;
}

.prize-overlay.prize-hidden {
    display: none !important;
}

@keyframes prizeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.prize-container {
    text-align: center;
    max-width: 480px;
    width: 100%;
    padding: 16px 8px;
    margin: auto;
}

.prize-header {
    margin-bottom: 24px;
}

.prize-earned-label {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.prize-earned-points {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 1.8rem;
    font-weight: 800;
    color: #55EFC4;
}

.prize-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    color: var(--text-white);
    margin-bottom: 24px;
}

.prize-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    max-width: 320px;
    margin: 0 auto 24px;
}

.prize-card {
    aspect-ratio: 1;
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.2), rgba(251, 146, 60, 0.15));
    border: 2px solid rgba(249, 115, 22, 0.4);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    position: relative;
    overflow: hidden;
}

.prize-card:hover:not(.prize-picked):not(.prize-revealed) {
    border-color: #FB923C;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(249, 115, 22, 0.3);
}

.prize-card.prize-picked {
    cursor: default;
    animation: prizeFlip 0.5s ease;
    border-color: #FACC15;
    background: rgba(250, 204, 21, 0.1);
}

.prize-card.prize-revealed {
    cursor: default;
    opacity: 0.35;
    transform: scale(0.95);
}

@keyframes prizeFlip {
    0% { transform: scale(1) rotateY(0deg); }
    50% { transform: scale(1.1) rotateY(90deg); }
    100% { transform: scale(1) rotateY(0deg); }
}

.prize-card-icon {
    pointer-events: none;
}

/* Prize Result */
.prize-result {
    animation: resultIn 0.4s ease;
}

.prize-result.prize-hidden {
    display: none !important;
}

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

.prize-result-icon {
    font-size: 3rem;
    margin-bottom: 8px;
}

.prize-result-text {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-white);
    margin-bottom: 4px;
}

.prize-result-detail {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 20px;
}

.btn-play-continue {
    background: linear-gradient(135deg, #F97316, #FB923C);
    color: white;
    padding: 12px 40px;
}

.btn-play-continue:hover {
    background: linear-gradient(135deg, #EA6C0A, #F97316);
    box-shadow: 0 4px 20px rgba(249, 115, 22, 0.45);
}

@media (max-height: 680px) {
    .prize-header { margin-bottom: 12px; }
    .prize-earned-points { font-size: 1.3rem; }
    .prize-title { font-size: 1.1rem; margin-bottom: 14px; }
    .prize-grid { gap: 8px; margin-bottom: 14px; }
    .prize-grid { max-width: 260px; }
    .prize-card { font-size: 1.8rem; }
}

/* ===== Badge Picker ===== */
.badge-picker-container {
    max-width: 560px;
}

.badge-picker-hint {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 24px;
    text-align: center;
}

.badge-picker-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-height: 48vh;
    overflow-y: auto;
    padding: 4px;
    margin-bottom: 28px;
}

.badge-option {
    width: 76px;
    height: 76px;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    overflow: hidden;
}

.badge-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    display: block;
}

.badge-option:hover {
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.badge-option.selected {
    border-color: #FACC15;
    box-shadow: 0 0 14px rgba(250, 204, 21, 0.5);
    transform: scale(1.08);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .join-input {
        font-size: 1.5rem;
        letter-spacing: 6px;
    }

    .game-hud {
        gap: 16px;
        padding: 10px 12px;
    }

    .hud-value {
        font-size: 1rem;
    }
}

/* ===== HUD Badge Avatar ===== */
.hud-avatar-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hud-avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
}
.hud-avatar-crown {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6));
}

/* ===== Desert Alchemy Mini-Game ===== */
#lobbyWaitScreen {
    align-items: flex-start;
    overflow-y: auto;
}

.alchemy-container {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 20px 0 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

.alchemy-title {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    color: #F59E0B;
    margin: 0;
}

.alchemy-player {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0;
}

.alchemy-player span:first-child {
    color: #F59E0B;
    font-weight: 600;
}

.alchemy-inventory {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    width: 100%;
}

.alchemy-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 10px;
    background: rgba(245, 158, 11, 0.08);
    border: 1.5px solid rgba(245, 158, 11, 0.22);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    min-width: 68px;
    color: var(--text-light);
}

.alchemy-card-emoji {
    font-size: 1.5rem;
    line-height: 1;
    pointer-events: none;
}

.alchemy-card-img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 6px;
    pointer-events: none;
}

.alchemy-card-name {
    font-size: 0.68rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
}

.alchemy-card:hover {
    background: rgba(245, 158, 11, 0.18);
    border-color: rgba(245, 158, 11, 0.5);
    transform: scale(1.06);
}

.alchemy-card.selected {
    background: rgba(245, 158, 11, 0.22);
    border-color: #F59E0B;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.35);
}

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

.alchemy-card.new-card {
    animation: alchemyPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    border-color: #22D3EE;
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.4);
}

.alchemy-combine-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 4px;
}

.alchemy-slot {
    width: 88px;
    height: 76px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: rgba(245, 158, 11, 0.06);
    border: 2px dashed rgba(245, 158, 11, 0.3);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
    color: rgba(245, 158, 11, 0.45);
    font-size: 0.75rem;
}

.alchemy-slot:hover {
    border-color: rgba(245, 158, 11, 0.5);
}

.alchemy-slot.filled {
    border-style: solid;
    border-color: #F59E0B;
    background: rgba(245, 158, 11, 0.13);
    color: var(--text-white);
}

.alchemy-slot-placeholder {
    font-size: 1.6rem;
    opacity: 0.45;
    pointer-events: none;
}

.alchemy-slot-emoji {
    font-size: 1.6rem;
    line-height: 1;
    pointer-events: none;
}

.alchemy-slot-img {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border-radius: 6px;
    pointer-events: none;
}

.alchemy-slot-name {
    font-size: 0.65rem;
    font-weight: 600;
    text-align: center;
    pointer-events: none;
}

.alchemy-plus {
    font-size: 1.4rem;
    color: rgba(245, 158, 11, 0.5);
    font-weight: 700;
    line-height: 1;
}

.alchemy-result {
    min-height: 30px;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: 8px;
    padding: 5px 14px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.alchemy-result.show {
    opacity: 1;
}

.alchemy-result.discovery {
    color: #22D3EE;
    background: rgba(34, 211, 238, 0.1);
    animation: alchemyResultPop 0.3s ease;
}

.alchemy-result.known {
    color: var(--text-muted);
}

.alchemy-result.no-match {
    color: #FF6B6B;
    animation: alchemyResultShake 0.3s ease;
}

@keyframes alchemyResultPop {
    0%, 100% { transform: scale(1); }
    45% { transform: scale(1.07); }
}

@keyframes alchemyResultShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.alchemy-wait-msg {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin: 0;
}

.btn-change-character {
    margin-top: 14px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: var(--font-body);
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-change-character:hover {
    border-color: rgba(255, 255, 255, 0.4);
    color: var(--text-light);
}

/* ===== Easter Egg Award Overlay (shared) ===== */
.easter-egg-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: eggFadeIn 0.5s ease;
}
@keyframes eggFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.egg-overlay-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}
.egg-overlay-img {
    width: 160px;
    height: 160px;
    object-fit: contain;
    animation: eggBounce 0.8s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
    filter: drop-shadow(0 0 24px rgba(250, 204, 21, 0.8));
}
@keyframes eggBounce {
    0%   { transform: scale(0) rotate(-10deg); opacity: 0; }
    60%  { transform: scale(1.15) rotate(4deg); opacity: 1; }
    80%  { transform: scale(0.95) rotate(-2deg); }
    100% { transform: scale(1) rotate(0); }
}
.egg-overlay-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: #fbbf24;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.6);
    letter-spacing: 0.02em;
}
.egg-overlay-sub {
    font-size: 1rem;
    color: rgba(255,255,255,0.75);
}
