/* =============================================
   GomokuHub - Stylesheet
   ============================================= */

/* The HTML `hidden` attribute must always win over component display rules. */
[hidden] { display: none !important; }

:root {
    --bg: #f6f1e7;
    --bg-soft: #efe7d4;
    --paper: #ffffff;
    --ink: #1f1d18;
    --ink-soft: #555048;
    --accent: #8b3a1d;
    --accent-dark: #6a2c16;
    --line: #2c2620;
    --board: #e8b878;
    --board-dark: #d4a25a;
    --black: #1c1a17;
    --white: #f8f4ec;
    --shadow: 0 4px 18px rgba(40, 28, 16, 0.08);
    --radius: 10px;
    --maxw: 1140px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-serif: "Georgia", "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

.container {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 24px;
}

/* ====================== Header ====================== */
.site-header {
    background: var(--paper);
    border-bottom: 1px solid #e2d8c4;
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    padding-bottom: 14px;
    gap: 16px;
    flex-wrap: wrap;
}
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.logo:hover { text-decoration: none; }
.logo-mark {
    font-size: 1.3rem;
    letter-spacing: -2px;
}
.main-nav {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    font-size: 0.95rem;
}
.main-nav a {
    color: var(--ink-soft);
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
}
.main-nav a:hover {
    color: var(--accent);
    text-decoration: none;
}
.main-nav a.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ====================== Hero ====================== */
.hero {
    background: linear-gradient(135deg, var(--bg-soft) 0%, var(--bg) 100%);
    padding: 64px 0;
    border-bottom: 1px solid #e2d8c4;
}
.hero-inner {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 48px;
    align-items: center;
}
.hero h1 {
    font-family: var(--font-serif);
    font-size: 2.6rem;
    line-height: 1.15;
    margin: 0 0 16px;
    color: var(--ink);
    letter-spacing: -0.02em;
}
.hero .lead {
    font-size: 1.1rem;
    color: var(--ink-soft);
    margin: 0 0 28px;
}
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }

/* ====================== Buttons ====================== */
.btn {
    display: inline-block;
    padding: 12px 22px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.98rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.06s ease, background 0.15s ease, color 0.15s ease;
    text-align: center;
    font-family: inherit;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent-dark); color: white; }
.btn-secondary {
    background: transparent;
    color: var(--ink);
    border-color: var(--ink);
}
.btn-secondary:hover { background: var(--ink); color: var(--paper); }

/* ====================== Mini Board (hero art) ====================== */
.hero-art { display: flex; justify-content: center; }
.board-mini {
    background: var(--board);
    border: 6px solid #6e4a25;
    border-radius: 6px;
    padding: 10px;
    box-shadow: var(--shadow);
}
.mini-row {
    display: flex;
}
.mini-row span {
    width: 28px;
    height: 28px;
    border-right: 1px solid #7a5a30;
    border-bottom: 1px solid #7a5a30;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.mini-row span:nth-child(8n) { border-right: none; }
.mini-row:nth-child(8n) span { border-bottom: none; }
.mini-row span::after {
    content: "";
    width: 22px;
    height: 22px;
    border-radius: 50%;
}
.mini-row span.b::after { background: var(--black); }
.mini-row span.w::after { background: var(--white); box-shadow: inset 0 0 0 1px #6a5a40; }

/* ====================== Sections ====================== */
section { padding: 56px 0; }
section h2 {
    font-family: var(--font-serif);
    font-size: 1.9rem;
    margin: 0 0 24px;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.section-intro { color: var(--ink-soft); margin-top: -8px; margin-bottom: 28px; }

/* ====================== Features ====================== */
.features { background: var(--paper); }
.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
}
.feature-card {
    background: var(--bg);
    border: 1px solid #e2d8c4;
    padding: 24px;
    border-radius: var(--radius);
}
.feature-card h3 { margin-top: 0; }

/* ====================== Articles Grid ====================== */
.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 22px;
}
.article-card {
    background: var(--paper);
    border: 1px solid #e2d8c4;
    border-radius: var(--radius);
    padding: 24px;
    color: var(--ink);
    transition: transform 0.1s ease, box-shadow 0.15s ease;
    display: block;
}
.article-card:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: #c7b793;
}
.article-card h3 { margin-top: 0; color: var(--ink); }
.article-card p { color: var(--ink-soft); }
.article-card .read-more {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.95rem;
}

/* ====================== FAQ ====================== */
.faq { background: var(--paper); border-top: 1px solid #e2d8c4; }
.faq-list { display: grid; gap: 12px; max-width: 800px; }
.faq details {
    background: var(--bg);
    border: 1px solid #e2d8c4;
    border-radius: var(--radius);
    padding: 14px 18px;
}
.faq summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--ink);
}
.faq details[open] { box-shadow: var(--shadow); }
.faq p { margin: 10px 0 0; color: var(--ink-soft); }

/* ====================== Footer ====================== */
.site-footer {
    background: #2a241d;
    color: #d6c9ad;
    padding: 48px 0 24px;
    margin-top: 48px;
}
.footer-inner {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid #4a3f30;
}
.site-footer h4 {
    color: white;
    margin: 0 0 12px;
    font-size: 1rem;
}
.site-footer a {
    color: #d6c9ad;
    display: block;
    padding: 4px 0;
}
.site-footer a:hover { color: white; }
.site-footer strong { color: white; font-size: 1.2rem; }
.footer-bottom {
    padding-top: 18px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.9rem;
    color: #a59a7e;
}

/* ====================== Page Header ====================== */
.page-header {
    background: linear-gradient(135deg, var(--bg-soft) 0%, var(--bg) 100%);
    border-bottom: 1px solid #e2d8c4;
    padding: 48px 0 32px;
}
.page-header h1 {
    font-family: var(--font-serif);
    font-size: 2.3rem;
    margin: 0 0 8px;
    letter-spacing: -0.01em;
}
.page-header .lead { color: var(--ink-soft); margin: 0; font-size: 1.05rem; }

/* ====================== Article (long-form) ====================== */
.article { padding: 32px 0 64px; }
.article-wrap { max-width: 780px; }
.breadcrumb { font-size: 0.9rem; color: var(--ink-soft); margin-bottom: 14px; }
.breadcrumb a { color: var(--ink-soft); }
.article-header { margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid #e2d8c4; }
.article-header h1 {
    font-family: var(--font-serif);
    font-size: 2.3rem;
    margin: 0 0 6px;
    letter-spacing: -0.01em;
    line-height: 1.2;
}
.article-meta { color: var(--ink-soft); font-size: 0.9rem; margin: 0; }
.article-body { font-size: 1.06rem; line-height: 1.75; color: #2a261f; }
.article-body .lead {
    font-size: 1.18rem;
    color: var(--ink);
    font-family: var(--font-serif);
    line-height: 1.5;
    margin: 0 0 28px;
    padding: 0 0 18px;
    border-bottom: 1px dashed #d8c8a4;
}
.article-body h2 {
    font-family: var(--font-serif);
    font-size: 1.55rem;
    margin-top: 38px;
    margin-bottom: 14px;
    color: var(--ink);
}
.article-body h3 {
    font-size: 1.2rem;
    margin-top: 26px;
    margin-bottom: 8px;
    color: var(--ink);
}
.article-body p, .article-body li { margin: 0 0 12px; }
.article-body ul, .article-body ol { padding-left: 22px; }
.article-body strong { color: var(--ink); }

.compare-table-wrap { overflow-x: auto; margin: 18px 0; }
.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.97rem;
    background: var(--paper);
    border: 1px solid #e2d8c4;
    border-radius: var(--radius);
    overflow: hidden;
}
.compare-table th, .compare-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #e2d8c4;
    vertical-align: top;
}
.compare-table thead { background: var(--bg-soft); }
.compare-table th { color: var(--ink); font-weight: 700; }
.compare-table tr:last-child td { border-bottom: none; }

.related-articles {
    margin-top: 48px;
    padding: 22px;
    background: var(--bg-soft);
    border-radius: var(--radius);
    border-left: 4px solid var(--accent);
}
.related-articles h3 { margin-top: 0; }
.related-articles ul { list-style: none; padding: 0; margin: 0; }
.related-articles li { padding: 4px 0; }

/* ====================== Play Page ====================== */
.play-body { background: var(--bg); }
.play-main { padding: 32px 0 56px; }
.play-container h1 {
    font-family: var(--font-serif);
    font-size: 2.1rem;
    margin: 0 0 8px;
    letter-spacing: -0.01em;
}
.play-container .lead { color: var(--ink-soft); margin: 0 0 28px; }

.game-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 28px;
    align-items: start;
}
.game-sidebar { display: flex; flex-direction: column; gap: 18px; }
.panel {
    background: var(--paper);
    border: 1px solid #e2d8c4;
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
.panel h2 {
    font-size: 1.05rem;
    margin: 0 0 12px;
    color: var(--ink);
    font-family: var(--font);
    letter-spacing: 0;
}
.panel label {
    display: block;
    font-size: 0.9rem;
    color: var(--ink-soft);
    margin-bottom: 12px;
}
.panel select {
    display: block;
    width: 100%;
    padding: 8px 10px;
    margin-top: 4px;
    border-radius: 6px;
    border: 1px solid #c7b793;
    background: var(--bg);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--ink);
}
.buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.buttons .btn { flex: 1; padding: 10px 14px; font-size: 0.92rem; }
.status { margin: 0 0 6px; font-weight: 600; color: var(--ink); }
.moves-info { margin: 0; font-size: 0.88rem; color: var(--ink-soft); }
.quick-guide { padding-left: 18px; margin: 0; font-size: 0.92rem; color: var(--ink-soft); }
.quick-guide li { margin-bottom: 6px; }

.board-wrap {
    position: relative;
    background: var(--paper);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid #e2d8c4;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: center;
}
#board {
    width: 100%;
    max-width: 600px;
    height: auto;
    aspect-ratio: 1 / 1;
    cursor: crosshair;
    display: block;
    border-radius: 6px;
}

.game-overlay {
    position: absolute;
    inset: 0;
    background: rgba(31, 29, 24, 0.78);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 5;
}
.overlay-box {
    background: var(--paper);
    padding: 32px 28px;
    border-radius: var(--radius);
    text-align: center;
    max-width: 360px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.overlay-box h2 { font-family: var(--font-serif); margin-top: 0; font-size: 1.6rem; }
.overlay-box p { color: var(--ink-soft); margin: 0 0 18px; }

.play-articles { margin-top: 56px; }

/* ====================== Responsive ====================== */
@media (max-width: 900px) {
    .hero-inner { grid-template-columns: 1fr; }
    .hero h1 { font-size: 2rem; }
    .feature-grid { grid-template-columns: 1fr; }
    .footer-inner { grid-template-columns: 1fr; }
    .game-layout { grid-template-columns: 1fr; }
    .game-sidebar { order: 2; }
    .board-wrap { order: 1; }
    .article-header h1 { font-size: 1.8rem; }
    .main-nav { gap: 12px; font-size: 0.9rem; }
    .hero { padding: 40px 0; }
    section { padding: 40px 0; }
}
@media (max-width: 600px) {
    .container { padding: 0 16px; }
    .header-inner { flex-direction: column; align-items: flex-start; }
    .main-nav { width: 100%; }
    .hero h1 { font-size: 1.75rem; }
    .article-header h1 { font-size: 1.55rem; }
    .panel { padding: 14px 16px; }
    .board-wrap { padding: 8px; }
}
