@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Noto+Sans+KR:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --paper: #f5f3ed;
  --ink: #22241f;
  --muted: #77796f;
  --line: #deddd3;
  --green: #294b3c;
  --green-light: #e4e9df;
  --board: #e6bd78;
  --board-line: rgba(73, 53, 29, .58);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Sans KR", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, a { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid #6b947b; outline-offset: 4px; }
.app { width: min(100% - 40px, 760px); min-height: 100vh; margin: 0 auto; display: flex; flex-direction: column; }
.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; letter-spacing: -.04em; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; background: var(--green); color: #f8f7f0; border-radius: 9px; font-size: 17px; }
.top-note, .tiny-note, .footer, .game-hint { color: var(--muted); font-size: 12px; }
.home-screen { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 54px 0 70px; }
.intro { margin-bottom: 38px; }
.eyebrow { margin: 0 0 12px; color: var(--green); font-family: "DM Mono", monospace; font-size: 10px; font-weight: 500; letter-spacing: .16em; }
h1 { margin: 0; font-size: clamp(38px, 7vw, 58px); line-height: 1.22; letter-spacing: -.075em; font-weight: 800; }
.intro h1 span { color: var(--green); }
.intro-copy { margin: 20px 0 0; color: var(--muted); font-size: 15px; line-height: 1.9; }
.mode-list { display: grid; gap: 12px; }
.mode-card { width: 100%; min-height: 94px; display: flex; align-items: center; gap: 16px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.48); text-align: left; cursor: pointer; transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.mode-card:hover { transform: translateY(-2px); border-color: #9eaa9d; background: #fffef9; }
.mode-icon { flex: 0 0 46px; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 13px; font-size: 25px; }
.ai-icon { background: #e9e6dc; color: #33362f; }
.local-icon { background: var(--green-light); color: var(--green); }
.mode-text { display: grid; gap: 5px; }
.mode-text strong { font-size: 16px; font-weight: 700; letter-spacing: -.04em; }
.mode-text small { color: var(--muted); font-size: 12px; }
.mode-arrow { margin-left: auto; color: #92958b; font-size: 22px; }
.tiny-note { margin: 22px 0 0; }
.footer { min-height: 60px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); }
.play-screen { flex: 1; width: min(100%, 560px); margin: 0 auto; padding: 28px 0 42px; }
.game-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.game-title { text-align: center; }
.game-title .eyebrow { margin-bottom: 3px; font-size: 9px; }
.game-title h1 { font-size: 24px; letter-spacing: -.06em; }
.text-button, .icon-button { border: 0; background: transparent; cursor: pointer; }
.text-button { padding: 10px 0; color: var(--muted); font-size: 12px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px; font-size: 22px; }
.status-card { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding: 13px 15px; background: #fffef9; border: 1px solid var(--line); border-radius: 14px; }
.turn-stone { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto; }
.black-stone { background: #252620; box-shadow: inset -2px -3px 4px #0004; }
.white-stone { background: #fff; border: 1px solid #c9c8c0; box-shadow: inset -2px -3px 4px #0001; }
.status-copy { display: grid; gap: 3px; }
.status-copy strong { font-size: 13px; }
.status-copy span { color: var(--muted); font-size: 11px; }
.move-count { margin-left: auto; color: var(--muted); font: 11px "DM Mono", monospace; }
.difficulty-control { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.difficulty-control select { max-width: 90px; padding: 6px 7px; border: 1px solid var(--line); border-radius: 8px; background: #fffef9; color: var(--ink); font: inherit; cursor: pointer; }
.board-wrap { width: 100%; padding: clamp(7px, 2vw, 13px); border-radius: 5px; background: var(--board); box-shadow: 0 7px 0 #c89e5d, 0 12px 22px #4a35181c; touch-action: manipulation; }
.board { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); aspect-ratio: 1; }
.cell { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; padding: 0; border: 0; background-color: transparent; background-image: linear-gradient(var(--board-line), var(--board-line)), linear-gradient(var(--board-line), var(--board-line)); background-repeat: no-repeat; background-position: center center; background-size: 1px 100%, 100% 1px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.cell::before { content: ""; width: 78%; height: 78%; border-radius: 50%; transform: scale(0); transition: transform .1s ease; }
.cell.black::before { transform: scale(1); background: radial-gradient(circle at 32% 25%, #62635d 0, #242520 40%, #11120f 100%); box-shadow: 1px 2px 3px #0006; }
.cell.white::before { transform: scale(1); background: radial-gradient(circle at 32% 25%, #fff 0, #fff 45%, #deded7 100%); border: 1px solid #aaa99f; box-shadow: 1px 2px 3px #0003; }
.cell.last-move::after { content: ""; position: absolute; width: 20%; height: 20%; border-radius: 50%; background: #e76d4b; z-index: 1; }
.cell:disabled { cursor: default; }
.game-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
.secondary-button, .primary-button { min-height: 46px; border-radius: 12px; cursor: pointer; font-size: 13px; font-weight: 700; }
.secondary-button { background: transparent; border: 1px solid var(--line); }
.secondary-button:disabled { opacity: .38; cursor: not-allowed; }
.primary-button { color: #fffef9; background: var(--green); border: 1px solid var(--green); }
.primary-button:hover { background: #203c30; }
.game-hint { margin: 14px 0 0; text-align: center; }
[hidden] { display: none !important; }
@media (max-width: 480px) {
  .app { width: min(100% - 28px, 760px); }
  .topbar { height: 64px; }
  .top-note { font-size: 10px; }
  .home-screen { padding: 44px 0 52px; }
  .intro { margin-bottom: 30px; }
  .intro-copy { font-size: 14px; }
  .mode-card { min-height: 84px; padding: 15px; gap: 13px; }
  .mode-icon { width: 42px; height: 42px; flex-basis: 42px; }
  .play-screen { padding-top: 20px; }
  .game-title h1 { font-size: 21px; }
  .status-card { padding: 11px 10px; gap: 9px; }
  .difficulty-control { gap: 4px; font-size: 10px; }
  .difficulty-control select { max-width: 76px; padding: 5px 4px; }
  .footer { min-height: 52px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; } }

/* Solo-game setup dialog */
.setup-dialog { width: min(calc(100% - 32px), 390px); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); color: var(--ink); box-shadow: 0 18px 60px #0003; }
.setup-dialog::backdrop { background: #1b211dcc; backdrop-filter: blur(3px); }
.setup-form { padding: 26px; }
.setup-form .eyebrow { margin-bottom: 8px; }
.setup-form h2 { margin: 0; font-size: 25px; letter-spacing: -.06em; }
.setup-description { margin: 8px 0 20px; color: var(--muted); font-size: 13px; }
.color-option { display: flex; align-items: center; gap: 12px; padding: 13px; margin-top: 9px; border: 1px solid var(--line); border-radius: 12px; background: #fffef9; cursor: pointer; }
.color-option:has(input:checked) { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.color-option input { accent-color: var(--green); }
.option-stone { width: 19px; height: 19px; flex: 0 0 auto; border-radius: 50%; }
.color-option > span:last-child { display: grid; gap: 3px; }
.color-option strong { font-size: 13px; }
.color-option small { color: var(--muted); font-size: 11px; }
.setup-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.setup-actions button { min-height: 44px; }


/* Difficulty is selected before entering the Gomoku board. */
.setup-difficulty { display: grid; gap: 8px; margin-top: 18px; color: var(--muted); font-size: 12px; }
.setup-difficulty select { width: 100%; min-height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; background: #fffef9; color: var(--ink); font: inherit; cursor: pointer; }

/* Canvas board uses a single fixed coordinate system for all intersections. */
.board { display:block; width:100%; height:auto; aspect-ratio:1; }

/* Canvas board uses a single fixed coordinate system for all intersections. */
.board { display:block; width:100%; height:auto; aspect-ratio:1; }

/* Canvas board uses one fixed coordinate system for every intersection. */
.board { display:block; width:100%; height:auto; aspect-ratio:1; }


/* Ink-wash Gomoku motif: open-ended intersections that dissolve from the top-right. */
.intro { position: relative; isolation: isolate; }
.intro > h1 { position: relative; z-index: 1; max-width: 58%; }
.hero-boards {
  position: absolute; z-index: 0; right: -2%; top: 8px;
  width: 27%; aspect-ratio: 1; pointer-events: none; opacity: .2;
}
.hero-boards::before {
  content: ""; position: absolute; z-index: -1; inset: -48% -35% -28% -22%;
  background:
    radial-gradient(ellipse at 78% 18%, rgba(43,55,43,.22), transparent 58%),
    linear-gradient(135deg, transparent 20%, rgba(43,55,43,.12) 55%, transparent 78%);
  filter: blur(9px); border-radius: 48% 0 55% 35%;
}
.hero-board {
  position: absolute; inset: 0; overflow: visible;
  background-image:
    linear-gradient(to right, rgba(47,57,47,.8) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(47,57,47,.8) 1px, transparent 1px);
  background-size: 25% 100%, 100% 25%;
  background-position: left top; background-repeat: repeat-x, repeat-y;
  -webkit-mask-image: radial-gradient(ellipse at 100% 0%, #000 0%, rgba(0,0,0,.82) 34%, rgba(0,0,0,.3) 61%, transparent 82%);
  mask-image: radial-gradient(ellipse at 100% 0%, #000 0%, rgba(0,0,0,.82) 34%, rgba(0,0,0,.3) 61%, transparent 82%);
}
.hero-board .stone {
  position: absolute; left: var(--x); top: var(--y);
  width: 15%; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%,-50%);
}
.hero-board .black {
  background: radial-gradient(circle at 32% 25%, #55584f 0, #252820 48%, #171a16 100%);
  box-shadow: 1px 2px 3px #0004;
}
.hero-board .white {
  background: radial-gradient(circle at 32% 25%, #fff 0, #fff 48%, #d5d3c8 100%);
  border: 1px solid #aaa99f; box-shadow: 1px 2px 3px #0002;
}
/* Keep navigation cards above the decorative grid. */
.home-screen .mode-list { position: relative; z-index: 1; }
@media (max-width: 620px) {
  .intro > h1 { max-width: 100%; }
  .hero-boards { width: 31%; right: 0; top: 0; opacity: .12; }
  .hero-boards::before { inset: -35% -24% -20%; }
}
@media (max-width: 420px) {
  .hero-boards { width: 27%; opacity: .1; }
  .hero-board .stone { width: 14%; }
}

.footer { min-height: 90px; flex-wrap: wrap; gap: 10px 18px; padding: 16px 0; }
.footer-links { display: flex; gap: 14px; }
.footer-links a { color: inherit; text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }
.footer small { flex-basis: 100%; font-size: 10px; line-height: 1.6; }
