/* =========================================================
   GameHub – Global Styles  (dark-first design)
   ========================================================= */

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

:root {
    --primary:      #e94560;
    --primary-dark: #c73550;
    --secondary:    #16213e;
    --accent:       #08d9d6;
    --accent2:      #f5a623;
    --dark:         #0f0f1a;
    --light:        #1a1a2e;
    --light2:       #242450;
    --text:         #eef0f8;
    --text-muted:   #8892aa;
    --success:      #53ebb1;
    --error:        #ff6b6b;
    --warning:      #ffd166;
    --gold:         #ffd700;
    --border:       rgba(255,255,255,.08);
    --radius:       12px;
    --shadow:       0 4px 24px rgba(0,0,0,.4);
    --glow:         0 0 20px rgba(233,69,96,.35);
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--dark);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ── Typography ──────────────────────────────────────────── */
h1, h2, h3, h4 { line-height: 1.2; }
a { color: inherit; text-decoration: none; }

/* ── Layout ──────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.container-sm { max-width: 800px; margin: 0 auto; padding: 0 20px; }

/* ── Navbar ──────────────────────────────────────────────── */
.nav {
    background: rgba(22,33,62,.95);
    backdrop-filter: blur(12px);
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 200;
}
.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}
.nav-brand {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -.5px;
}
.nav-links { display: flex; gap: 6px; align-items: center; }
.nav-links a {
    color: var(--text-muted);
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all .2s;
}
.nav-links a:hover, .nav-links a.active {
    color: var(--text);
    background: rgba(255,255,255,.07);
}
.nav-links a.admin-link {
    color: var(--accent2);
    border: 1px solid rgba(245,166,35,.3);
}
.balance-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,215,0,.1);
    border: 1px solid rgba(255,215,0,.25);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
}
.balance-display .coin-icon { font-size: 18px; }
.balance-display span { color: var(--gold); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 12px rgba(233,69,96,.4);
}
.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(233,69,96,.5);
}
.btn-accent {
    background: var(--accent);
    color: var(--dark);
}
.btn-accent:hover { background: #06c8c5; transform: translateY(-1px); }
.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,.07); }
.btn-warning { background: var(--warning); color: var(--dark); }
.btn-warning:hover { background: #f5c842; }
.btn-success { background: var(--success); color: var(--dark); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 14px 30px; font-size: 17px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
}
.card-sm { padding: 18px; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    margin-bottom: 7px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--dark);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 8px;
    color: var(--text);
    font-size: 15px;
    transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(233,69,96,.2);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }
.form-error { color: var(--error); font-size: 12px; margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Auth pages ──────────────────────────────────────────── */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 0%, rgba(233,69,96,.15) 0%, transparent 70%),
                var(--dark);
    padding: 40px 20px;
}
.auth-card { width: 100%; max-width: 420px; }
.auth-logo {
    text-align: center;
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}
.auth-card h1 {
    text-align: center;
    color: var(--text);
    margin-bottom: 8px;
    font-size: 24px;
}
.auth-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 14px;
}
.auth-footer { text-align: center; margin-top: 20px; color: var(--text-muted); font-size: 14px; }
.auth-footer a { color: var(--primary); font-weight: 600; }
.auth-footer a:hover { text-decoration: underline; }
.btn-full { width: 100%; }

/* ── Dashboard grid ──────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    transition: transform .2s, border-color .2s;
}
.stat-card:hover { transform: translateY(-3px); border-color: var(--primary); }
.stat-card .stat-icon { font-size: 32px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}
.game-card {
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform .25s, border-color .25s, box-shadow .25s;
}
.game-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: var(--glow);
}
.game-card-image {
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    position: relative;
}
.game-card-image.scratch-bg { background: linear-gradient(135deg, var(--accent), #0087ff); }
.game-card-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,.5);
    color: var(--gold);
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 30px;
    backdrop-filter: blur(4px);
}
.game-card-content { padding: 20px; }
.game-card-content h3 { font-size: 18px; margin-bottom: 6px; }
.game-card-content p { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; line-height: 1.5; }

/* ── Transactions ────────────────────────────────────────── */
.transactions-list { max-height: 420px; overflow-y: auto; }
.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}
.transaction-item:last-child { border-bottom: none; }
.transaction-item:hover { background: rgba(255,255,255,.03); }
.transaction-icon { font-size: 20px; margin-right: 12px; }
.transaction-desc { font-size: 14px; }
.transaction-sub  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.transaction-amount { font-weight: 700; font-size: 16px; }
.transaction-amount.positive { color: var(--success); }
.transaction-amount.negative { color: var(--error); }

/* ── Gift Shop ───────────────────────────────────────────── */
.gifts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}
.gift-card {
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .2s, border-color .2s;
}
.gift-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.gift-card-img {
    height: 130px;
    background: linear-gradient(135deg, var(--light2), var(--light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
}
.gift-card-body { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.gift-card-name { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.gift-card-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; flex: 1; }
.gift-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.gift-cost {
    font-size: 15px;
    font-weight: 800;
    color: var(--gold);
    display: flex;
    align-items: center;
    gap: 5px;
}
.gift-stock { font-size: 12px; color: var(--text-muted); text-align: right; }
.gift-out   { opacity: .5; }

/* ── Loading & Toast ─────────────────────────────────────── */
.loading {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,15,26,.85);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.loading.active { display: flex; }
.spinner {
    width: 48px; height: 48px;
    border: 4px solid rgba(255,255,255,.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
    position: fixed;
    bottom: 24px; right: 24px;
    padding: 14px 22px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    z-index: 1001;
    animation: toastIn .35s ease;
    max-width: 320px;
    box-shadow: var(--shadow);
}
.toast.success { background: var(--success); color: var(--dark); }
.toast.error   { background: var(--error);   color: #fff; }
.toast.warning { background: var(--warning); color: var(--dark); }
.toast.info    { background: var(--accent);  color: var(--dark); }
@keyframes toastIn {
    from { transform: translateX(110%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,15,26,.85);
    backdrop-filter: blur(6px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 500;
    padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px;
    width: 100%;
    max-width: 460px;
    animation: modalIn .3s ease;
}
@keyframes modalIn {
    from { transform: scale(.92); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
.modal-box h2 { margin-bottom: 20px; font-size: 22px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ── Admin tables ────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}
.admin-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}
.admin-table tr:hover td { background: rgba(255,255,255,.03); }
.admin-table tr:last-child td { border-bottom: none; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 600;
}
.badge-success { background: rgba(83,235,177,.15); color: var(--success); }
.badge-error   { background: rgba(255,107,107,.15); color: var(--error); }
.badge-warning { background: rgba(255,209,102,.15); color: var(--warning); }
.badge-info    { background: rgba(8,217,214,.15);   color: var(--accent); }
.badge-gold    { background: rgba(255,215,0,.15);   color: var(--gold); }

/* ── Admin layout ────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 240px;
    background: var(--secondary);
    border-right: 1px solid var(--border);
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.admin-sidebar .logo {
    padding: 0 20px 24px;
    font-size: 18px;
    font-weight: 800;
    border-bottom: 1px solid var(--border);
}
.admin-sidebar nav { flex: 1; padding: 16px 0; }
.admin-sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    border-left: 3px solid transparent;
}
.admin-sidebar .nav-item:hover { color: var(--text); background: rgba(255,255,255,.04); }
.admin-sidebar .nav-item.active { color: var(--primary); background: rgba(233,69,96,.08); border-left-color: var(--primary); }
.admin-main { flex: 1; overflow-y: auto; }
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(22,33,62,.5);
}
.admin-header h1 { font-size: 20px; font-weight: 700; }
.admin-content { padding: 24px 28px; }

/* ── Section tabs (admin) ────────────────────────────────── */
.section { display: none; }
.section.active { display: block; }

/* ── Tetris & Scratch pages ──────────────────────────────── */
.game-container { display: flex; gap: 28px; justify-content: center; align-items: flex-start; padding: 28px 0; flex-wrap: wrap; }
#gameCanvas { border: 2px solid rgba(233,69,96,.5); border-radius: 6px; background: var(--dark); }
.game-sidebar { width: 180px; display: flex; flex-direction: column; gap: 16px; }
.game-panel { background: var(--secondary); border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.game-panel h3 { color: var(--primary); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.panel-value { font-size: 26px; font-weight: 800; }
#nextCanvas { border: 1px solid var(--border); border-radius: 4px; background: var(--dark); }
.game-controls { font-size: 12px; color: var(--text-muted); line-height: 2; }
.game-controls kbd { background: var(--light); padding: 2px 6px; border-radius: 3px; color: var(--text); }

/* ── Homepage / Landing ──────────────────────────────────── */
.hero {
    min-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 0%, rgba(233,69,96,.2) 0%, transparent 65%),
                radial-gradient(ellipse at 80% 80%, rgba(8,217,214,.12) 0%, transparent 55%),
                var(--dark);
    padding: 60px 20px;
}
.hero-content { position: relative; z-index: 2; max-width: 720px; }
.hero-badge {
    display: inline-block;
    background: rgba(233,69,96,.15);
    border: 1px solid rgba(233,69,96,.4);
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 30px;
    margin-bottom: 24px;
    letter-spacing: .5px;
}
.hero h1 {
    font-size: clamp(2.4rem, 6vw, 4rem);
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: 20px;
}
.hero h1 .gradient-text {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero p {
    font-size: 18px;
    color: var(--text-muted);
    margin-bottom: 36px;
    line-height: 1.7;
}
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.hero-particles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.particle {
    position: absolute;
    width: 4px; height: 4px;
    background: var(--primary);
    border-radius: 50%;
    animation: float var(--dur, 6s) ease-in-out infinite;
    opacity: .6;
}
@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0); opacity: .6; }
    50%       { transform: translateY(-60px) rotate(180deg); opacity: .2; }
}

.features-section { padding: 80px 0; }
.features-section .section-title {
    text-align: center;
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 12px;
}
.features-section .section-sub { text-align: center; color: var(--text-muted); margin-bottom: 48px; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; }
.feature-item {
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
    text-align: center;
    transition: transform .2s, border-color .2s;
}
.feature-item:hover { transform: translateY(-4px); border-color: var(--primary); }
.feature-icon { font-size: 40px; margin-bottom: 14px; }
.feature-item h3 { font-size: 17px; margin-bottom: 8px; }
.feature-item p { font-size: 14px; color: var(--text-muted); line-height: 1.6; }

.cta-section {
    padding: 80px 20px;
    text-align: center;
    background: linear-gradient(135deg, rgba(233,69,96,.1), rgba(8,217,214,.1));
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.cta-section h2 { font-size: 2rem; font-weight: 800; margin-bottom: 14px; }
.cta-section p  { color: var(--text-muted); margin-bottom: 30px; font-size: 16px; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--dark); }
::-webkit-scrollbar-thumb { background: var(--light2); border-radius: 3px; }

/* ── Utilities ───────────────────────────────────────────── */
.hidden { display: none !important; }
.text-primary { color: var(--primary); }
.text-accent  { color: var(--accent); }
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error   { color: var(--error); }
.text-gold    { color: var(--gold); }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; justify-content: center; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-full { width: 100%; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .nav-links { gap: 2px; }
    .nav-links a { padding: 6px 10px; font-size: 13px; }
    .balance-display { padding: 6px 12px; font-size: 13px; }
    .admin-layout { flex-direction: column; }
    .admin-sidebar { width: 100%; height: auto; position: relative; }
    .admin-sidebar nav { display: flex; overflow-x: auto; padding: 8px 0; }
    .admin-sidebar .nav-item { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
    .form-row { grid-template-columns: 1fr; }
}
