/* CSS Variables for consistent theming */
:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --secondary: #7209b7;
    --accent: #f72585;
    --light: #f8f9fa;
    --dark: #212529;
    --gray: #6c757d;
    --success: #4cc9f0;
    --warning: #ffd166;
    --danger: #ef476f;
    
    --border-radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
    
    /* Font stack with system fonts */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, 
                  "Helvetica Neue", Arial, "Noto Sans", sans-serif, 
                  "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", 
                  "Noto Color Emoji";
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

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

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--dark);
    background-color: #f0f2f5;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.8) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(200, 200, 255, 0.3) 0%, transparent 20%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism effect for modern UI */
.glass {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow);
}

/* Header and Navigation */
header {
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    transform: translateY(0);
    height: 60px;
}

header.hidden {
    transform: translateY(-100%);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    text-decoration: none;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background-color: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 1.2rem;
}

nav a {
    color: var(--dark);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    font-size: 0.95rem;
}

nav a:hover {
    color: var(--primary);
}

.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 1.8rem;
    height: 1.8rem;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}

.hamburger span {
    width: 1.8rem;
    height: 0.2rem;
    background: var(--dark);
    border-radius: 10px;
    transition: var(--transition);
    transform-origin: 1px;
}

/* Main content */
main {
    flex: 1;
    padding: 0.5rem 1rem;
    max-width: 1200px;
    margin: 60px auto 0;
    width: 100%;
}

.game-container {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0.8rem 0;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
}

h1 {
    color: var(--primary);
    font-size: 1.7rem;
    margin: 0;
    line-height: 1.2;
}

.game-actions {
    display: flex;
    gap: 0.5rem;
}

button {
    padding: 0.5rem 0.8rem;
    border: none;
    border-radius: var(--border-radius);
    background: var(--primary);
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
}

button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

button.secondary {
    background: var(--light);
    color: var(--dark);
}

button.secondary:hover {
    background: #e9ecef;
}

/* Responsive game container - will be adjusted by JS based on screen size */
.game-iframe-container {
    position: relative;
    /* width: 100%; */ /* Let JS handle width */
    overflow: hidden;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    margin: 0 auto; /* Center the container */
}

.game-iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: var(--border-radius);
    display: block;
}

.game-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #555;
    color: white;
    border-radius: var(--border-radius);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 0.8rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.game-fallback {
    display: none;
    text-align: center;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    margin-top: 0.8rem;
}

/* Related games section */
.section-title {
    font-size: 1.4rem;
    margin-bottom: 0.8rem;
    color: var(--dark);
    position: relative;
    padding-bottom: 0.4rem;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--primary);
    border-radius: 3px;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.game-card {
    aspect-ratio: 1/1;
    border-radius: var(--border-radius);
    overflow: hidden;
    position: relative;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.game-card a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.game-card-img {
    width: 100%;
    height: 100%;
    background-color: var(--gray);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.game-card-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 0.5rem;
}

.game-card-title h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
}

/* Game info article */
article {
    padding: 1.2rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

article h2 {
    margin: 1.2rem 0 0.8rem;
    color: var(--primary);
    font-size: 1.3rem;
}

article h2:first-child {
    margin-top: 0;
}

article h3 {
    margin: 1rem 0 0.6rem;
    color: var(--secondary);
    font-size: 1.1rem;
}

article p {
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
}

article ul, article ol {
    margin-bottom: 0.8rem;
    padding-left: 1.2rem;
}

article li {
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
}

.media-container {
    margin: 1.2rem 0;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.media-container img {
    width: 100%;
    height: auto;
    display: block;
}

/* FAQ section */
.faq-item {
    margin-bottom: 0.8rem;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.faq-item summary {
    padding: 0.8rem;
    background: var(--light);
    cursor: pointer;
    font-weight: 500;
    list-style: none;
    position: relative;
    font-size: 0.95rem;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    position: absolute;
    right: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
}

.faq-item[open] summary::after {
    content: '-';
}

.faq-item div {
    padding: 0.8rem;
    background: white;
    border-top: 1px solid #e9ecef;
    font-size: 0.95rem;
}

/* Comments section */
.comments-container {
    margin-bottom: 1.5rem;
}

.comment {
    padding: 0.8rem;
    margin-bottom: 0.8rem;
    border-radius: var(--border-radius);
    background: white;
    box-shadow: var(--shadow);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.comment-author {
    font-weight: 500;
    color: var(--primary);
    font-size: 0.95rem;
}

.comment-date {
    color: var(--gray);
    font-size: 0.8rem;
}

.comment-rating {
    color: var(--warning);
    margin-bottom: 0.4rem;
}

.comment-form {
    padding: 1.2rem;
    margin-top: 1.5rem;
}

.form-group {
    margin-bottom: 0.8rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.95rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #ced4da;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.95rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.rating-stars {
    display: flex;
    gap: 0.4rem;
}

.rating-stars input {
    display: none;
}

.rating-stars label {
    cursor: pointer;
    font-size: 1.3rem;
    color: #ddd;
    transition: var(--transition);
}

.rating-stars input:checked ~ label {
    color: #ddd;
}

.rating-stars label:hover,
.rating-stars label:hover ~ label,
.rating-stars input:checked + label,
.rating-stars input:checked ~ label:hover,
.rating-stars input:checked ~ label:hover ~ label {
    color: var(--warning);
}

.hp-field {
    opacity: 0;
    position: absolute;
    left: -9999px;
}

.form-status {
    padding: 0.6rem;
    border-radius: var(--border-radius);
    margin-bottom: 0.8rem;
    display: none;
    font-size: 0.95rem;
}

.form-status.success {
    background: rgba(76, 201, 240, 0.2);
    border: 1px solid var(--success);
    color: var(--success);
    display: block;
}

.form-status.error {
    background: rgba(239, 71, 111, 0.2);
    border: 1px solid var(--danger);
    color: var(--danger);
    display: block;
}

/* Footer */
footer {
    background: var(--dark);
    color: white;
    padding: 1.5rem 1rem;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.2rem;
    margin: 0.8rem 0;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: var(--transition);
    font-size: 0.9rem;
}

.footer-links a:hover {
    color: white;
}

.copyright {
    margin-top: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
}

/* Consent modal */
.consent-modal {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    padding: 1.2rem;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    max-width: 500px;
    margin: 0 auto;
    display: none;
}

.consent-modal p {
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
}

.consent-buttons {
    display: flex;
    gap: 0.8rem;
}

/* Responsive styles */
@media (max-width: 768px) {
    nav ul {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        background: white;
        padding: 0.8rem;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    }
    
    nav ul.active {
        display: flex;
    }
    
    .hamburger {
        display: flex;
    }
    
    .hamburger.active span:nth-child(1) {
        transform: rotate(45deg);
    }
    
    .hamburger.active span:nth-child(2) {
        opacity: 0;
    }
    
    .hamburger.active span:nth-child(3) {
        transform: rotate(-45deg);
    }
    
    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .game-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
    }
    
    .game-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .consent-buttons {
        flex-direction: column;
    }
    
    main {
        margin-top: 60px;
        padding: 0;
    }
    
    .game-container {
        margin-bottom: 1rem;
    }
    
    .game-header {
        padding: 0 1rem;
        margin: 0.8rem 0;
    }
    
    header {
        padding: 0.5rem 1rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    button {
        padding: 0.4rem 0.7rem;
        font-size: 0.85rem;
    }
    
    /* 修复导航按钮位置 */
    header {
        justify-content: space-between;
    }
    
    nav {
        order: 3;
    }
    
    .hamburger {
        order: 2;
        margin-left: auto;
    }
    
    /* 游戏容器全宽 */
    .game-iframe-container {
        border-radius: 0;
        margin: 0;
        /* width: 100vw !important; */ /* Let JS handle width */
        max-width: 100vw;
    }
    
    .game-iframe-container iframe {
        border-radius: 0;
    }
    
    /* 修复刷新按钮背景色 */
    button.secondary {
        background: #e9ecef;
        color: var(--dark);
        border: 1px solid #ced4da;
    }
    
    button.secondary:hover {
        background: #dee2e6;
    }
    
    /* 其他内容区域的移动端间距 */
    .related-games,
    article,
    .comments-container {
        padding: 0 1rem;
    }
}

@media (min-width: 769px) {
    main {
        padding: 1rem 1.5rem;
    }
    
    header {
        padding: 0.75rem 1.5rem;
    }
}

/* Ensure everything fits on screen */
@media (max-height: 700px) {
    .game-header {
        margin: 0.5rem 0;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .section-title {
        font-size: 1.3rem;
        margin-bottom: 0.6rem;
    }
} 

/* Fullscreen centering for the game container */
.game-iframe-container:fullscreen,
.game-iframe-container:-webkit-full-screen,
.game-iframe-container:-ms-fullscreen {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
}

.game-iframe-container:fullscreen iframe,
.game-iframe-container:-webkit-full-screen iframe,
.game-iframe-container:-ms-fullscreen iframe {
    margin: 0 auto;
    max-width: 100vw;
    max-height: 100vh;
}