:root {
    color-scheme: light;
    --bg: #f7f4ee;
    --surface: #fffdfa;
    --ink: #282a28;
    --muted: #686c67;
    --line: #dedbd3;
    --accent: #40755c;
    --accent-dark: #2f5d48;
    --accent-soft: #e5efe8;
    --shadow: 0 16px 40px rgba(52, 48, 40, 0.08);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 10% 0%, rgba(227, 185, 117, 0.18), transparent 28rem),
        var(--bg);
    font-family: Pretendard, "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}
body.modal-open { overflow: hidden; }

button { font: inherit; }

.app-shell {
    width: min(100% - 32px, 680px);
    margin: 0 auto;
    padding: 54px 0 40px;
}
.hub-link { display: inline-block; margin: 0 4px 12px; color: var(--muted); font-size: .8rem; font-weight: 700; text-decoration: none; }
.hub-link:hover, .hub-link:focus-visible { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 3px; }

.hero { padding: 0 4px 26px; }
.brand, .eyebrow { margin: 0 0 7px; color: var(--accent); font-size: .78rem; font-weight: 800; letter-spacing: .08em; }
h1 { margin: 0; font-size: clamp(2rem, 9vw, 3.15rem); line-height: 1.15; letter-spacing: -.055em; }
.subtitle { margin: 14px 0 0; font-size: 1.1rem; font-weight: 700; }
.intro { color: var(--muted); }
.intro { margin: 5px 0 0; }
.service-usage { margin: 11px 0 0; color: var(--muted); font-size: .8rem; }
.service-usage strong { color: var(--accent-dark); font-variant-numeric: tabular-nums; }

.panel {
    border: 1px solid rgba(222, 219, 211, .9);
    border-radius: 24px;
    background: rgba(255, 253, 250, .94);
    box-shadow: var(--shadow);
}
.draw-panel, .results-panel { padding: 24px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
h2 { margin: 0; font-size: 1.24rem; letter-spacing: -.025em; }
.random-note { margin: 7px 0 0; color: var(--muted); font-size: .88rem; }
button:focus-visible { outline: 3px solid rgba(64, 117, 92, .28); outline-offset: 2px; }
.copy-status { margin: 0; color: var(--accent-dark); font-size: .84rem; font-weight: 700; }

.draw-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.primary-button, .secondary-button, .compact-button {
    min-height: 52px;
    border-radius: 15px;
    cursor: pointer;
    font-weight: 800;
}
.primary-button { border: 1px solid var(--accent-dark); color: #fff; background: var(--accent-dark); }
.secondary-button { border: 1px solid #b8c7be; color: var(--accent-dark); background: var(--accent-soft); }
.primary-button:hover, .secondary-button:hover, .compact-button:hover { filter: brightness(.97); }

.results-panel { margin-top: 16px; }
.results-heading { align-items: center; }
.compact-button { min-height: 40px; padding: 0 14px; border: 1px solid var(--line); color: var(--ink); background: #fff; font-size: .84rem; }
.game-list { display: grid; gap: 12px; margin-top: 20px; }
.game { padding: 16px; border-radius: 17px; background: #f5f3ee; }
.game-title { margin: 0 0 11px; color: var(--muted); font-size: .8rem; font-weight: 800; }
.balls { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
.ball {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    max-width: 48px;
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 50%;
    color: #272925;
    background: #e8d58f;
    font-size: clamp(.78rem, 3.3vw, .94rem);
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 3px 7px rgba(40, 38, 32, .1);
}
.ball.range-2 { background: #b9d4d8; }
.ball.range-3 { background: #dfb9ad; }
.ball.range-4 { background: #c9cbd0; }
.ball.range-5 { background: #b8d0ae; }
.results-footer { margin-top: 16px; text-align: center; }
.full-button { width: 100%; }
.copy-status { min-height: 1.3em; margin-top: 8px; }
.notice { padding: 24px 10px 0; color: #777a75; font-size: .78rem; text-align: center; }
.notice p { margin: 0; }
.footer-nav { margin-top: 15px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; }
.footer-nav button { padding: 2px; border: 0; color: inherit; background: none; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.modal-layer { position: fixed; inset: 0; z-index: 1000; padding: 20px; display: grid; place-items: center; }
.modal-layer[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(35, 34, 31, .62); }
.modal-dialog { position: relative; width: min(500px, 100%); max-height: calc(100dvh - 40px); overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: 0 22px 70px rgba(0,0,0,.25); outline: none; }
.modal-header { padding: 17px 19px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 1.12rem; }
.modal-close { width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; color: var(--muted); background: #f0ede7; cursor: pointer; font-size: 1.45rem; line-height: 1; }
.modal-content { padding: 18px 19px 20px; max-height: calc(100dvh - 120px); overflow-y: auto; overscroll-behavior: contain; color: var(--muted); font-size: .9rem; line-height: 1.7; overflow-wrap: anywhere; }
.modal-content p { margin: 0 0 1em; }
.modal-content p:last-child { margin-bottom: 0; }
.modal-content ol, .modal-content ul { margin: 0 0 1em; padding-left: 1.35em; }
.modal-content li + li { margin-top: .35em; }
.sitemap-list { display: grid; gap: 8px; margin: 0 !important; padding: 0 !important; list-style: none; }
.sitemap-list li + li { margin-top: 0; }
.sitemap-item { display: block; padding: 13px 14px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); text-decoration: none; }
.sitemap-item:hover, .sitemap-item:focus-visible { border-color: var(--accent); background: #f3f7f4; }
.sitemap-title { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.sitemap-description { display: block; margin-top: 3px; color: var(--muted); font-size: .82rem; }
.current-badge { padding: 2px 7px; border-radius: 999px; color: var(--accent-dark); background: var(--accent-soft); font-size: .68rem; font-weight: 800; }

@media (max-width: 520px) {
    .app-shell { width: min(100% - 24px, 680px); padding-top: 34px; }
    .draw-panel, .results-panel { padding: 19px 16px; border-radius: 20px; }
    .modal-layer { padding: 12px; }
    .modal-dialog { max-height: calc(100dvh - 24px); }
}

@media (max-width: 360px) {
    .draw-actions { grid-template-columns: 1fr; }
    .ball { font-size: .74rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
