*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f0f2f5;
    color: #2d3748;
}

header {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #ffffff;
    padding: 0;
    text-align: center;
    box-shadow: 0 2px 12px rgba(79, 70, 229, 0.3);
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    margin: 0;
    font-size: 22px;
}

header h1 a {
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 1px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

header h1 a:hover {
    color: #fbbf24;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 24px;
}

.header-nav {
    display: flex;
    gap: 6px;
    align-items: center;
}

.lang-toggle {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1.5px solid rgba(255, 255, 255, 0.45);
    border-radius: 6px;
    padding: 5px 13px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    margin-left: 4px;
    line-height: 1;
}
.lang-toggle:hover {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.7);
}

.header-nav a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s, transform 0.15s;
}

.header-nav a:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: translateY(-1px);
}

.layout-shell {
    display: flex;
    min-height: calc(100vh - 120px);
}

.sidebar {
    width: 230px;
    background: #ffffff;
    color: #374151;
    padding: 24px 14px;
    box-sizing: border-box;
    border-right: 1px solid #e5e7eb;
}

.sidebar-section {
    margin-bottom: 28px;
}

.sidebar h2 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #9ca3af;
    padding-left: 12px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav a {
    color: #4b5563;
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s, color 0.15s;
}

.sidebar-nav a:hover {
    background: #f3f4f6;
    color: #4f46e5;
}

.sidebar-nav a.active {
    background: #ede9fe;
    color: #4f46e5;
    font-weight: 600;
}

.content-area {
    flex: 1;
    padding: 20px 0 30px;
    min-width: 0;
}

h1 {
    margin: 0;
}

.container {
    width: 85%;
    max-width: 1000px;
    margin: auto;
    overflow: hidden;
}

footer {
    background: linear-gradient(135deg, #1e1b4b, #312e81);
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    padding: 14px 0;
    font-size: 13px;
    width: 100%;
}

nav {
    margin-top: 10px;
}

nav a {
    color: #ffffff;
    text-decoration: none;
    margin: 0 15px;
    font-size: 16px;
}

nav a:hover {
    text-decoration: underline;
}

.btn {
    display: inline-block;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #ffffff;
    padding: 10px 22px;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    margin-top: 10px;
    text-decoration: none;
    border-radius: 8px;
    transition: transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}

.upload-form {
    margin: 20px 0;
}

.upload-area {
    border: 2px dashed #c7d2fe;
    padding: 40px;
    text-align: center;
    margin-bottom: 15px;
    background: #fafaff;
    border-radius: 12px;
    transition: border-color 0.2s, background 0.2s;
}

.upload-area:hover {
    border-color: #818cf8;
    background: #f0f0ff;
}

.upload-area input[type="file"] {
    margin-top: 10px;
}

.file-list {
    list-style: none;
    padding: 0;
}

.file-list li {
    background: #fff;
    padding: 12px 16px;
    margin: 5px 0;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    transition: box-shadow 0.2s;
}

.file-list li:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.file-list li a {
    color: #4f46e5;
    text-decoration: none;
    font-weight: 500;
}

.file-list li a:hover {
    text-decoration: underline;
}

.file-content {
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 20px;
    margin: 15px 0;
    overflow-x: auto;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.file-content pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.alert {
    padding: 12px 16px;
    margin: 10px 0;
    border: 1px solid;
    border-radius: 8px;
    font-size: 14px;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.verify-form {
    max-width: 400px;
    margin: 30px 0;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    font-size: 15px;
    box-sizing: border-box;
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

.file-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.file-table th,
.file-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

.file-table th {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

.file-table tr:hover {
    background: #f5f3ff;
}

.file-table a {
    color: #4f46e5;
    text-decoration: none;
    font-weight: 500;
}

.file-table a:hover {
    text-decoration: underline;
}

.home-hero {
    background: linear-gradient(135deg, #ede9fe, #e0e7ff);
    padding: 28px;
    border: none;
    border-radius: 14px;
    margin: 20px 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 18px;
    border-radius: 12px;
    transition: box-shadow 0.2s, transform 0.15s;
}

.stat-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.stat-card h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 26px;
    margin: 0;
    font-weight: 700;
    color: #4f46e5;
}

.home-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 12px;
}

.file-meta {
    color: #666;
    margin-left: 10px;
    font-size: 14px;
}

.home-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.product-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.product-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 14px;
    border-radius: 12px;
    transition: box-shadow 0.2s, transform 0.15s;
}

.product-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
    transform: translateY(-3px);
}

.product-img-wrap {
    position: relative;
}

.video-play-btn {
    position: absolute;
    bottom: 18px;
    right: 8px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background .2s;
}

.video-play-btn:hover {
    background: rgba(0,0,0,0.8);
}

.product-image {
    width: 100%;
    height: 220px;
    display: block;
    object-fit: cover;
    border: none;
    margin-bottom: 10px;
    border-radius: 8px;
}

.product-title {
    margin: 0 0 6px;
    color: #1e1b4b;
}

.product-price {
    margin: 0;
    color: #4f46e5;
    font-weight: bold;
    font-size: 17px;
}

.product-price .ref-label {
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
    background: #f3f4f6;
    border-radius: 3px;
    padding: 1px 5px;
    margin-right: 3px;
    vertical-align: middle;
}

.product-video {
    width: 100%;
    max-height: 220px;
    display: block;
    margin-bottom: 10px;
    border: 1px solid #eee;
}

.video-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.video-modal-content {
    position: relative;
    max-width: 720px;
    width: 90%;
}

.video-modal-content video {
    width: 100%;
    border-radius: 6px;
}

.video-modal-close {
    position: absolute;
    top: -36px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
}

@media (max-width: 900px) {
    .layout-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        padding: 12px 14px;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        /* 侧边栏改为横向滚动导航 */
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
    }

    .sidebar-section {
        margin-bottom: 0;
        flex: 1 1 140px;
    }

    .content-area {
        padding-top: 0;
    }

    .container {
        width: 96%;
    }

    .product-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* 导航折行 */
    .header-inner {
        flex-wrap: wrap;
        gap: 6px;
        padding: 10px 14px;
    }
    .header-nav {
        flex-wrap: wrap;
        gap: 4px;
    }
    .header-nav a {
        font-size: 12px;
        padding: 5px 10px;
    }

    /* 首页英雄区 */
    .home-hero {
        padding: 18px;
    }

    /* 统计卡片横排 */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* 表格横向滚动 */
    .file-table, .manage-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 游戏 canvas 自动缩放 */
    canvas {
        max-width: 100%;
        height: auto !important;
    }
    #gomokuCanvas, #gameCanvas {
        width: 100% !important;
        height: auto !important;
    }

    /* 老虎机布局 */
    .slot-machine {
        width: 100%;
    }
    .reel {
        width: 80px !important;
        height: 100px !important;
    }
    .symbol {
        font-size: 36px !important;
        height: 100px !important;
        line-height: 100px !important;
    }
    .slot-frame {
        padding: 10px !important;
    }

    /* 游戏信息行折行 */
    .game-info {
        flex-wrap: wrap;
        gap: 8px;
    }
}

@media (max-width: 560px) {
    .product-list {
        grid-template-columns: 1fr;
    }

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

    /* header 标题+导航竖排 */
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    /* 按钮组竖排 */
    .home-actions {
        flex-direction: column;
    }
    .home-actions .btn {
        width: 100%;
        text-align: center;
    }

    /* 上传区内边距缩小 */
    .upload-area {
        padding: 20px 12px;
    }

    /* 五子棋操作栏竖排 */
    .game-info {
        flex-direction: column;
        align-items: center;
    }

    /* 老虎机轮盘更小 */
    .reel {
        width: 64px !important;
        height: 84px !important;
    }
    .symbol {
        font-size: 28px !important;
        height: 84px !important;
        line-height: 84px !important;
    }

    /* 赔率表三列改两列 */
    .paytable-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    /* 表单全宽 */
    .verify-form {
        max-width: 100%;
    }

    /* 弹窗视频自适应 */
    .video-modal-content {
        width: 98%;
    }
}

/* Manage products page */
.manage-hint {
    color: #666;
    margin-bottom: 10px;
}

.manage-table td, .manage-table th {
    vertical-align: middle;
}

.manage-table .edit-input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #aaa;
    font-size: 14px;
    box-sizing: border-box;
}

.manage-table .edit-price {
    width: 90px;
}

.cell-actions {
    white-space: nowrap;
}

.btn-edit, .btn-save, .btn-cancel, .btn-delete {
    border: none;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 13px;
    border-radius: 3px;
    margin-right: 4px;
}

.btn-edit {
    background: #4f46e5;
    color: #fff;
}

.btn-edit:hover {
    background: #4338ca;
}

.btn-save {
    background: #28a745;
    color: #fff;
}

.btn-save:hover {
    background: #218838;
}

.btn-cancel {
    background: #6c757d;
    color: #fff;
}

.btn-cancel:hover {
    background: #5a6268;
}

.btn-delete {
    background: #dc3545;
    color: #fff;
}

.btn-delete:hover {
    background: #c82333;
}

.no-video {
    color: #999;
    font-style: italic;
}

.edit-file {
    max-width: 140px;
    font-size: 12px;
}