html {
    scroll-behavior: smooth;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
}

.container {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 16px 20px 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
}

/* Landing page uses wider container */
.hub-container {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 24px;
    padding: 40px 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Header area */
.hub-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 30px 20px;
    margin-bottom: 30px;
}

.hub-header h1 {
    color: #fff;
    font-size: 2.8em;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.hub-header .subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.15em;
    margin-bottom: 0;
}

.game-count {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.9em;
    margin-top: 10px;
}

/* Category Navigation Bar */
.category-nav {
    margin-bottom: 24px;
}

.category-nav-list {
    display: flex;
    list-style: none;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
}

.category-nav-link {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 25px;
    background: rgba(102, 126, 234, 0.08);
    color: #667eea;
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    white-space: nowrap;
}

.category-nav-link:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

/* Category sections */
.category {
    margin-bottom: 30px;
    text-align: left;
    scroll-margin-top: 64px;
}

.category-title {
    font-size: 1.3em;
    color: #555;
    border-bottom: 3px solid #667eea;
    padding-bottom: 8px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-title .cat-icon {
    font-size: 1.2em;
}

/* Game grid */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 0;
}

.game-card {
    background: white;
    border-radius: 14px;
    padding: 24px 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    border: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 36px rgba(102, 126, 234, 0.2);
    border-color: #667eea;
}

.game-icon-wrap {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f0f0ff 0%, #e8e0f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    margin-bottom: 12px;
}

.game-icon-wrap svg {
    width: 36px;
    height: 36px;
}

.game-card h2 {
    color: #333;
    font-size: 1.2em;
    margin-bottom: 8px;
}

.game-card p {
    color: #777;
    line-height: 1.5;
    margin-bottom: 16px;
    font-size: 0.9em;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.badge-new {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    font-size: 0.7em;
    font-weight: bold;
    padding: 3px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

h1 {
    color: #333;
    font-size: 1.6em;
    margin-bottom: 4px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
    color: #666;
    font-size: 1em;
    margin-bottom: 10px;
}

.play-button {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 24px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.95em;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
    cursor: pointer;
}

.play-button:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.play-button:active {
    transform: scale(0.98);
}

.back-button {
    display: inline-block;
    margin-top: 30px;
    color: #667eea;
    text-decoration: none;
    font-size: 1.1em;
    font-weight: bold;
    transition: color 0.2s ease;
}

.back-button:hover {
    color: #764ba2;
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin: 6px 0;
    font-size: 1em;
    font-weight: bold;
    color: #333;
}

.game-info span {
    color: #667eea;
}

.controls {
    margin-top: 8px;
}

.controls p {
    color: #666;
    margin: 4px 0;
    font-size: 0.9em;
}

canvas {
    border-radius: 10px;
}

@media (max-width: 1024px) {
    .game-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .hub-container {
        padding: 30px 20px;
    }
}

/* Site Footer */
.site-footer {
    margin-top: 30px;
    padding-top: 24px;
    border-top: 2px solid #f0f0f0;
    text-align: center;
}

.footer-content {
    margin-bottom: 16px;
}

.footer-brand {
    font-size: 1.1em;
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
}

.footer-tagline {
    color: #999;
    font-size: 0.85em;
    margin-bottom: 12px;
}

.footer-links {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.footer-links a {
    color: #667eea;
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 500;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #764ba2;
}

.footer-updated {
    color: #bbb;
    font-size: 0.75em;
    margin-top: 12px;
}

/* Utility Tool Styles */
.tool-area {
    text-align: left;
    width: 100%;
    margin: 16px 0;
}

.tool-area textarea,
.tool-area input[type="text"],
.tool-area input[type="number"],
.tool-area select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.95em;
    transition: border-color 0.2s;
    background: #fafafa;
    color: #333;
}

.tool-area textarea:focus,
.tool-area input[type="text"]:focus,
.tool-area input[type="number"]:focus,
.tool-area select:focus {
    outline: none;
    border-color: #667eea;
    background: #fff;
}

.tool-area textarea {
    min-height: 120px;
    resize: vertical;
}

.tool-area label {
    display: block;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
    font-size: 0.9em;
}

.tool-output {
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 14px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #333;
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 48px;
    margin-top: 8px;
}

.tool-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.tool-row > * {
    flex: 1;
}

.tool-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tool-tab {
    padding: 8px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    background: #fff;
    color: #555;
    font-weight: 600;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.tool-tab:hover {
    border-color: #667eea;
    color: #667eea;
}

.tool-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.copy-btn {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 20px;
    border-radius: 25px;
    border: none;
    font-weight: bold;
    font-size: 0.85em;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.copy-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.copy-btn:active {
    transform: scale(0.98);
}

.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 8px 0;
}

.tool-grid .info-item {
    background: #f5f5f5;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.88em;
}

.tool-grid .info-item .info-label {
    color: #999;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tool-grid .info-item .info-value {
    color: #333;
    font-weight: 600;
    margin-top: 2px;
    word-break: break-all;
}

@media (max-width: 768px) {
    .tool-row {
        flex-direction: column;
    }
    .tool-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.4em;
    }

    .hub-header h1 {
        font-size: 2em;
    }

    .game-grid {
        grid-template-columns: 1fr;
    }

    .category-nav-list {
        gap: 6px;
    }

    .category-nav-link {
        padding: 6px 14px;
        font-size: 0.82em;
    }

    .container {
        padding: 12px 10px 16px;
        border-radius: 12px;
    }

    .hub-container {
        padding: 20px 15px;
    }

    .game-info {
        gap: 16px;
        font-size: 0.9em;
        margin: 4px 0;
    }

    .controls p {
        font-size: 0.85em;
        margin: 2px 0;
    }
}

/* Game page wrapper: game + sidebar side-by-side */
.game-page-wrapper {
    display: flex;
    justify-content: center;
    gap: 16px;
    width: 100%;
    max-width: 1200px;
    align-items: flex-start;
}

.game-page-wrapper > .container {
    flex: 1;
    min-width: 0;
}

/* Similar Games sidebar */
.similar-games-section {
    width: 180px;
    flex-shrink: 0;
    position: sticky;
    top: 68px;
    padding: 16px 12px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.similar-games-title {
    font-size: 0.9em;
    color: #555;
    border-bottom: 2px solid #667eea;
    padding-bottom: 6px;
    margin: 0;
}

.similar-game-card {
    background: white;
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
    text-decoration: none;
    border: 1px solid #f0f0f0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.similar-game-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.2);
    border-color: #667eea;
}

.similar-game-card .game-icon-wrap {
    width: 40px;
    height: 40px;
    font-size: 1.3em;
}

.similar-game-card .game-icon-wrap svg {
    width: 24px;
    height: 24px;
}

.similar-game-card .game-name {
    color: #333;
    font-weight: 600;
    font-size: 0.78em;
    line-height: 1.2;
}

/* Responsive: sidebar collapses below game */
@media (max-width: 1024px) {
    .game-page-wrapper {
        flex-direction: column;
        align-items: center;
    }

    .similar-games-section {
        width: 100%;
        max-width: 900px;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        max-height: none;
        margin-top: 12px;
    }

    .similar-games-title {
        width: 100%;
    }

    .similar-game-card {
        flex: 1 1 calc(25% - 10px);
        min-width: 120px;
    }
}
