:root {
    --orange: #f97315;
    --orange-hover: #fc5f01;
    --orange-dark: #c27431;
    --orange-light: rgba(249,115,21,.08);
    --teal: #1d9e75;
    --teal-light: rgba(29,158,117,.08);
    --bg: #effcf4;
    --bg-gradient-start: #effcf4;
    --bg-gradient-end: #f5f3ee;
    --dark: #1b1c1b;
    --card-bg: #ffffff;
    --card-border: rgba(0,0,0,.06);
    --card-shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.03);
    --card-shadow-hover: 0 2px 8px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06);
    --text-primary: #1b1c1b;
    --text-secondary: #6b6b6b;
    --text-muted: #999;
    --border-color: #e8e8e8;
    --input-bg: #ffffff;
    --input-border: #e0e0e0;
    --green-check: #2ecc40;
    --red-error: #e74c3c;
    --gold: #f0a500;
    --nav-link: #555;
    --nav-link-active: var(--orange);
    --footer-text: #999;
    --modal-bg: #ffffff;
    --modal-border: rgba(0,0,0,.08);
    --sidebar-item-bg: #ffffff;
    --sidebar-item-hover: #f5f5f5;
    --sidebar-item-active: var(--orange-light);
    --sidebar-item-active-text: var(--orange);
    --progress-bg: #e8e8e8;
    --step-badge-bg: var(--orange);
    --step-badge-text: #ffffff;
    --audio-bg: #f8f8f8;

    --game-bg: #f3eee7;
    --game-surface: #ffffff;
    --game-surface-mid: #ede7de;
    --game-surface-deep: #e5ddd3;
    --game-surface-light: #faf7f3;
    --game-brown: #2f241c;
    --game-text-label: #6b6158;
    --game-chip-bg: #faf7f3;
    --game-chip-shadow: 4px 4px 10px rgba(0,0,0,.06), -4px -4px 10px rgba(255,255,255,.8);
    --game-neu-out: 8px 8px 18px rgba(0,0,0,.07), -8px -8px 18px rgba(255,255,255,.75);
    --game-neu-out-sm: 4px 4px 10px rgba(0,0,0,.06), -4px -4px 10px rgba(255,255,255,.7);
    --game-neu-in: inset 3px 3px 6px rgba(0,0,0,.06), inset -3px -3px 6px rgba(255,255,255,.5);
    --game-neu-btn: 5px 5px 14px rgba(249,115,21,.3), -3px -3px 10px rgba(255,255,255,.5), inset 0 1px 0 rgba(255,255,255,.2);
    --game-deco-opacity: 0.45;
    --game-stat-icon-bg: #f3eee7;
    --game-btn2-bg: #faf7f3;
    --game-btn2-border: #e5ddd3;
}

[data-theme="dark"] {
    --bg: #1b1c1b;
    --bg-gradient-start: #1e1d1c;
    --bg-gradient-end: #1b1c1b;
    --card-bg: #262524;
    --card-border: rgba(255,255,255,.06);
    --card-shadow: 0 1px 3px rgba(0,0,0,.2), 0 4px 12px rgba(0,0,0,.15);
    --card-shadow-hover: 0 2px 8px rgba(0,0,0,.25), 0 8px 24px rgba(0,0,0,.2);
    --text-primary: #f0ede8;
    --text-secondary: #9a9590;
    --text-muted: #6b6560;
    --border-color: rgba(255,255,255,.08);
    --input-bg: #2a2928;
    --input-border: rgba(255,255,255,.1);
    --nav-link: #9a9590;
    --footer-text: #5a5550;
    --modal-bg: #262524;
    --modal-border: rgba(255,255,255,.08);
    --sidebar-item-bg: #2a2928;
    --sidebar-item-hover: #302f2e;
    --sidebar-item-active: rgba(249,115,21,.12);
    --sidebar-item-active-text: var(--orange);
    --progress-bg: rgba(255,255,255,.08);
    --audio-bg: #2a2928;

    --game-bg: #1c1a17;
    --game-surface: #262320;
    --game-surface-mid: #2a2724;
    --game-surface-deep: #332f2a;
    --game-surface-light: #302c28;
    --game-brown: #f0eae0;
    --game-text-label: #b0a898;
    --game-chip-bg: #302c28;
    --game-chip-shadow: 4px 4px 12px rgba(0,0,0,.25), -4px -4px 12px rgba(60,55,48,.15);
    --game-neu-out: 6px 6px 16px rgba(0,0,0,.3), -6px -6px 16px rgba(60,55,48,.1);
    --game-neu-out-sm: 4px 4px 10px rgba(0,0,0,.25), -4px -4px 10px rgba(60,55,48,.08);
    --game-neu-in: inset 3px 3px 6px rgba(0,0,0,.2), inset -3px -3px 6px rgba(60,55,48,.08);
    --game-neu-btn: 4px 4px 12px rgba(249,115,21,.25), -3px -3px 8px rgba(60,55,48,.1), inset 0 1px 0 rgba(255,255,255,.06);
    --game-deco-opacity: 0.08;
    --game-stat-icon-bg: #332f2a;
    --game-btn2-bg: #302c28;
    --game-btn2-border: #3d3833;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    transition: background .3s, color .3s;
}

body::before {
    content: '';
    position: fixed; inset: 0;
    background:
        radial-gradient(ellipse 70% 50% at 0% 0%, rgba(78,160,78,.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 100% 0%, rgba(249,115,21,.04) 0%, transparent 50%);
    pointer-events: none; z-index: 0;
}

[data-theme="dark"] body::before {
    background:
        radial-gradient(ellipse 70% 50% at 0% 0%, rgba(249,115,21,.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(58,175,169,.04) 0%, transparent 50%);
}

.navbar {
    position: sticky; top: 0; z-index: 100;
    background: rgba(239,252,244,.8);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    transition: background .3s, border-color .3s;
}
[data-theme="dark"] .navbar { background: rgba(27,28,27,.8); }

.navbar-inner {
    max-width: 1280px; margin: 0 auto;
    display: flex; align-items: center; height: 60px; gap: 2rem;
}

.nav-logo {
    display: flex; align-items: center;
    text-decoration: none; flex-shrink: 0; height: 36px;
}
.nav-logo img { height: 150px; width: auto; }

.nav-links { display: flex; align-items: center; gap: 1.75rem; list-style: none; }
.nav-links a {
    font-size: .875rem; font-weight: 500; color: var(--nav-link);
    text-decoration: none; transition: color .2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--nav-link-active); }

.nav-dropdown { position: relative; }
.nav-dropdown-trigger {
    display: flex; align-items: center; gap: .3rem; cursor: pointer;
}
.nav-dropdown-trigger .chevron {
    transition: transform .2s; font-size: .6rem; margin-top: 1px;
}
.nav-dropdown:hover .chevron { transform: rotate(180deg); }
.nav-dropdown-menu {
    position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    min-width: 520px; padding: 1.5rem 1.75rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.04);
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem;
    opacity: 0; visibility: hidden;
    transition: opacity .2s, visibility .2s, transform .2s;
    transform: translateX(-50%) translateY(8px);
    z-index: 200;
}
.nav-dropdown:hover .nav-dropdown-menu {
    opacity: 1; visibility: visible;
    transform: translateX(-50%) translateY(0);
}
.nav-dropdown-menu::before {
    content: ''; position: absolute; top: -10px; left: 0; right: 0; height: 10px;
}
.dropdown-group-title {
    display: flex; align-items: center; gap: .4rem;
    font-size: .7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; margin-bottom: .6rem; color: var(--orange);
}
.dropdown-group-title svg { flex-shrink: 0; }
.dropdown-group-items { list-style: none; display: flex; flex-direction: column; gap: .25rem; }
.dropdown-group-items a {
    font-size: .8rem; font-weight: 400; color: var(--text-secondary);
    text-decoration: none; padding: .25rem 0; display: block;
    transition: color .15s;
}
.dropdown-group-items a:hover { color: var(--orange); }

.nav-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }

.nav-history-btn {
    display: flex; align-items: center; gap: .4rem;
    font-size: .875rem; font-weight: 500; color: var(--nav-link);
    background: none; border: none; cursor: pointer;
    transition: color .2s; padding: .4rem .6rem; border-radius: 8px;
    font-family: inherit;
}
.nav-history-btn:hover { color: var(--text-primary); }

.theme-toggle-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: 1px solid var(--border-color);
    border-radius: 10px; cursor: pointer; font-size: 1rem;
    color: var(--text-secondary); transition: all .2s;
}
.theme-toggle-btn:hover { background: var(--card-bg); border-color: var(--text-muted); }

.site-footer {
    text-align: center; padding: 3rem 1.5rem 2rem;
    color: var(--footer-text); font-size: .8rem; position: relative; z-index: 1;
}
.footer-brand {
    font-weight: 600; font-size: .9rem; color: var(--text-secondary);
    margin-bottom: .3rem; display: flex; align-items: center; justify-content: center; gap: .35rem;
}

.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; z-index: 10000;
}
.modal-backdrop.hidden { display: none !important; }
.modal {
    background: var(--modal-bg); border: 1px solid var(--modal-border);
    border-radius: 20px; padding: 2rem 2.25rem;
    width: 90%; max-width: 480px; color: var(--text-primary);
    position: relative; box-shadow: 0 24px 64px rgba(0,0,0,.2);
    animation: modalIn .25s ease both;
}
@keyframes modalIn { from { opacity:0; transform:scale(.96) translateY(8px); } to { opacity:1; transform:scale(1) translateY(0); } }
.modal-close {
    position: absolute; top: 1rem; right: 1.25rem;
    background: none; border: none; color: var(--text-muted);
    font-size: 1.2rem; cursor: pointer; transition: color .15s;
}
.modal-close:hover { color: var(--text-primary); }
.modal h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: .4rem; }
.modal p { color: var(--text-secondary); font-size: .88rem; margin-bottom: 1.5rem; }

.modal-actions { display: flex; gap: .75rem; }
.modal-submit {
    flex: 1; padding: .75rem; background: var(--orange); color: #fff;
    border: none; border-radius: 10px; font-size: .95rem; font-weight: 600;
    cursor: pointer; transition: opacity .2s; font-family: inherit;
}
.modal-submit:hover { opacity: .88; }
.modal-submit:disabled { opacity: .4; cursor: not-allowed; }
.modal-cancel {
    padding: .75rem 1.25rem; background: none; color: var(--text-muted);
    border: none; border-radius: 10px; font-size: .95rem;
    cursor: pointer; transition: color .15s; font-family: inherit;
}
.modal-cancel:hover { color: var(--text-primary); }

.share-option {
    display: flex; align-items: center; gap: 1rem;
    padding: .75rem 1rem; border-radius: 12px;
    color: var(--text-primary); text-decoration: none;
    font-weight: 500; transition: background .2s;
}
.share-option:hover { background: var(--orange-light); }
.share-icon { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.share-icon svg { width: 22px; height: 22px; }
.copy-link-box {
    margin-top: 1rem; background: var(--input-bg);
    border: 1px solid var(--input-border); border-radius: 12px;
    display: flex; align-items: center; padding: .4rem .4rem .4rem 1rem; gap: .5rem;
}
.copy-link-box input {
    flex: 1; background: transparent; border: none;
    color: var(--text-primary); outline: none;
    font-size: .85rem; font-family: inherit; min-width: 0;
}
.copy-link-box button {
    background: var(--orange); color: #fff; border: none;
    padding: .55rem 1rem; border-radius: 8px; cursor: pointer;
    font-size: .8rem; font-weight: 600; font-family: inherit; transition: background .2s;
}
.copy-link-box button:hover { background: var(--orange-hover); }

.stars { display: flex; gap: .5rem; justify-content: center; margin-bottom: .6rem; }
.star { font-size: 2.4rem; cursor: pointer; color: var(--progress-bg); transition: color .15s, transform .1s; user-select: none; }
.star.active { color: var(--gold); }
.star:hover { transform: scale(1.18); color: var(--gold); }
.star-hint { text-align: center; font-size: .82rem; color: var(--text-muted); min-height: 1.2em; margin-bottom: 1rem; font-style: italic; }
.comment-box {
    width: 100%; background: var(--input-bg); border: 1px solid var(--input-border);
    border-radius: 10px; color: var(--text-primary); padding: .75rem;
    font-size: .9rem; resize: vertical; min-height: 80px; margin-bottom: 1rem;
    font-family: inherit; transition: background .3s, color .3s;
}
.comment-box::placeholder { color: var(--text-muted); }
.comment-box:focus { outline: none; border-color: var(--orange); }

.history-modal-inner { max-height: 70vh; display: flex; flex-direction: column; }
.history-header { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.history-icon {
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--orange-light); display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
}
.history-icon svg { width: 22px; height: 22px; stroke: var(--orange); fill: none; stroke-width: 2; }
.history-search {
    width: 100%; padding: .7rem 1rem .7rem 2.5rem;
    background: var(--input-bg); border: 1px solid var(--input-border);
    border-radius: 12px; font-size: .9rem; font-family: inherit;
    color: var(--text-primary); outline: none; transition: border-color .2s;
    margin-bottom: 1rem;
}
.history-search:focus { border-color: var(--orange); }
.history-search-wrapper { position: relative; }
.history-search-wrapper svg {
    position: absolute; left: .85rem; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; stroke: var(--text-muted); fill: none; stroke-width: 2;
}
.history-list {
    flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem;
    max-height: 400px; scrollbar-width: thin;
}
.history-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .85rem 1rem; background: var(--card-bg);
    border: 1px solid var(--card-border); border-radius: 14px;
    text-decoration: none; color: var(--text-primary); transition: all .2s;
}
.history-item:hover { border-color: var(--orange); background: var(--orange-light); }
.history-item-icon {
    width: 40px; height: 40px; border-radius: 10px;
    background: var(--input-bg); display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
}
.history-item-icon svg { width: 18px; height: 18px; stroke: var(--text-muted); fill: none; stroke-width: 1.5; }
.history-item-text { flex: 1; min-width: 0; }
.history-item-title { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item-meta { font-size: .75rem; color: var(--text-muted); display: flex; align-items: center; gap: .4rem; margin-top: .15rem; }
.history-item-meta .star-small { color: var(--orange); }
.history-item-arrow { color: var(--text-muted); flex-shrink: 0; font-size: 1rem; }
.history-close-btn {
    width: 100%; margin-top: 1rem; padding: .85rem;
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: 14px; font-size: .95rem; font-weight: 500;
    color: var(--text-secondary); cursor: pointer; font-family: inherit; transition: all .2s;
}
.history-close-btn:hover { border-color: var(--text-muted); color: var(--text-primary); }

.hidden { display: none !important; }

.lightbox {
    position: fixed; inset: 0; z-index: 20000;
    background: rgba(0,0,0,.85); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    cursor: zoom-out; animation: fadeIn .2s ease;
}
.lightbox.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.lightbox img {
    max-width: 92vw; max-height: 90vh;
    border-radius: 12px; box-shadow: 0 8px 40px rgba(0,0,0,.4);
    object-fit: contain;
}
.lightbox-close {
    position: absolute; top: 1.5rem; right: 1.5rem;
    background: rgba(255,255,255,.15); border: none;
    color: #fff; width: 40px; height: 40px; border-radius: 50%;
    font-size: 1.2rem; cursor: pointer; display: flex;
    align-items: center; justify-content: center; transition: background .2s;
}
.lightbox-close:hover { background: rgba(255,255,255,.3); }

@media (max-width: 960px) {
    .nav-links { display: none; }
}

@media (max-width: 600px) {
    .navbar { padding: 0 1rem; }
}
