/* ===================================================
   Gem Miner — Mobile Clicker Game Styles
   Dark mining theme with gold/amber accents
   =================================================== */

/* ── CSS Reset & Variables ─────────────────────── */
:root {
    --bg-deep:       #0a0e17;
    --bg-surface:    #141b2d;
    --bg-card:       rgba(30, 41, 67, 0.85);
    --bg-glass:      rgba(255, 255, 255, 0.04);
    --gold:          #ffd700;
    --gold-light:    #ffed4a;
    --gold-dark:     #b8860b;
    --amber:         #ff9800;
    --gem-purple:    #a855f7;
    --gem-blue:      #3b82f6;
    --text:          #e8eaed;
    --text-dim:      #8892a4;
    --text-muted:    #5a6577;
    --danger:        #ef4444;
    --success:       #22c55e;
    --radius:        12px;
    --radius-sm:     8px;
    --radius-lg:     20px;
    --shadow:        0 8px 32px rgba(0,0,0,0.4);
    --transition:    0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font:          'Inter', 'Noto Sans KR', 'Noto Sans JP', -apple-system, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg-deep);
    color: var(--text);
    overflow: hidden;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* ── Google Fonts ──────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Noto+Sans+KR:wght@400;500;700&family=Noto+Sans+JP:wght@400;500;700&display=swap');

/* ── App Container ─────────────────────────────── */
#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

/* ── Screens ───────────────────────────────────── */
.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    position: absolute;
    inset: 0;
    overflow-y: auto;
    animation: fadeIn 0.3s ease;
}
.screen.active {
    display: flex;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Login Screen ──────────────────────────────── */
.login-screen {
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background:
        radial-gradient(circle at 30% 20%, rgba(255,215,0,0.08) 0%, transparent 50%),
        radial-gradient(circle at 70% 80%, rgba(168,85,247,0.06) 0%, transparent 50%),
        var(--bg-deep);
}

.login-logo {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    animation: float 3s ease-in-out infinite;
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-10px); }
}

.login-title {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--gold), var(--amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.login-form {
    width: 100%;
    max-width: 320px;
}

.input-group {
    position: relative;
    margin-bottom: 1rem;
}

.input-group input {
    width: 100%;
    padding: 1rem 1.2rem;
    background: var(--bg-card);
    border: 1px solid rgba(255,215,0,0.15);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.1rem;
    font-family: var(--font);
    outline: none;
    transition: border-color var(--transition);
}
.input-group input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(255,215,0,0.15);
}
.input-group input::placeholder {
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.9rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
}
.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: #1a1a2e;
    font-size: 1.1rem;
    padding: 1rem;
    box-shadow: 0 4px 20px rgba(255,215,0,0.3);
}
.btn-primary:hover {
    box-shadow: 0 6px 30px rgba(255,215,0,0.5);
}

.login-error {
    color: var(--danger);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 0.5rem;
    min-height: 1.2em;
}

/* ── Top Bar ───────────────────────────────────── */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    background: var(--bg-surface);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
    z-index: 10;
}

.top-bar .user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.top-bar .gem-display {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gold);
}

/* ── Stats Bar ─────────────────────────────────── */
.stats-bar {
    display: flex;
    justify-content: space-around;
    padding: 0.6rem 0.5rem;
    background: var(--bg-glass);
    border-bottom: 1px solid rgba(255,255,255,0.03);
    flex-shrink: 0;
}

.stat-item {
    text-align: center;
}
.stat-item .stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-item .stat-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}

/* ── Main Clicker Area ─────────────────────────── */
.clicker-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(ellipse at center, rgba(255,215,0,0.03) 0%, transparent 60%),
        var(--bg-deep);
}

.mine-btn {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 3px solid var(--gold-dark);
    background:
        radial-gradient(circle at 35% 35%, rgba(255,215,0,0.2), transparent 60%),
        var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    box-shadow:
        0 0 30px rgba(255,215,0,0.15),
        inset 0 -5px 15px rgba(0,0,0,0.3);
    z-index: 2;
}
.mine-btn:active {
    transform: scale(0.92);
    box-shadow:
        0 0 15px rgba(255,215,0,0.3),
        inset 0 2px 10px rgba(0,0,0,0.5);
}
.mine-btn.pulse {
    animation: pulse 0.15s ease-out;
}
@keyframes pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(0.93); }
    100% { transform: scale(1); }
}

/* ── Click Particles ───────────────────────────── */
.click-particle {
    position: absolute;
    pointer-events: none;
    z-index: 5;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--gold-light);
    text-shadow: 0 0 10px rgba(255,215,0,0.5);
    animation: particleFloat 0.8s ease-out forwards;
}
@keyframes particleFloat {
    0%   { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-80px) scale(0.5); }
}

/* ── DPS Counter ───────────────────────────────── */
.dps-display {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-dim);
}
.dps-display span {
    color: var(--gem-blue);
    font-weight: 700;
}

/* ── Boost Status ──────────────────────────────── */
.boost-active {
    margin-top: 0.5rem;
    padding: 0.3rem 0.8rem;
    background: linear-gradient(135deg, rgba(168,85,247,0.2), rgba(59,130,246,0.2));
    border: 1px solid var(--gem-purple);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--gem-purple);
    font-weight: 600;
    display: none;
}
.boost-active.show {
    display: inline-block;
    animation: glow 1.5s ease-in-out infinite alternate;
}
@keyframes glow {
    from { box-shadow: 0 0 5px rgba(168,85,247,0.3); }
    to   { box-shadow: 0 0 15px rgba(168,85,247,0.6); }
}

/* ── Bottom Navigation ─────────────────────────── */
.bottom-nav {
    display: flex;
    background: var(--bg-surface);
    border-top: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
    z-index: 10;
}
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.7rem 0;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--transition);
    border: none;
    background: transparent;
}
.nav-item .nav-icon {
    font-size: 1.3rem;
}
.nav-item.active {
    color: var(--gold);
}
.nav-item:active {
    opacity: 0.7;
}

/* ── Tab Content ───────────────────────────────── */
.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* ── Upgrade Shop ──────────────────────────────── */
.shop-header {
    padding: 1rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gold);
}

.upgrade-card {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin: 0 0.8rem 0.6rem;
    padding: 0.9rem;
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
    transition: all var(--transition);
}
.upgrade-card:active {
    transform: scale(0.98);
}
.upgrade-card.disabled {
    opacity: 0.5;
}

.upgrade-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--bg-surface), var(--bg-card));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.upgrade-info {
    flex: 1;
    min-width: 0;
}
.upgrade-name {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}
.upgrade-desc {
    font-size: 0.75rem;
    color: var(--text-dim);
}
.upgrade-level {
    font-size: 0.7rem;
    color: var(--gem-blue);
    font-weight: 600;
}

.upgrade-buy {
    padding: 0.5rem 0.8rem;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: #1a1a2e;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
    flex-shrink: 0;
}
.upgrade-buy:active {
    transform: scale(0.95);
}
.upgrade-buy:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

/* ── Boosts Section ────────────────────────────── */
.boost-card {
    background: linear-gradient(135deg, rgba(168,85,247,0.1), rgba(59,130,246,0.1));
    border-color: rgba(168,85,247,0.2);
}
.boost-card .upgrade-buy {
    background: linear-gradient(135deg, var(--gem-purple), var(--gem-blue));
    color: white;
}

/* ── Leaderboard ───────────────────────────────── */
.lb-header {
    padding: 1rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gold);
}

.lb-my-rank {
    margin: 0 0.8rem 0.8rem;
    padding: 0.8rem;
    background: linear-gradient(135deg, rgba(255,215,0,0.08), rgba(255,152,0,0.08));
    border: 1px solid rgba(255,215,0,0.2);
    border-radius: var(--radius);
    text-align: center;
}
.lb-my-rank .rank-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--gold);
}
.lb-my-rank .rank-label {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.lb-list {
    padding: 0 0.8rem;
}

.lb-entry {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.lb-entry.me {
    background: rgba(255,215,0,0.06);
    border-radius: var(--radius-sm);
}

.lb-rank {
    width: 2rem;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
}
.lb-rank.top1 { color: #ffd700; }
.lb-rank.top2 { color: #c0c0c0; }
.lb-rank.top3 { color: #cd7f32; }

.lb-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
}

.lb-score {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gold);
}

/* ── Profile ───────────────────────────────────── */
.profile-section {
    padding: 1.5rem;
}

.profile-card {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
}
.profile-avatar {
    font-size: 4rem;
    margin-bottom: 0.5rem;
}
.profile-name {
    font-size: 1.3rem;
    font-weight: 700;
}
.profile-joined {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 0.3rem;
}

.profile-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}
.profile-stat-card {
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    text-align: center;
}
.profile-stat-card .psc-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gold);
}
.profile-stat-card .psc-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 0.2rem;
}

.btn-logout {
    width: 100%;
    padding: 0.9rem;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: var(--radius);
    color: var(--danger);
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-logout:active {
    background: rgba(239,68,68,0.2);
}

/* ── Toast ─────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.toast {
    padding: 0.7rem 1.2rem;
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
    box-shadow: var(--shadow);
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }
.toast.info    { border-color: var(--gem-blue); color: var(--gem-blue); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ── Loading Spinner ───────────────────────────── */
.spinner {
    display: inline-block;
    width: 1.2rem;
    height: 1.2rem;
    border: 2px solid var(--text-muted);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Offline Banner ────────────────────────────── */
.offline-banner {
    display: none;
    padding: 1rem;
    text-align: center;
    background: linear-gradient(135deg, rgba(255,215,0,0.1), rgba(168,85,247,0.1));
    border-bottom: 1px solid rgba(255,215,0,0.2);
}
.offline-banner.show {
    display: block;
    animation: fadeIn 0.5s ease;
}
.offline-gems {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--gold);
}
.offline-label {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* ── Scrollbar ─────────────────────────────────── */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 2px;
}

/* ── Responsive Safety ─────────────────────────── */
@media (min-width: 481px) {
    #app {
        border-left: 1px solid rgba(255,255,255,0.05);
        border-right: 1px solid rgba(255,255,255,0.05);
    }
}

@media (max-height: 600px) {
    .mine-btn {
        width: 140px;
        height: 140px;
        font-size: 3.5rem;
    }
}
