/* =========================================
   GLOBAL RESET
========================================= */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: Poppins, sans-serif; }
html, body { height: 100%; }
body {
    background: var(--bg, #F8E56A); /* default pastel yellow */
    transition: background 0.35s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Utility */
.hidden { display: none !important; }

/* =========================================
   SCREENS
========================================= */
.screen {
    width: 100%;
    min-height: 100vh;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 28px;
}
.screen.active { display: flex; }

/* =========================================
   HOME COIN CHIP (top-left)
========================================= */
.home-coin-chip {
    position: fixed;
    top: 18px;
    left: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 14px;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
    z-index: 50;
    font-weight: 700;
}
.home-coin-chip img { width: 20px; height: 20px; }
#homeCoinCount { font-weight: 800; color: #111; }

/* =========================================
   CARD (main centered box) - frosted white larger
========================================= */
.card {
    width: 500px; /* larger desktop width */
    max-width: 96%;
    background: rgba(255,255,255,0.90); /* frosted-white */
    border-radius: 18px;
    padding: 26px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.12);
    backdrop-filter: blur(6px) saturate(1.05);
    position: relative;
    overflow: visible;
}

/* Slightly larger menu card */
.menu-card { padding: 44px 36px; text-align: center; }

/* Title */
.game-title {
    font-size: 38px;
    font-weight: 900;
    color: #1E1E1E;
    margin-bottom: 18px;
    line-height: 1.02;
}

/* =========================================
   BUTTON STYLES (premium dark gradient)
========================================= */
.btn {
    width: 100%;
    padding: 14px 0;
    margin: 10px 0;
    border: none;
    border-radius: 12px;
    background: linear-gradient(180deg,#2f2f2f, #1f1f1f);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease, opacity .12s;
    box-shadow: 0 6px 16px rgba(16,24,32,0.18);
}
.btn:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(16,24,32,0.22); opacity: 0.98; }
.home-btn { margin-top: 12px; }

/* small button variant (top-controls) */
.small-btn {
    width: 100px;
    font-size: 14px;
    padding: 8px 0;
}

/* Back button */
.back-btn {
    position: absolute;
    top: 16px;
    left: 16px;
    padding: 8px 12px;
    border-radius: 10px;
    background: #1E1E1E;
    color: #fff;
    border: none;
    font-size: 14px;
    cursor: pointer;
}

/* =========================================
   GAME CARD TOP
========================================= */
.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 12px;
}

/* Coins inside card */
.coin-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.7);
    padding: 8px 12px;
    border-radius: 12px;
    font-weight: 800;
    box-shadow: 0 3px 10px rgba(0,0,0,0.06);
}
.coin-icon { width: 22px; height: 22px; }

/* Turn indicator centered */
.turn-wrap {
    flex: 1;
    text-align: center;
}
#turnText {
    font-weight: 900;
    font-size: 20px;
    color: #1E1E1E;
    display: inline-block;
    padding: 8px 14px;
    border-radius: 14px;
    background: rgba(255,255,255,0.72);
}

/* Top controls (pause/home) */
.top-controls {
    display: flex;
    gap: 10px;
}

/* Hint */
.hint {
    text-align: center;
    color: #444;
    font-weight: 700;
    margin-top: 12px;
}

/* =========================================
   BOARD WRAP & BOARD (larger)
========================================= */
.board-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 0 6px 0;
}

.board {
    width: 380px;
    height: 380px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 1fr;
    gap: 14px;
    align-items: stretch;
    justify-items: stretch;
}

/* Each cell fixed size and never shrinks */
.cell {
    background: rgba(255,255,255,0.98);
    border-radius: 18px;
    font-size: 72px;
    font-weight: 900;
    color: #111;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: transform 0.18s ease, background 0.12s;
    box-shadow: 0 8px 26px rgba(0,0,0,0.06) inset;
}

/* Prevent content from forcing size changes */
.cell, .cell * { min-width: 0; min-height: 0; }

/* Hover */
.cell:hover { transform: translateY(-4px); background: #ffffff; }

/* Pop animation for X/O placed */
.pop {
    transform: scale(1.02);
    animation: popAnim 0.28s ease;
}
@keyframes popAnim {
    0% { transform: scale(0.6); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* =========================================
   POPUPS
========================================= */
.popup {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100vh;
    background: #00000070;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 60;
}
.popup-box {
    background: #fff;
    width: 360px;
    padding: 22px;
    border-radius: 14px;
    text-align: center;
    box-shadow: 0 6px 28px rgba(0,0,0,0.18);
}

/* THEME STORE */
.theme-grid {
    margin-top: 12px;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-gap: 16px;
    padding-bottom: 10px;
}
.theme-card {
    background: rgba(255,255,255,0.9);
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 8px 22px rgba(0,0,0,0.06);
    text-align: center;
}
.theme-preview {
    width: 100%;
    height: 100px; /* larger preview */
    border-radius: 12px;
    margin-bottom: 10px;
    box-shadow: inset 0 -6px 18px rgba(0,0,0,0.03);
}
.theme-name {
    font-size: 15px;
    font-weight: 800;
    color: #1E1E1E;
    margin-bottom: 8px;
}
.theme-btn {
    padding: 10px 6px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 800;
}

/* Responsive tweaks */
@media (max-width: 640px) {
    .card { width: 92%; padding: 18px; border-radius: 14px; }
    .board { width: 86vw; max-width: 380px; height: 86vw; max-height: 380px; gap: 10px; }
    .cell { font-size: 11.5vw; }
    .game-title { font-size: 28px; }
    .btn { font-size: 16px; padding: 12px 0; }
    .home-coin-chip { top: 12px; left: 12px; padding: 6px 10px; }
    .theme-preview { height: 84px; }
}
