/* ============================================
   PlayBoxBase - Mobile-First Game Website
   ============================================ */

:root {
    --bg: #0f0f1a;
    --surface: #1a1a2e;
    --surface-light: #222240;
    --text: #e8e8f0;
    --text-muted: #8888a0;
    --accent: #ff4757;
    --accent-hover: #e03345;
    --border: #2a2a40;
    --phone-width: 430px;
    --radius: 12px;
    --radius-sm: 8px;
    --safe-bottom: env(safe-area-inset-bottom, 16px);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #0a0a14;
    color: var(--text);
    line-height: 1.5;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

/* Phone frame on desktop */
.app-shell {
    width: 100%;
    max-width: var(--phone-width);
    min-height: 100vh;
    background: var(--bg);
    position: relative;
    overflow-x: hidden;
}

/* On desktop: subtle shadow around phone frame */
@media (min-width: 431px) {
    .app-shell {
        margin: 0 auto;
        box-shadow: 0 0 60px rgba(0,0,0,0.5), 0 0 0 1px var(--border);
        min-height: 100vh;
    }
    body {
        padding: 0;
    }
}

/* ============================================
   Header
   ============================================ */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(12px);
}
.app-header .logo {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}
.app-header .logo span {
    color: var(--accent);
}
.app-header .header-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

/* ============================================
   Genre Navigation (horizontal scroll)
   ============================================ */
.genre-nav {
    position: sticky;
    top: 56px;
    z-index: 99;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.genre-nav::-webkit-scrollbar { display: none; }
.genre-nav-inner {
    display: flex;
    gap: 8px;
    padding: 0 16px;
    white-space: nowrap;
}
.genre-chip {
    display: inline-flex;
    align-items: center;
    padding: 7px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: var(--surface);
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border);
    transition: all 0.2s;
    flex-shrink: 0;
}
.genre-chip.active,
.genre-chip:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.genre-chip .count {
    font-size: 11px;
    margin-left: 4px;
    opacity: 0.7;
}

/* ============================================
   Game Card List
   ============================================ */
.game-list {
    padding: 12px 16px calc(24px + var(--safe-bottom));
}

.game-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
}
.game-card:active {
    transform: scale(0.985);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.game-card-thumb {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--surface-light);
    flex-shrink: 0;
}
.game-card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.game-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.game-card-company {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.game-card-genres {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.game-card-genre {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255,71,87,0.12);
    color: var(--accent);
    font-weight: 500;
}

/* ============================================
   Ad Placement
   ============================================ */
.ad-placeholder,
.ad-placement {
    background: #2a2a35;
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}
.ad-placement {
    width: 100%;
    max-width: 600px;
    height: 400px;
    margin-left: auto;
    margin-right: auto;
}
.ad-placement iframe,
.ad-placement > div {
    width: 100% !important;
    height: 100% !important;
}
.ad-placeholder {
    border: 1px dashed #3a3a48;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.ad-placeholder::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.02) 50%, transparent 60%);
    animation: adShimmer 2s infinite;
}
@keyframes adShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.ad-list-inline {
    width: 100%;
    height: 400px;
    margin-bottom: 16px;
}
.ad-detail-top {
    width: 100%;
    height: 400px;
    margin-bottom: 16px;
}
.ad-detail-bottom {
    width: 100%;
    height: 400px;
    margin-top: 16px;
    margin-bottom: 16px;
}

/* ============================================
   Fullscreen Ad (Play Page)
   ============================================ */
.fullscreen-ad {
    position: fixed;
    inset: 0;
    background: #1a1a2e;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: var(--phone-width);
    margin: 0 auto;
}
.fullscreen-ad .ad-inner {
    width: calc(100% - 32px);
    height: 70%;
    background: #2a2a35;
    border: 1px dashed #3a3a48;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}
.fullscreen-ad .ad-label {
    color: #555;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.fullscreen-ad .countdown {
    color: #fff;
    font-size: 48px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.fullscreen-ad .skip-hint {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 8px;
}
.fullscreen-ad .skip-btn {
    margin-top: 12px;
    padding: 8px 24px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.2);
    background: transparent;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}
.fullscreen-ad .skip-btn:hover {
    background: rgba(255,255,255,0.08);
}

/* ============================================
   Game Play Page
   ============================================ */
.play-page {
    position: fixed;
    inset: 0;
    background: #000;
    max-width: var(--phone-width);
    margin: 0 auto;
}
.play-page iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Back button */
.back-btn {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 500;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    font-size: 20px;
    font-weight: 300;
    transition: all 0.2s;
    line-height: 1;
}
.back-btn:hover {
    background: rgba(0,0,0,0.8);
}
/* Arrow SVG instead of emoji */
.back-btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: #fff;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ============================================
   Detail Page
   ============================================ */
.detail-header-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.detail-thumb {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--surface-light);
    flex-shrink: 0;
}
.detail-header-info {
    flex: 1;
    min-width: 0;
}
.detail-header-info .detail-title {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}
.detail-header-info .detail-company {
    font-size: 12px;
    color: var(--text-muted);
}
.detail-body {
    padding: 16px 16px calc(40px + var(--safe-bottom));
}
.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.detail-meta-item {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 14px;
    background: var(--surface-light);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.detail-section {
    margin-bottom: 20px;
}
.detail-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
}
.detail-section p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.7;
}
.detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.btn-play {
    flex: 1;
    padding: 14px 24px;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-play:hover { background: var(--accent-hover); }
.btn-play svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ============================================
   Related Games
   ============================================ */
.related-games {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.related-card {
    text-decoration: none;
    color: inherit;
}
.related-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--surface-light);
}
.related-card .name {
    font-size: 12px;
    color: #fff;
    margin-top: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

/* ============================================
   Loading & Empty States
   ============================================ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 14px;
}
.loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}
.empty-state p {
    font-size: 14px;
}

.load-more {
    text-align: center;
    padding: 8px 0 24px;
}
.load-more button {
    padding: 10px 32px;
    border-radius: 20px;
    background: var(--surface);
    color: #fff;
    border: 1px solid var(--border);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}
.load-more button:hover { background: var(--surface-light); }
.load-more button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================
   Pull-to-refresh indicator
   ============================================ */
.pull-indicator {
    text-align: center;
    padding: 12px;
    color: var(--text-muted);
    font-size: 12px;
    display: none;
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
