:root {
    --page-bg: #f5f6f7;
    --surface: #ffffff;
    --surface-muted: #f8f9fa;
    --text: #20252b;
    --text-muted: #66707a;
    --line: #dfe3e7;
    --line-strong: #c9d0d7;
    --accent: #315f91;
    --accent-dark: #24496f;
    --danger: #a04444;
    --content-width: 1180px;
    --header-height: 64px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--page-bg);
    color: var(--text);
    font-family: "Noto Sans KR", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.65;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.site-container {
    width: min(100% - 32px, var(--content-width));
    margin-inline: auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    flex: 0 0 auto;
    background: rgba(255, 255, 255, 0.97);
    border-bottom: 1px solid var(--line);
}

.header-inner {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 28px;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.04em;
}

.brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    color: var(--accent);
    background: #fff;
}

.brand-accent {
    color: var(--accent);
}

#main-navigation {
    min-width: 0;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}

#main-navigation .gnb-item {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0;
}

#main-navigation .gnb-item > a {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 100%;
    padding: 0 11px;
    color: #3d4650;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
}

#main-navigation .gnb-item > a:hover,
#main-navigation .gnb-item > a:focus-visible {
    color: var(--accent-dark);
    border-bottom-color: var(--accent);
    outline: none;
}

.gnb-sub {
    display: none;
    position: absolute;
    top: calc(100% - 1px);
    left: 0;
    min-width: 190px;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: 0 8px 20px rgba(34, 42, 50, 0.09);
}

.gnb-item:hover .gnb-sub,
.gnb-item:focus-within .gnb-sub {
    display: block;
}

.gnb-sub a {
    display: block !important;
    height: auto !important;
    padding: 9px 11px !important;
    color: #4c5660 !important;
    font-size: 13px !important;
    border: 0 !important;
}

.gnb-sub a:hover,
.gnb-sub a:focus-visible {
    background: var(--surface-muted);
    color: var(--accent-dark) !important;
}

.header-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.site-clock {
    color: var(--text-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.mobile-menu-button {
    display: none;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
    color: #3d4650;
}

#mobile-menu {
    position: absolute;
    top: var(--header-height);
    left: 0;
    width: 100%;
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

#mobile-menu > div {
    border-bottom: 1px solid #edf0f2;
}

#mobile-menu > div > div:first-child {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 16px;
    background: #fff;
}

#mobile-menu a {
    display: block;
    padding: 12px 16px;
}

#mobile-menu button {
    margin-left: auto;
    border: 0;
    background: transparent;
    color: var(--text-muted);
}

.mobile-sub {
    background: var(--surface-muted);
}

.site-main {
    width: min(100% - 32px, var(--content-width));
    margin: 0 auto;
    padding: 28px 0 42px;
    flex: 1 0 auto;
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 34px;
    align-items: start;
}

.site-sidebar {
    min-width: 0;
}

.sidebar-section {
    padding: 18px 0;
    border-top: 1px solid var(--line-strong);
}

.sidebar-section:first-child {
    border-top: 2px solid #616b75;
}

.sidebar-heading {
    margin: 0 0 12px;
    font-size: 15px;
    line-height: 1.4;
    font-weight: 700;
}

.sidebar-heading a {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-heading a:hover {
    color: var(--accent-dark);
}

#sidebar-roadmap {
    margin: 0;
    padding: 0;
    list-style: none;
}

#sidebar-roadmap li {
    margin: 0;
}

#sidebar-roadmap a {
    display: block;
    padding: 7px 4px;
    color: #58616a;
    font-size: 13px;
    border-bottom: 1px solid #eceff1;
}

#sidebar-roadmap a:hover {
    color: var(--accent-dark);
    background: #fafbfc;
}

.practice-panel {
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
    padding: 15px;
}

.practice-panel h3 {
    margin: 0 0 4px;
    font-size: 15px;
}

.practice-description {
    min-height: 39px;
    margin: 0 0 13px;
    color: var(--text-muted);
    font-size: 12px;
}

.game-screen {
    position: relative;
}

.game-primary-button,
.game-secondary-button {
    width: 100%;
    min-height: 38px;
    border-radius: 3px;
    font-weight: 600;
}

.game-primary-button {
    border: 1px solid var(--accent-dark);
    background: var(--accent);
    color: #fff;
}

.game-primary-button:hover {
    background: var(--accent-dark);
}

.game-secondary-button {
    margin-top: 9px;
    border: 1px solid var(--line-strong);
    background: #fff;
    color: #3b444c;
}

.game-secondary-button:hover {
    background: var(--surface-muted);
}

.game-score-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 12px;
}

.game-problem {
    min-height: 68px;
    display: grid;
    place-items: center;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    background: var(--surface-muted);
    font-size: 25px;
    font-weight: 700;
}

.game-input {
    width: 100%;
    height: 40px;
    border: 1px solid var(--line-strong);
    border-radius: 3px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
}

.game-input:focus {
    outline: 2px solid rgba(49, 95, 145, 0.18);
    border-color: var(--accent);
}

.game-end {
    text-align: center;
}

.game-final-score {
    margin: 6px 0 12px;
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-dark);
}

.ttt-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-bottom: 9px;
}

.ttt-cell {
    aspect-ratio: 1;
    border: 1px solid var(--line-strong);
    border-radius: 2px;
    background: #fff;
    color: #26313a;
    font-size: 22px;
    font-weight: 700;
}

.ttt-cell:hover {
    background: var(--surface-muted);
}

.game-status {
    min-height: 29px;
    padding: 5px 8px;
    margin-bottom: 8px;
    background: var(--surface-muted);
    border: 1px solid var(--line);
    text-align: center;
    font-size: 12px;
    font-weight: 600;
}

.game-info-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 7px;
    color: var(--text-muted);
    font-size: 12px;
}

.p2048-board,
.slide-board-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    padding: 6px;
    border: 1px solid var(--line-strong);
    background: #e7eaed;
    overflow: hidden;
    touch-action: none;
}

.p2048-background,
.slide-grid {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 5px;
}

.p2048-background span {
    border: 1px solid #d4d9de;
    background: #f5f6f7;
}

/* 슬라이딩 숫자 퍼즐: 밝은 배경에서도 숫자가 선명하게 보이도록 구성 */
.slide-tile,
.slide-empty-cell {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    border-radius: 4px;
}

.slide-tile {
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: 1px solid #aeb8c2;
    background: #ffffff;
    color: #26313a;
    box-shadow: 0 1px 2px rgba(32, 37, 43, 0.12);
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    cursor: default;
    user-select: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.slide-tile:disabled {
    opacity: 1;
}

.slide-tile-correct {
    border-color: #9fb4c9;
    background: #eaf1f7;
    color: #24496f;
}

.slide-tile-movable {
    border-color: var(--accent);
    background: #ffffff;
    color: #173f66;
    box-shadow: inset 0 0 0 1px rgba(49, 95, 145, 0.18), 0 1px 2px rgba(32, 37, 43, 0.12);
    cursor: pointer;
}

.slide-tile-movable:hover {
    background: #edf4fa;
}

.slide-tile-movable:active {
    transform: translateY(1px);
}

.slide-tile-movable:focus-visible {
    outline: 3px solid rgba(49, 95, 145, 0.28);
    outline-offset: 1px;
}

.slide-empty-cell {
    border: 1px dashed #aab3bc;
    background: #cfd6dc;
}

#p2048-tile-container {
    position: absolute;
    inset: 0;
    padding: 6px;
    z-index: 2;
}

.game-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.94);
    text-align: center;
}

.game-overlay strong {
    margin-bottom: 10px;
    font-size: 18px;
}

.game-help {
    margin: 7px 0 0;
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
}

.sidebar-ad {
    min-height: 120px;
}

.content-column {
    min-width: 0;
}

.content-frame {
    min-height: 540px;
    padding: 0 0 24px;
}

.home-intro {
    padding: 34px 0 32px;
    border-top: 2px solid #616b75;
    border-bottom: 1px solid var(--line);
}

.home-eyebrow {
    margin: 0 0 10px;
    color: var(--accent-dark);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.home-intro h1 {
    margin: 0;
    max-width: 760px;
    font-size: clamp(30px, 4vw, 46px);
    line-height: 1.25;
    letter-spacing: -0.05em;
    font-weight: 700;
}

.home-summary {
    max-width: 720px;
    margin: 17px 0 0;
    color: #58616a;
    font-size: 16px;
}

.home-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 22px;
}

.text-link-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 39px;
    padding: 0 15px;
    border: 1px solid var(--line-strong);
    border-radius: 3px;
    background: #fff;
    color: #38424b;
    font-weight: 600;
}

.text-link-button.primary {
    border-color: var(--accent-dark);
    background: var(--accent);
    color: #fff;
}

.text-link-button:hover {
    background: var(--surface-muted);
}

.text-link-button.primary:hover {
    background: var(--accent-dark);
}

.home-section {
    padding: 30px 0;
    border-bottom: 1px solid var(--line);
}

.home-section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 15px;
}

.home-section h2 {
    margin: 0;
    font-size: 21px;
    letter-spacing: -0.03em;
}

.home-section-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}

.home-link-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid var(--line);
}

.home-link-item {
    min-height: 98px;
    padding: 18px 18px 16px 0;
    border-bottom: 1px solid var(--line);
}

.home-link-item:nth-child(odd) {
    padding-right: 24px;
    border-right: 1px solid var(--line);
}

.home-link-item:nth-child(even) {
    padding-left: 24px;
}

.home-link-item a {
    display: block;
}

.home-link-item strong {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #28323b;
    font-size: 16px;
}

.home-link-item a:hover strong {
    color: var(--accent-dark);
}

.home-link-item p {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

.home-note {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 28px;
    align-items: start;
    padding: 25px 0 0;
}

.home-note h2 {
    margin: 0 0 8px;
    font-size: 17px;
}

.home-note p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}

.home-note-meta {
    min-width: 180px;
    padding-left: 20px;
    border-left: 1px solid var(--line);
    color: var(--text-muted);
    font-size: 12px;
}

.home-note-meta strong {
    display: block;
    margin-bottom: 4px;
    color: #343d45;
}

#page-view {
    min-width: 0;
}

#page-view > :first-child {
    margin-top: 0;
}

.site-footer {
    flex: 0 0 auto;
    padding: 13px 0 15px;
    background: #252a2f;
    color: #c5cbd0;
    border-top: 1px solid #171b1f;
    font-size: 12px;
}

.footer-lines {
    display: grid;
    gap: 5px;
}

.footer-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-width: 0;
}

.footer-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 13px;
    min-width: 0;
}

.footer-title {
    color: #fff;
    font-weight: 700;
}

.footer-muted {
    color: #919aa2;
}

.footer-bottom-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px 14px;
    min-width: 0;
}

.footer-ai-note {
    color: #aeb6bc;
    font-size: 11px;
}

.footer-value {
    color: #e3e7ea;
    font-variant-numeric: tabular-nums;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.footer-links button,
.footer-links a {
    padding: 0;
    border: 0;
    background: transparent;
    color: #b8c0c6;
    font-size: 12px;
}

.footer-links button:hover,
.footer-links a:hover {
    color: #fff;
}

.footer-separator {
    color: #5e666d;
}

@media (max-width: 1050px) {
    #main-navigation {
        gap: 0;
    }

    #main-navigation .gnb-item > a {
        padding-inline: 8px;
        font-size: 13px;
    }

    .site-clock {
        display: none;
    }
}

@media (max-width: 860px) {
    .site-header {
        height: 58px;
    }

    :root {
        --header-height: 58px;
    }

    #main-navigation {
        display: none;
    }

    .mobile-menu-button {
        display: inline-grid;
        place-items: center;
    }

    .header-inner {
        justify-content: space-between;
    }

    .site-main {
        grid-template-columns: 1fr;
        gap: 28px;
        padding-top: 20px;
    }

    .content-column {
        order: 1;
    }

    .site-sidebar {
        order: 2;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 20px;
    }

    .sidebar-section {
        border-top: 1px solid var(--line-strong);
    }

    .sidebar-roadmap-section,
    .sidebar-ad-section {
        display: none;
    }

    .practice-section {
        grid-column: 1 / -1;
    }

    .practice-panel {
        max-width: 420px;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 14px;
    }

    .site-container,
    .site-main {
        width: min(100% - 24px, var(--content-width));
    }

    .brand-mark {
        width: 31px;
        height: 31px;
    }

    .site-brand {
        font-size: 17px;
    }

    .home-intro {
        padding: 25px 0 24px;
    }

    .home-intro h1 {
        font-size: 29px;
    }

    .home-summary {
        font-size: 14px;
    }

    .home-section-header {
        display: block;
    }

    .home-section-header p {
        margin-top: 5px;
    }

    .home-link-list {
        grid-template-columns: 1fr;
    }

    .home-link-item,
    .home-link-item:nth-child(odd),
    .home-link-item:nth-child(even) {
        padding: 15px 0;
        border-right: 0;
    }

    .home-note {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .home-note-meta {
        padding: 12px 0 0;
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .site-sidebar {
        display: block;
    }

    .practice-panel {
        max-width: none;
    }

    .footer-line {
        align-items: flex-start;
    }

    .footer-line:first-child {
        display: block;
    }

    .footer-line:first-child .footer-group + .footer-group {
        margin-top: 4px;
    }

    .footer-line:last-child {
        gap: 10px;
    }

    .footer-bottom-info {
        display: block;
    }

    .footer-ai-note {
        margin-top: 3px;
        line-height: 1.45;
    }

    .footer-copyright {
        white-space: normal;
    }
}
