/* 
 * FF Live Play - Universal Game Rewards System Styles
 * Safe, isolated, lightweight styles for the reward HUD and animations.
 */

:root {
    --ff-primary: #7c3aed;
    --ff-bg: rgba(15, 23, 42, 0.85);
    --ff-border: rgba(255, 255, 255, 0.1);
    --ff-text: #f8fafc;
    --ff-gold: #fbbf24;
    --ff-blue: #3b82f6;
    --ff-orange: #f97316;
}

/* HUD Container */
#ff-reward-hud {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 2147483640; /* High z-index to stay above games */
    font-family: system-ui, -apple-system, sans-serif;
    pointer-events: none; /* Let clicks pass through empty areas */
}

.ff-hud-inner {
    background: var(--ff-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--ff-border);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    pointer-events: auto; /* Make HUD clickable */
    color: var(--ff-text);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 160px;
    transition: opacity 0.3s ease;
}

.ff-hud-inner.hidden {
    display: none !important;
}

/* Minimized HUD */
#ff-hud-minimized {
    background: var(--ff-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--ff-border);
    border-radius: 20px;
    padding: 6px 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    color: var(--ff-gold);
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
}

#ff-hud-minimized.hidden {
    display: none !important;
}

#ff-hud-minimized:hover {
    background: rgba(30, 41, 59, 0.95);
}

/* Stats */
.ff-hud-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ff-pill {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ff-coin-pill { color: var(--ff-gold); }
.ff-xp-pill { color: var(--ff-blue); }
.ff-streak-pill { color: var(--ff-orange); }

/* Bottom Row */
.ff-hud-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2px;
    border-top: 1px solid var(--ff-border);
    padding-top: 8px;
}

.ff-timer {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
}

.ff-hud-controls {
    display: flex;
    gap: 4px;
}

.ff-hud-controls button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid transparent;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s;
    padding: 0;
}

.ff-hud-controls button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Toast System */
#ff-toast-container {
    position: fixed;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2147483645;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    align-items: center;
}

.ff-toast {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #000;
    font-weight: 900;
    font-family: system-ui, sans-serif;
    padding: 12px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.5), inset 0 2px 4px rgba(255,255,255,0.4);
    font-size: 18px;
    line-height: 1.3;
    text-align: center;
    text-shadow: 0 1px 1px rgba(255,255,255,0.3);
    opacity: 0;
    transform: translateY(-20px) scale(0.8);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ff-toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Modal System */
#ff-reward-modal {
    position: fixed;
    inset: 0;
    z-index: 2147483646;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-family: system-ui, sans-serif;
}

#ff-reward-modal.hidden {
    display: none !important;
}

.ff-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.ff-modal-content {
    background: var(--ff-bg);
    border: 1px solid var(--ff-border);
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    position: relative;
    z-index: 2;
    color: var(--ff-text);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.ff-modal-header {
    background: rgba(0, 0, 0, 0.2);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--ff-border);
}

.ff-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
    color: var(--ff-gold);
}

#ff-modal-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    line-height: 1;
}

#ff-modal-close:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.ff-modal-body {
    padding: 20px;
}

.ff-modal-body ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ff-modal-body li {
    font-size: 14px;
    line-height: 1.5;
    color: #cbd5e1;
}

.ff-modal-body b {
    color: white;
}

/* Coin Rain Animation */
.ff-coin-rain-layer {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 2147483647 !important;
  pointer-events: none !important;
  overflow: hidden !important;
}

.ff-falling-coin {
  position: absolute !important;
  top: -60px !important;
  pointer-events: none !important;
  opacity: 1;
  animation: ff-coin-fall 2.4s ease-in forwards;
  will-change: transform, opacity;
}

@keyframes ff-coin-fall {
  0% {
    transform: translateY(-80px) rotate(0deg) scale(.8);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    transform: translateY(115vh) rotate(760deg) scale(.95);
    opacity: 0;
  }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #ff-reward-hud {
        top: auto;
        bottom: 10px;
        right: 10px;
        left: 10px;
        display: flex;
        justify-content: flex-end;
    }

    /* On mobile, default to collapsed state so it doesn't block game controls */
    .ff-hud-inner {
        /* Add a little zoom out to make it smaller on mobile */
        transform-origin: bottom right;
        transform: scale(0.9);
    }
}

/* === MODALS (SHOP, INFO, CONFIRM) === */
#ff-modals-wrapper {
    position: fixed;
    z-index: 999999;
}

.ff-modal-base {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999999;
}

.ff-modal-base.hidden {
    display: none !important;
}

.ff-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.ff-modal-content {
    position: relative;
    background: rgba(15, 23, 42, 0.95);
    border: 2px solid #fbbf24;
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    width: 90%;
    max-width: 500px;
    color: #fff;
    font-family: system-ui, sans-serif;
    max-height: 90vh;
    overflow-y: auto;
}

.ff-modal-content::-webkit-scrollbar {
    width: 0;
}

.ff-shop-content {
    max-width: 800px;
    padding: 30px 40px;
}

.ff-confirm-content {
    max-width: 400px;
    text-align: center;
}

.ff-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.ff-modal-header h2 {
    color: #fbbf24;
    margin: 0;
    font-size: 28px;
    font-weight: 900;
}

.ff-modal-close {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    font-size: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.ff-modal-close:hover {
    background: rgba(255,255,255,0.2);
}

.ff-modal-body ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ff-modal-body li {
    margin-bottom: 12px;
    font-size: 16px;
    line-height: 1.5;
}

/* === COIN SHOP GRID === */
.ff-shop-balance {
    font-size: 20px;
    font-weight: bold;
    color: #fbbf24;
    margin-bottom: 20px;
    text-align: center;
    background: rgba(251, 191, 36, 0.1);
    padding: 15px;
    border-radius: 12px;
}

.ff-shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.ff-shop-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s;
}

.ff-shop-item:hover {
    transform: translateY(-5px);
    border-color: rgba(251, 191, 36, 0.8);
}

.ff-shop-item h4 {
    margin: 0 0 10px 0;
    color: #fff;
    font-size: 18px;
}

.ff-shop-item p {
    font-size: 14px;
    color: #cbd5e1;
    margin: 0 0 20px 0;
    line-height: 1.4;
    flex-grow: 1;
}

.ff-buy-btn {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #000;
    border: none;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 900;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(245,158,11,0.4);
    transition: transform 0.2s, opacity 0.2s;
}

.ff-buy-btn:not(:disabled):hover {
    transform: scale(1.05);
}

.ff-buy-btn:disabled {
    cursor: not-allowed;
    background: #475569;
    box-shadow: none;
    color: #94a3b8;
}

/* === CONFIRM MODAL === */
.ff-confirm-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 25px;
}

.ff-confirm-actions button {
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.ff-confirm-actions button:hover {
    transform: scale(1.02);
}

#ff-confirm-btn-item {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

#ff-confirm-btn-coin {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: black;
}

#ff-confirm-btn-cancel {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* === GOLDEN THEME === */
.golden-theme .ff-hud-inner {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.95), rgba(217, 119, 6, 0.95));
    border: 2px solid #fff;
    box-shadow: 0 10px 40px rgba(245, 158, 11, 0.8);
}

.golden-theme .ff-hud-inner * {
    color: #fff !important;
}

.golden-theme .ff-pill {
    background: rgba(0,0,0,0.2) !important;
    border-color: rgba(255,255,255,0.4) !important;
}

.golden-theme button {
    background: rgba(0,0,0,0.2) !important;
}

.golden-theme button:hover {
    background: rgba(0,0,0,0.4) !important;
}

/* === MODALS (SHOP, INFO, CONFIRM) === */
#ff-modals-wrapper {
    position: fixed;
    z-index: 999999;
}

.ff-modal-base {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999999;
}

.ff-modal-base.hidden {
    display: none !important;
}

.ff-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.ff-modal-content {
    position: relative;
    background: rgba(15, 23, 42, 0.95);
    border: 2px solid #fbbf24;
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    width: 90%;
    max-width: 500px;
    color: #fff;
    font-family: system-ui, sans-serif;
    max-height: 90vh;
    overflow-y: auto;
}

.ff-modal-content::-webkit-scrollbar {
    width: 0;
}

.ff-shop-content {
    max-width: 800px;
    padding: 30px 40px;
}

.ff-confirm-content {
    max-width: 400px;
    text-align: center;
}

.ff-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.ff-modal-header h2 {
    color: #fbbf24;
    margin: 0;
    font-size: 28px;
    font-weight: 900;
}

.ff-modal-close {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    font-size: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.ff-modal-close:hover {
    background: rgba(255,255,255,0.2);
}

.ff-modal-body ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ff-modal-body li {
    margin-bottom: 12px;
    font-size: 16px;
    line-height: 1.5;
}

/* === COIN SHOP GRID === */
.ff-shop-balance {
    font-size: 20px;
    font-weight: bold;
    color: #fbbf24;
    margin-bottom: 20px;
    text-align: center;
    background: rgba(251, 191, 36, 0.1);
    padding: 15px;
    border-radius: 12px;
}

.ff-shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.ff-shop-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s;
}

.ff-shop-item:hover {
    transform: translateY(-5px);
    border-color: rgba(251, 191, 36, 0.8);
}

.ff-shop-item h4 {
    margin: 0 0 10px 0;
    color: #fff;
    font-size: 18px;
}

.ff-shop-item p {
    font-size: 14px;
    color: #cbd5e1;
    margin: 0 0 20px 0;
    line-height: 1.4;
    flex-grow: 1;
}

.ff-buy-btn {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #000;
    border: none;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 900;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(245,158,11,0.4);
    transition: transform 0.2s, opacity 0.2s;
}

.ff-buy-btn:not(:disabled):hover {
    transform: scale(1.05);
}

.ff-buy-btn:disabled {
    cursor: not-allowed;
    background: #475569;
    box-shadow: none;
    color: #94a3b8;
}

/* === CONFIRM MODAL === */
.ff-confirm-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 25px;
}

.ff-confirm-actions button {
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.ff-confirm-actions button:hover {
    transform: scale(1.02);
}

#ff-confirm-btn-item {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

#ff-confirm-btn-coin {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: black;
}

#ff-confirm-btn-cancel {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* === GOLDEN THEME === */
.golden-theme .ff-hud-inner {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.95), rgba(217, 119, 6, 0.95));
    border: 2px solid #fff;
    box-shadow: 0 10px 40px rgba(245, 158, 11, 0.8);
}

.golden-theme .ff-hud-inner * {
    color: #fff !important;
}

.golden-theme .ff-pill {
    background: rgba(0,0,0,0.2) !important;
    border-color: rgba(255,255,255,0.4) !important;
}

.golden-theme button {
    background: rgba(0,0,0,0.2) !important;
}

.golden-theme button:hover {
    background: rgba(0,0,0,0.4) !important;
}
