/* ===== Material Design 3 (M3) CSS Variables ===== */
:root {
    /* M3 Primary Tonal Palette */
    --md-sys-color-primary: #94b8ff;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #e0ecff;
    --md-sys-color-on-primary-container: #1f3a5c;
    
    /* Link colors (higher contrast for accessibility) */
    --md-sys-color-link: #3b6eb3;
    --md-sys-color-link-hover: #1f4a8a;
    
    /* M3 Secondary */
    --md-sys-color-secondary: #7094d6;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #e0ecff;
    --md-sys-color-on-secondary-container: #051F1F;
    
    /* M3 Tertiary */
    --md-sys-color-tertiary: #4B607C;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #D3E4FF;
    --md-sys-color-on-tertiary-container: #041C35;
    
    /* M3 Error */
    --md-sys-color-error: #BA1A1A;
    --md-sys-color-on-error: #FFFFFF;
    --md-sys-color-error-container: #FFDAD6;
    --md-sys-color-on-error-container: #410002;
    
    /* M3 Surface */
    --md-sys-color-surface: #FAFDFC;
    --md-sys-color-on-surface: #191C1C;
    --md-sys-color-surface-variant: #DAE5E4;
    --md-sys-color-on-surface-variant: #3F4948;
    --md-sys-color-surface-container-lowest: #FFFFFF;
    --md-sys-color-surface-container-low: #F4F7F6;
    --md-sys-color-surface-container: #EEF1F0;
    --md-sys-color-surface-container-high: #E8EBEA;
    --md-sys-color-surface-container-highest: #E3E6E5;
    
    /* M3 Outline */
    --md-sys-color-outline: #6F7979;
    --md-sys-color-outline-variant: #BEC9C8;
    
    /* M3 Background */
    --md-sys-color-background: #FAFDFC;
    --md-sys-color-on-background: #191C1C;
    
    /* M3 Typography */
    --md-sys-typescale-display-large: 400 57px/64px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-display-medium: 400 45px/52px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-display-small: 400 36px/44px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-headline-large: 400 32px/40px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-headline-medium: 400 28px/36px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-headline-small: 400 24px/32px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-title-large: 400 22px/28px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-title-medium: 500 16px/24px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-title-small: 500 14px/20px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-body-large: 400 16px/24px 'Roboto', sans-serif;
    --md-sys-typescale-body-medium: 400 14px/20px 'Roboto', sans-serif;
    --md-sys-typescale-body-small: 400 12px/16px 'Roboto', sans-serif;
    --md-sys-typescale-label-large: 500 14px/20px 'Roboto', sans-serif;
    --md-sys-typescale-label-medium: 500 12px/16px 'Roboto', sans-serif;
    --md-sys-typescale-label-small: 500 11px/16px 'Roboto', sans-serif;
    
    /* M3 Shape */
    --md-sys-shape-corner-none: 0px;
    --md-sys-shape-corner-extra-small: 4px;
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-extra-large: 28px;
    --md-sys-shape-corner-full: 9999px;
    
    /* M3 Elevation */
    --md-sys-elevation-1: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-2: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-3: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px rgba(0, 0, 0, 0.3);
    
    /* Layout */
    --max-width: 1200px;
    --top-nav-height: 64px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font: var(--md-sys-typescale-body-large);
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--md-sys-color-link);
    text-decoration: none;
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
}

a:hover {
    color: var(--md-sys-color-link-hover);
}

/* ===== App Layout ===== */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Navigation Bar ===== */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-nav-height);
    background-color: var(--md-sys-color-surface);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 100;
    box-shadow: var(--md-sys-elevation-1);
}

.nav-bar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: 16px;
    flex-shrink: 0;
}

.nav-bar-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--md-sys-shape-corner-medium);
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
    overflow: hidden;
}

.nav-bar-logo:hover {
    background-color: #6688cc;
    transform: scale(1.05);
}

.nav-bar-logo:hover .nav-logo-img {
    filter: brightness(0) invert(1);
}

.nav-logo-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.nav-bar-title-group {
  display: flex;
  flex-direction: column;
}

.nav-bar-title {
  font-family: 'Calistoga', serif;
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.5rem;
  color: var(--md-sys-color-on-surface);
  display: block;
  white-space: nowrap;
}

.nav-bar-subtitle {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 400;
  font-size: 1rem;
  line-height: 1rem;
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
}

.nav-bar-items {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    margin-right: 0;
}

.nav-bar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--md-sys-shape-corner-full);
    cursor: pointer;
    text-decoration: none;
    color: var(--md-sys-color-on-surface-variant);
    font: var(--md-sys-typescale-label-large);
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
    position: relative;
    overflow: hidden;
}

.nav-bar-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: currentColor;
    opacity: 0;
    transition: opacity 200ms cubic-bezier(0.2, 0, 0, 1);
}

.nav-bar-item:hover {
    text-decoration: none;
    color: var(--md-sys-color-on-surface);
}

.nav-bar-item:hover::before {
    opacity: 0.08;
}

.nav-bar-item.active {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.nav-bar-item.active:hover::before {
    opacity: 0;
}

.nav-bar-item .material-icons {
    font-size: 20px;
}

.nav-bar-item-label {
    white-space: nowrap;
}

/* ===== Main Content ===== */
.main-content {
    margin-top: var(--top-nav-height);
    flex: 1;
}

.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 24px;
}

/* ===== Loading & Error States ===== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 16px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--md-sys-color-surface-container);
    border-top-color: var(--md-sys-color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font: var(--md-sys-typescale-body-large);
    color: var(--md-sys-color-on-surface-variant);
}

/* ===== Game List Page ===== */
.game-list-container {
    max-width: 1200px;
    margin: 0 auto;
}

.game-list-header {
    margin-bottom: 24px;
    text-align: center;
}

.game-list-title {
    font: var(--md-sys-typescale-headline-large);
    font-family: 'Calistoga', serif;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 8px;
}

.game-list-subtitle {
    font: var(--md-sys-typescale-body-large);
    color: var(--md-sys-color-on-surface-variant);
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.game-search-container {
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
}

.game-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 600px;
    width: 100%;
}

.game-search-icon {
    position: absolute;
    left: 16px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 24px;
    pointer-events: none;
}

.game-search-input {
    width: 100%;
    height: 56px;
    padding: 0 16px 0 56px;
    border-radius: var(--md-sys-shape-corner-full);
    border: 1px solid var(--md-sys-color-outline-variant);
    background-color: var(--md-sys-color-surface-container-low);
    color: var(--md-sys-color-on-surface);
    font: var(--md-sys-typescale-body-large);
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
}

.game-search-input:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface);
    box-shadow: 0 0 0 2px rgba(148, 184, 255, 0.2);
}

.game-search-input::placeholder {
    color: var(--md-sys-color-on-surface-variant);
}

.game-results-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 800px;
    margin: 0 auto;
}

.game-no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    text-align: center;
    color: var(--md-sys-color-on-surface-variant);
}

.game-no-results .material-icons {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.game-no-results p {
    font: var(--md-sys-typescale-body-large);
}

/* ===== All Games Page ===== */
.all-games-container {
    max-width: 1200px;
    margin: 0 auto;
}

.all-games-header {
    margin-bottom: 32px;
    text-align: center;
}

.all-games-title {
    font: var(--md-sys-typescale-headline-large);
    font-family: 'Calistoga', serif;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 8px;
}

.all-games-count {
    font: var(--md-sys-typescale-body-large);
    color: var(--md-sys-color-on-surface-variant);
}

.all-games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

/* ===== Game Card ===== */
.game-card {
    display: flex;
    flex-direction: column;
    padding: 24px;
    background-color: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-large);
    cursor: pointer;
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
    text-decoration: none;
    color: inherit;
    position: relative;
    min-height: 180px;
    width: 100%;
}

.game-card:hover {
    box-shadow: var(--md-sys-elevation-2);
    transform: translateY(-2px);
}

.md-card {
    background-color: var(--md-sys-color-surface-container-low);
}

.md-card-elevated {
    box-shadow: var(--md-sys-elevation-1);
}

.game-card-header {
    flex: 1;
    margin-bottom: 16px;
}

.game-card-title {
    font: var(--md-sys-typescale-title-large);
    color: var(--md-sys-color-on-surface);
    margin-bottom: 8px;
}

.game-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.game-card-tag {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 10px;
    border-radius: var(--md-sys-shape-corner-full);
    font: var(--md-sys-typescale-label-small);
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.game-card-metadata {
    display: flex;
    gap: 16px;
    margin-top: auto;
}

.game-card-status,
.game-card-tech {
    display: flex;
    align-items: center;
    gap: 4px;
    font: var(--md-sys-typescale-body-small);
    color: var(--md-sys-color-on-surface-variant);
}

.game-card-status .material-icons,
.game-card-tech .material-icons {
    font-size: 16px;
}

.game-card-arrow {
    position: absolute;
    top: 24px;
    right: 24px;
    font-size: 24px;
    color: var(--md-sys-color-on-surface-variant);
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
}

.game-card:hover .game-card-arrow {
    color: var(--md-sys-color-primary);
    transform: translateX(4px);
}

/* ===== Game Page Styles ===== */
.game-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 24px;
}

.game-back-button-container {
    margin-bottom: 24px;
    margin-top: 8px;
}

.game-back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--md-sys-shape-corner-full);
    color: var(--md-sys-color-link);
    font: var(--md-sys-typescale-label-large);
    text-decoration: none;
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
    background-color: transparent;
    border: none;
    cursor: pointer;
}

.game-back-button:hover {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-link-hover);
    text-decoration: none;
}

.game-back-button .material-icons {
    font-size: 20px;
}

.game-header {
    margin-bottom: 32px;
}

.game-title {
    font-family: 'Calistoga', serif;
    font-weight: 400;
    font-size: 2.5rem;
    line-height: 3rem;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 16px;
}

.game-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    margin-bottom: 24px;
    padding: 16px;
    background-color: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-medium);
}

.game-metadata-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font: var(--md-sys-typescale-body-medium);
    color: var(--md-sys-color-on-surface-variant);
}

.game-metadata-item .material-icons {
    font-size: 18px;
    color: var(--md-sys-color-primary);
}

.game-metadata-label {
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.game-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 32px;
}

.game-tag {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 16px;
    border-radius: var(--md-sys-shape-corner-full);
    font: var(--md-sys-typescale-label-large);
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
}

.game-tag:hover {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.game-section {
    margin-bottom: 32px;
}

.game-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font: var(--md-sys-typescale-title-medium);
    color: var(--md-sys-color-on-surface);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--md-sys-color-primary-container);
}

.game-section-title .material-icons {
    font-size: 24px;
    color: var(--md-sys-color-primary);
}

.game-description {
    padding: 20px;
    background-color: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-medium);
}

.game-description-text {
    font: var(--md-sys-typescale-body-medium);
    color: var(--md-sys-color-on-surface);
    line-height: 1.6;
}

.game-features {
    padding: 20px;
    background-color: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-medium);
}

.game-features-list {
    list-style: disc;
    padding-left: 24px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.game-feature-item {
    font: var(--md-sys-typescale-body-medium);
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.6;
}

.game-feature-item::marker {
    color: var(--md-sys-color-tertiary);
}

.game-controls {
    padding: 20px;
    background-color: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-medium);
}

.game-controls-list {
    list-style: disc;
    padding-left: 24px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.game-control-item {
    font: var(--md-sys-typescale-body-medium);
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.6;
}

.game-control-item::marker {
    color: var(--md-sys-color-tertiary);
}

/* ===== Footer ===== */
.site-footer {
    background-color: var(--md-sys-color-surface-container);
    border-top: 1px solid var(--md-sys-color-outline-variant);
    padding: 10px 24px;
    margin-top: auto;
}

.footer-content {
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-avatar {
    width: 20px;
    height: 20px;
    object-fit: cover;
    filter: brightness(0) invert(0.11);
}

.footer-copyright {
    color: var(--md-sys-color-on-surface-variant);
    font: var(--md-sys-typescale-body-small);
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-version {
    font-family: "Roboto Mono", monospace;
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
}

.footer-github {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 20px;
    text-decoration: none;
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
    border-radius: var(--md-sys-shape-corner-small);
}

.footer-github:hover {
    background-color: var(--md-sys-color-primary-container);
}

/* ===== Responsive Design ===== */
@media (min-width: 1248px) {
    .nav-bar {
        padding-left: calc((100% - var(--max-width)) / 2);
        padding-right: calc((100% - var(--max-width)) / 2);
    }
}

@media (max-width: 768px) {
    .page-container {
        padding: 20px 16px;
    }
    
    .game-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .game-title {
        font-size: 2rem;
        line-height: 2.5rem;
    }
    
    .game-metadata {
        flex-direction: column;
        gap: 12px;
    }
    
    .game-description,
    .game-features,
    .game-controls {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 1.75rem;
        line-height: 2.25rem;
    }
    
    .nav-bar {
        padding: 0 16px;
    }
    
    .nav-bar-title {
        display: none;
    }
    
    .game-search-wrapper {
        max-width: 100%;
    }
    
    .game-search-input {
        height: 48px;
        font-size: 16px;
    }
    
    .site-footer {
        padding: 10px 16px;
    }
}
