* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    overflow-x: hidden;
    overflow-y: auto;
}

body {
    font-family: 'Unbounded', sans-serif;
    background: linear-gradient(180deg, #121221 0%, #000000 100%) fixed;
    min-height: 100vh;
    min-height: 100dvh;
    color: #ffffff;
    overflow-x: hidden;
}

/* ── Header / Nav ── */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background-color: #0E1350;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
}

.logo-link {
    display: flex;
    align-items: center;
}

.site-logo {
    height: 36px;
    width: auto;
}

.nav-menu {
    display: flex;
    align-items: center;
}

.nav-link {
    color: #29FBCD;
    text-decoration: none;
    font-family: 'Unbounded', sans-serif;
    font-size: 14px;
    font-weight: 400;
    padding: 8px 16px;
    transition: opacity 0.2s ease;
}

.nav-link:hover {
    opacity: 0.8;
}

.dropdown {
    position: relative;
}

.dropdown-button {
    background: transparent;
    border: none;
    color: #29FBCD;
    font-family: 'Unbounded', sans-serif;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    padding: 8px 16px;
    transition: opacity 0.2s ease;
}

.dropdown-button:hover {
    opacity: 0.8;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: #0E1350;
    min-width: 200px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    padding-top: 4px;
}

.dropdown-content::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 14px;
}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 12px 16px;
    color: #29FBCD;
    text-decoration: none;
    font-family: 'Unbounded', sans-serif;
    font-size: 12px;
    font-weight: 400;
    transition: background 0.2s ease;
}

.dropdown-item:hover {
    background: rgba(41, 251, 205, 0.1);
}

.dropdown-item.active {
    color: #B74CFF;
}

/* ── Side menu (mobile) ── */

.side-menu-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.side-menu-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.side-menu {
    position: fixed;
    top: 0; right: -280px; bottom: 0;
    width: 280px;
    background: #0E1350;
    z-index: 1200;
    transition: right 0.3s ease;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.side-menu.open {
    right: 0;
}

.side-menu-close {
    position: absolute;
    top: 12px; right: 16px;
    background: none; border: none;
    color: white; font-size: 28px;
    cursor: pointer;
}

.side-menu-logo {
    margin-bottom: 32px;
}

.side-menu-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.side-menu-link {
    color: #29FBCD;
    text-decoration: none;
    font-family: 'Unbounded', sans-serif;
    font-size: 14px;
    font-weight: 400;
    padding: 12px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.side-menu-link:hover {
    background: rgba(41, 251, 205, 0.1);
}

.side-menu-link.active {
    color: #B74CFF;
}

/* ── Hamburger ── */

.hamburger-button {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    flex-direction: column;
    gap: 5px;
}

.hamburger-line {
    display: block;
    width: 24px;
    height: 2px;
    background: #29FBCD;
    border-radius: 2px;
}

/* ── Container ── */

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 76px 20px 20px;
}

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

.title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.title {
    font-size: clamp(1.4rem, 5vw, 2rem);
    font-weight: 700;
    background: linear-gradient(135deg, #B74CFF, #29FBCD);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.75rem;
    font-weight: 300;
    color: rgba(255,255,255,0.5);
}

/* ── Size selector ── */

.size-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 16px;
}

.size-label-text {
    font-size: 0.7rem;
    font-weight: 400;
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
}

.size-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 180px;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #B74CFF;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.size-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.size-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #B74CFF;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
    cursor: pointer;
}

.size-display {
    font-family: 'Unbounded', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: #B74CFF;
    min-width: 52px;
    text-align: center;
}

/* ── Puzzle name input ── */

.name-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.name-label {
    font-size: 0.7rem;
    font-weight: 400;
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
}

.name-input {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    font-family: 'Unbounded', sans-serif;
    font-size: 0.75rem;
    font-weight: 400;
    padding: 8px 14px;
    border-radius: 6px;
    outline: none;
    width: 220px;
    transition: border-color 0.2s ease;
}

.name-input::placeholder {
    color: rgba(255,255,255,0.25);
}

.name-input:focus {
    border-color: #B74CFF;
}

/* ── Editor area ── */

.editor-area {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.board-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

#editorCanvas {
    cursor: crosshair;
    touch-action: none;
    border-radius: 4px;
}

/* ── Toolbar ── */

.toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.tool-group {
    display: flex;
    gap: 6px;
}

.tool-button {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.6);
    font-family: 'Unbounded', sans-serif;
    font-size: 0.7rem;
    font-weight: 400;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tool-button:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.tool-button.active {
    background: rgba(183,76,255,0.2);
    border-color: #B74CFF;
    color: #B74CFF;
}

.tool-fill-icon {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: currentColor;
    border-radius: 2px;
}

.tool-erase-icon {
    font-size: 0.9rem;
}

.action-button {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.6);
    font-family: 'Unbounded', sans-serif;
    font-size: 0.85rem;
    padding: 7px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-button:hover:not(:disabled) {
    background: rgba(255,255,255,0.1);
    color: white;
}

.action-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.action-button.danger {
    font-size: 0.7rem;
    color: #ff6b6b;
    border-color: rgba(255,107,107,0.2);
}

.action-button.danger:hover {
    background: rgba(255,107,107,0.1);
    color: #ff6b6b;
}

/* ── Preview section ── */

.clue-preview-section {
    text-align: center;
    margin-bottom: 40px;
}

.section-title {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: rgba(255,255,255,0.85);
}

.section-desc {
    font-size: 0.65rem;
    font-weight: 300;
    color: rgba(255,255,255,0.4);
    margin-bottom: 16px;
}

.preview-container {
    display: flex;
    justify-content: center;
}

#previewCanvas {
    border-radius: 4px;
}

/* ── Actions section ── */

.actions-section {
    margin-bottom: 48px;
}

.actions-section .section-title {
    text-align: center;
    margin-bottom: 20px;
}

.action-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.action-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 20px;
}

.action-card h3 {
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: rgba(255,255,255,0.85);
}

.action-card p {
    font-size: 0.6rem;
    font-weight: 300;
    color: rgba(255,255,255,0.4);
    margin-bottom: 14px;
    line-height: 1.5;
}

.primary-btn {
    background: rgba(183,76,255,0.15);
    border: 1px solid rgba(183,76,255,0.3);
    color: #B74CFF;
    font-family: 'Unbounded', sans-serif;
    font-size: 0.65rem;
    font-weight: 400;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.primary-btn:hover {
    background: rgba(183,76,255,0.25);
    border-color: #B74CFF;
}

/* Share link output */

.share-link-output {
    display: flex;
    gap: 6px;
    margin-top: 12px;
}

.link-input {
    flex: 1;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
    font-family: monospace;
    font-size: 0.55rem;
    padding: 8px;
    border-radius: 6px;
    outline: none;
    min-width: 0;
}

.copy-btn {
    background: #29FBCD;
    border: none;
    color: #000;
    font-family: 'Unbounded', sans-serif;
    font-size: 0.6rem;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.copy-btn:hover {
    opacity: 0.85;
}

/* ── SEO content ── */

.seo-content {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 48px 20px;
}

.seo-inner {
    max-width: 700px;
    margin: 0 auto;
}

.seo-content h2 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 12px;
    margin-top: 32px;
    color: rgba(255,255,255,0.85);
}

.seo-content h2:first-child {
    margin-top: 0;
}

.seo-content p {
    font-size: 0.7rem;
    font-weight: 300;
    line-height: 1.8;
    color: rgba(255,255,255,0.5);
    margin-bottom: 16px;
}

/* ── Print styles ── */

.print-page {
    display: none;
}

@media print {
    body > *:not(.print-page) {
        display: none !important;
    }

    .print-page {
        display: block !important;
        background: white;
        color: black;
        text-align: center;
        padding: 40px 20px;
    }

    .print-header {
        margin-bottom: 24px;
    }

    .print-title {
        font-family: 'Unbounded', sans-serif;
        font-size: 24px;
        font-weight: 700;
        margin-bottom: 4px;
        color: #000;
    }

    .print-subtitle {
        font-family: 'Unbounded', sans-serif;
        font-size: 14px;
        font-weight: 300;
        color: #666;
    }

    #printCanvas {
        margin: 0 auto;
    }

    .print-footer {
        margin-top: 24px;
        font-family: 'Unbounded', sans-serif;
        font-size: 10px;
        color: #aaa;
    }
}

/* ── Play mode ── */

.play-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 76px 20px 20px;
}

.play-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.play-size {
    font-size: 0.7rem;
    font-weight: 400;
    color: rgba(255,255,255,0.5);
}

.play-timer {
    font-size: 0.75rem;
    font-weight: 500;
    color: #29FBCD;
    font-variant-numeric: tabular-nums;
}

.play-board-area {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

#playCanvas {
    cursor: pointer;
    touch-action: none;
    border-radius: 4px;
}

.play-toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.play-check-section {
    text-align: center;
    margin-bottom: 32px;
}

.check-btn {
    background: linear-gradient(135deg, rgba(41, 251, 205, 0.15), rgba(183, 76, 255, 0.15));
    border: 1px solid rgba(41, 251, 205, 0.3);
    color: #29FBCD;
    font-family: 'Unbounded', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 12px 32px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.check-btn:hover {
    background: linear-gradient(135deg, rgba(41, 251, 205, 0.25), rgba(183, 76, 255, 0.25));
    border-color: #29FBCD;
}

.check-result {
    font-size: 0.75rem;
    font-weight: 400;
    margin-top: 14px;
    min-height: 1.2em;
}

.check-result.success {
    color: #29FBCD;
}

.check-result.error {
    color: #ff6b6b;
}

.play-footer-links {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
    padding: 24px 0;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.play-link {
    color: #B74CFF;
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 400;
    transition: opacity 0.2s;
}

.play-link:hover {
    opacity: 0.8;
}

/* Win overlay */
.win-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    opacity: 0;
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.win-card {
    background: linear-gradient(135deg, #0E1350, #1a1a3e);
    border: 1px solid rgba(41,251,205,0.3);
    border-radius: 16px;
    padding: 40px 48px;
    text-align: center;
    max-width: 380px;
    width: 90%;
}

.win-card h2 {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, #29FBCD, #B74CFF);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.win-card .win-time {
    font-size: 0.8rem;
    font-weight: 300;
    color: rgba(255,255,255,0.6);
    margin-bottom: 24px;
}

.win-card .win-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.win-card .win-btn {
    display: block;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-family: 'Unbounded', sans-serif;
    font-size: 0.7rem;
    font-weight: 400;
    cursor: pointer;
    transition: opacity 0.2s;
    border: none;
}

.win-card .win-btn.primary {
    background: #29FBCD;
    color: #000;
    font-weight: 500;
}

.win-card .win-btn.secondary {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.7);
    border: 1px solid rgba(255,255,255,0.1);
}

.win-card .win-btn:hover {
    opacity: 0.85;
}

/* ── Responsive ── */

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

    .hamburger-button {
        display: flex;
    }

    .container {
        padding: 68px 12px 16px;
    }

    .play-container {
        padding: 68px 12px 16px;
    }

    .action-cards {
        grid-template-columns: 1fr;
    }

    .size-selector {
        flex-direction: column;
        gap: 8px;
    }

    .name-row {
        flex-direction: column;
        gap: 6px;
    }

    .name-input {
        width: 100%;
    }
}

@media (max-width: 400px) {
    .toolbar {
        gap: 8px;
    }

    .tool-button {
        padding: 7px 10px;
        font-size: 0.65rem;
    }
}
