:root {
    /* Color Palette - Cyber/Premium HK Style */
    --primary-color: #003366;
    /* Deep Hong Kong Blue */
    --accent-color: #C8102E;
    /* Taxi Red */
    --bg-gradient-start: #f0f2f5;
    --bg-gradient-end: #e6e9f0;
    --text-primary: #1a1a1a;
    --text-secondary: #595959;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 48px;
    --font-family: 'Noto Sans HK', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-primary);
    min-height: 100vh;
    padding-bottom: var(--spacing-xl);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* Header */
header {
    text-align: center;
    padding: var(--spacing-xl) 0;
}

.logo {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: var(--spacing-md);
    letter-spacing: -1px;
}

.time-display {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    font-variant-numeric: tabular-nums;
}

.weather-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.weather-icon {
    font-size: 1.5rem;
}

.weather-temp {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.weather-desc {
    font-size: 0.9rem;
}

/* Search Bar */
.search-container {
    max-width: 600px;
    margin: 0 auto var(--spacing-xl);
    position: relative;
    z-index: 10;
}

.search-box {
    display: flex;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    padding: var(--spacing-xs);
    backdrop-filter: blur(10px);
    transition: box-shadow 0.3s ease;
}

.search-box:focus-within {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1), 0 0 0 2px var(--primary-color);
}

.search-engine-select {
    background: transparent;
    border: none;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 1rem;
    color: var(--text-primary);
    border-right: 1px solid var(--text-secondary);
    cursor: pointer;
    outline: none;
    font-weight: 600;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 1.1rem;
    color: var(--text-primary);
    outline: none;
}

.search-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 0 var(--spacing-lg);
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s ease;
}

.search-btn:hover {
    background: var(--accent-color);
}

.tools-btn {
    background: transparent;
    border: none;
    font-size: 0.95rem;
    color: var(--text-secondary);
    padding: 0 var(--spacing-md);
    cursor: pointer;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    font-weight: 500;
    white-space: nowrap;
}

.tools-btn:hover {
    color: var(--primary-color);
    background: rgba(0, 0, 0, 0.02);
}

/* Categories */
.category-section {
    margin-bottom: var(--spacing-sm);
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.category-title {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin: 0;
    padding: 12px 16px;
    border-left: 4px solid var(--accent-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    transition: background 0.2s;
    user-select: none;
}

.category-title:hover {
    background: #e2e8f0;
}

.category-title::after {
    content: '▼';
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.category-section.collapsed .category-title::after {
    transform: rotate(-90deg);
}

.link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    padding: 16px;
    border-top: 1px solid #eee;
}

.category-section.collapsed .link-grid {
    display: none;
}

.link-item {
    background: transparent;
    border: none;
    padding: 6px 8px;
    text-align: left;
    text-decoration: none;
    color: #4b5563;
    display: block;
    position: relative;
    font-size: 0.95rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.link-item:hover {
    color: var(--primary-color);
    background: #f3f4f6;
    padding-left: 12px;
}

.link-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-icon {
    display: none;
}

/* Stars */
.link-star {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    color: #cbd5e1;
    opacity: 0;
    cursor: pointer;
    transition: all 0.2s;
}

.link-item:hover .link-star,
.link-star.active {
    opacity: 1;
}

.link-star.active {
    color: #fbbf24;
}

/* Sidebar */
.tools-sidebar {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 101;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.tools-sidebar.open {
    right: 0;
}

.sidebar-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}

.sidebar-content {
    padding: 20px;
    overflow-y: auto;
}

.widget-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

/* Calculator */
.calc-display {
    background: #f1f5f9;
    padding: 10px;
    text-align: right;
    font-family: monospace;
    font-size: 1.5rem;
    border-radius: 4px;
    margin-bottom: 10px;
    border: 1px solid #e2e8f0;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.calc-btn {
    padding: 10px;
    font-size: 1.1rem;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.calc-btn:hover {
    background: #e2e8f0;
}

.calc-btn.op {
    background: #e0f2fe;
    color: #0369a1;
}

.calc-btn.equal {
    grid-column: span 2;
    background: var(--primary-color);
    color: white;
}

.calc-btn.clear {
    background: var(--accent-color);
    color: white;
}

/* Game Overlay */
.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.game-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.game-header {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    padding: 20px;
}

.close-game-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    cursor: pointer;
}

.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

/* Game Menu */
.game-menu {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 50px;
}

.game-card {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    width: 200px;
}

.game-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.2);
}

.game-card h3 {
    color: white;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.game-card p {
    color: #cbd5e1;
}

/* 2048 Game */
.game-container-2048,
.game-container-gomoku,
.game-container-jumper {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.game-2048-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    background: #bbada0;
    padding: 10px;
    border-radius: 6px;
    width: 300px;
    height: 300px;
    position: relative;
}

.tile {
    width: 100%;
    height: 100%;
    background: #cdc1b4;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    color: #776e65;
    transition: all 0.15s ease;
}

.tile[data-val="2"] {
    background: #eee4da;
}

.tile[data-val="4"] {
    background: #ede0c8;
}

.tile[data-val="8"] {
    background: #f2b179;
    color: #f9f6f2;
}

.tile[data-val="16"] {
    background: #f59563;
    color: #f9f6f2;
}

.tile[data-val="32"] {
    background: #f67c5f;
    color: #f9f6f2;
}

.tile[data-val="64"] {
    background: #f65e3b;
    color: #f9f6f2;
}

.tile[data-val="128"] {
    background: #edcf72;
    color: #f9f6f2;
    font-size: 20px;
}

.tile[data-val="256"] {
    background: #edcc61;
    color: #f9f6f2;
    font-size: 20px;
}

.tile[data-val="512"] {
    background: #edc850;
    color: #f9f6f2;
    font-size: 20px;
}

.tile[data-val="1024"] {
    background: #edc53f;
    color: #f9f6f2;
    font-size: 16px;
}

.tile[data-val="2048"] {
    background: #edc22e;
    color: #f9f6f2;
    font-size: 16px;
}

.game-msg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(238, 228, 218, 0.73);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    display: none;
}

.game-msg.over {
    display: flex;
}

.game-msg p {
    font-size: 30px;
    font-weight: bold;
    color: #776e65;
}

/* Gomoku Styles */
.gomoku-board {
    width: min(90vw, 500px);
    height: min(90vw, 500px);
    background-color: #e6b380;
    /* Board logic color */
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    grid-template-rows: repeat(15, 1fr);
    border: 5px solid #8b4513;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.gomoku-cell {
    border: 1px solid rgba(0, 0, 0, 0.3);
    position: relative;
    cursor: pointer;
}

.gomoku-cell.occupied {
    cursor: not-allowed;
}

.gomoku-cell::before {
    /* Cross lines fix */
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background: #000;
    transform: translateY(-50%);
    opacity: 0.3;
}

.gomoku-cell::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    height: 100%;
    width: 1px;
    background: #000;
    transform: translateX(-50%);
    opacity: 0.3;
}

.stone {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.4);
    z-index: 2;
}

.stone.black {
    background: radial-gradient(circle at 35% 35%, #666, #000);
}

.stone.white {
    background: radial-gradient(circle at 30% 30%, #fff, #ddd);
}

.stone.winning {
    animation: winningStone 1s ease-in-out infinite;
}

@keyframes winningStone {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.2), 0 4px 8px rgba(0, 0, 0, 0.3);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.1);
        box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.2), 0 8px 16px rgba(255, 215, 0, 0.6);
    }
}

.hint-cell,
.hint-active {
    background: rgba(255, 215, 0, 0.5);
    animation: hintBlink 1s ease-in-out 3;
}

@keyframes hintBlink {

    0%,
    100% {
        background: rgba(255, 215, 0, 0.5);
    }

    50% {
        background: rgba(255, 215, 0, 0.8);
    }
}

.stone.last-move::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30%;
    height: 30%;
    background: red;
    border-radius: 50%;
}

.gomoku-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.gomoku-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    background: #f1f5f9;
    color: #0f172a;
}

.gomoku-btn:hover {
    background: #e2e8f0;
}

footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: auto;
    padding-top: var(--spacing-lg);
    padding-bottom: 20px;
}

@media (max-width: 600px) {
    .search-box {
        flex-direction: column;
        border-radius: 16px;
    }

    .search-engine-select {
        border-right: none;
        border-bottom: 1px solid #ddd;
        width: 100%;
        text-align: center;
    }

    .link-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile Controls Customization */
.mobile-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    gap: 5px;
}

.d-pad-row {
    display: flex;
    gap: 75px;
}

.d-pad {
    width: 70px;
    height: 70px;
    font-size: 32px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s, transform 0.1s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.d-pad:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.95);
}