:root {
  --bg: #efe9de;
  --surface: rgba(255, 253, 248, 0.96);
  --surface-strong: #fffdf8;
  --ink: #222720;
  --muted: #6e756d;
  --accent: #1f6a59;
  --accent-dark: #163d35;
  --accent-soft: #e4f2ed;
  --gold: #dca758;
  --board: #d7a456;
  --board-dark: #805228;
  --line: #4a3019;
  --danger: #b64943;
  --warning: #a86716;
  --blue: #2c77d5;
  --shadow: 0 18px 50px rgba(51, 39, 25, .13);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255,255,255,.95), transparent 35%),
    linear-gradient(145deg, #f6f0e7, var(--bg));
  -webkit-tap-highlight-color: transparent;
}
button, select, input { font: inherit; }
button { color: inherit; }

.app-shell { width: min(1240px, 100%); margin: 0 auto; padding: 18px 18px 40px; }
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-bottom: 16px;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(25px, 4vw, 40px); letter-spacing: -.045em; }
h2 { margin-bottom: 0; font-size: clamp(20px, 2.2vw, 27px); letter-spacing: -.035em; }
.eyebrow { margin-bottom: 3px; color: var(--accent); font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.engine-badge { padding: 8px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 900; white-space: nowrap; }
.icon-button { border: 0; border-radius: 12px; width: 42px; height: 42px; background: var(--surface); box-shadow: 0 7px 18px rgba(50,40,28,.1); cursor: pointer; }

.main-grid { display: grid; grid-template-columns: minmax(420px, 680px) minmax(330px, 1fr); gap: 18px; align-items: start; }
.card { background: var(--surface); border: 1px solid rgba(76,57,34,.11); border-radius: 23px; box-shadow: var(--shadow); }
.board-panel { padding: 15px; position: sticky; top: 12px; }
.game-strip { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 2px 2px 12px; }
.turn-display { display: flex; align-items: center; gap: 8px; font-weight: 900; }
.game-meta { color: var(--muted); font-size: 13px; }
.stone-dot { display: inline-block; width: 17px; height: 17px; border-radius: 50%; vertical-align: -3px; box-shadow: inset -2px -3px 4px rgba(0,0,0,.22), 0 1px 2px rgba(0,0,0,.25); }
.stone-dot.black { background: #151515; }
.stone-dot.white { background: #f7f4ed; border: 1px solid #aaa; }

.board-stage {
  width: 100%; aspect-ratio: 1; position: relative;
  border: 9px solid var(--board-dark); border-radius: 17px; padding: 0;
  background: linear-gradient(145deg, #e6bb73, var(--board));
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.22), 0 13px 27px rgba(65,42,18,.2);
  overflow: hidden;
}
.board-coordinate-grid {
  width: 100%; height: 100%; padding: 1.2%; display: grid;
  grid-template-columns: 5.2% 1fr 5.2%; grid-template-rows: 5.2% 1fr 5.2%;
}
.coord-axis { color: #4b311b; font-size: clamp(9px, 1.7vw, 13px); font-weight: 1000; opacity: .9; user-select: none; }
.coord-horizontal { display: grid; grid-template-columns: repeat(var(--board-size, 9), 1fr); align-items: center; text-align: center; }
.coord-vertical { display: grid; grid-template-rows: repeat(var(--board-size, 9), 1fr); align-items: center; text-align: center; }
.coord-axis span { display: grid; place-items: center; min-width: 0; min-height: 0; }
.board { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(var(--board-size, 9),1fr); grid-template-rows: repeat(var(--board-size, 9),1fr); user-select: none; touch-action: manipulation; }
.point { position: relative; border: 0; background: transparent; margin: 0; padding: 0; cursor: pointer; outline: 0; }
.point::before, .point::after { content: ""; position: absolute; z-index: 0; background: var(--line); opacity: .86; }
.point::before { height: 1.5px; top: 50%; left: 0; right: 0; transform: translateY(-50%); }
.point::after { width: 1.5px; left: 50%; top: 0; bottom: 0; transform: translateX(-50%); }
.point.edge-left::before { left: 50%; }
.point.edge-right::before { right: 50%; }
.point.edge-top::after { top: 50%; }
.point.edge-bottom::after { bottom: 50%; }
.point:focus-visible { outline: 3px solid #fff; outline-offset: -2px; border-radius: 50%; }
.stone, .ghost, .star, .last-marker, .hint-marker, .lesson-marker, .liberty-marker, .influence-marker, .atari-marker, .reply-marker {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); border-radius: 50%; pointer-events: none;
}
.star { width: 10%; height: 10%; background: var(--line); z-index: 1; }
.stone { width: 88%; height: 88%; z-index: 5; box-shadow: inset -5px -7px 9px rgba(0,0,0,.22), 0 3px 5px rgba(0,0,0,.33); }
.stone.black { background: radial-gradient(circle at 35% 28%, #565656 0, #1c1c1c 36%, #050505 80%); }
.stone.white { background: radial-gradient(circle at 35% 27%, #fff 0, #f0eee9 58%, #cac4ba 100%); border: 1px solid rgba(0,0,0,.18); }
.ghost { width: 78%; height: 78%; z-index: 4; opacity: 0; background: rgba(20,20,20,.55); transition: .12s; }
.point:hover .ghost { opacity: .55; }
.last-marker { width: 18%; height: 18%; z-index: 7; background: #e3463f; box-shadow: 0 0 0 2px white; }
.hint-marker { width: 67%; height: 67%; z-index: 8; border: 4px solid var(--blue); box-shadow: 0 0 0 4px rgba(255,255,255,.72), 0 0 18px rgba(44,119,213,.74); animation: pulse 1.15s infinite; }
.hint-marker.rank-2 { border-color: #7d56c5; box-shadow: 0 0 0 4px rgba(255,255,255,.72), 0 0 15px rgba(125,86,197,.65); }
.hint-marker.rank-3 { border-color: #da8a2c; box-shadow: 0 0 0 4px rgba(255,255,255,.72), 0 0 15px rgba(218,138,44,.65); }
.hint-label { position: absolute; z-index: 9; left: 52%; top: 50%; transform: translate(-50%,-50%); color: white; font-size: clamp(9px, 2vw, 13px); font-weight: 1000; text-shadow: 0 1px 3px rgba(0,0,0,.7); pointer-events: none; }
.reply-marker { width: 74%; height: 74%; z-index: 8; border: 4px dashed #cc3f38; background: rgba(255,255,255,.14); box-shadow: 0 0 0 4px rgba(255,255,255,.72), 0 0 16px rgba(204,63,56,.7); animation: pulse 1.15s infinite; }
.reply-label { position: absolute; z-index: 10; left: 50%; top: 50%; transform: translate(-50%,-50%); padding: 2px 5px; border-radius: 999px; background: #cc3f38; color: white; font-size: clamp(8px, 1.8vw, 11px); font-weight: 1000; white-space: nowrap; pointer-events: none; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.coordinate-help { margin: 8px 3px 0; color: #665d52; font-size: 12px; line-height: 1.5; }
.coordinate-help b { color: var(--accent-dark); }
.coord-callout { margin-top: 9px; padding: 9px 11px; border-radius: 12px; background: #fff4dc; border: 1px solid #eed39d; color: #78500f; font-size: 13px; font-weight: 800; }

.lesson-marker { width: 62%; height: 62%; z-index: 8; border: 5px solid #1d80e8; background: rgba(255,255,255,.15); box-shadow: 0 0 0 5px rgba(255,255,255,.8); animation: pulse 1s infinite; }
.liberty-marker { width: 20%; height: 20%; z-index: 6; background: #20a662; box-shadow: 0 0 0 4px rgba(255,255,255,.75); }
.atari-marker { width: 110%; height: 110%; z-index: 4; border: 3px solid rgba(210,50,43,.88); animation: pulse 1s infinite; }
.influence-marker { width: 72%; height: 72%; z-index: 2; opacity: .18; }
.influence-marker.black { background: #182922; }
.influence-marker.white { background: #f7f7ff; border: 1px solid rgba(65,76,100,.4); }
@keyframes pulse { 50% { transform: translate(-50%,-50%) scale(1.13); } }

.thinking-overlay[hidden] { display: none !important; }
.thinking-overlay { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 11px; color: white; background: rgba(20,33,29,.77); backdrop-filter: blur(3px); text-align: center; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid rgba(255,255,255,.28); border-top-color: white; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { width: min(220px, 65%); height: 6px; border-radius: 99px; background: rgba(255,255,255,.2); overflow: hidden; }
.progress span { display: block; width: 15%; height: 100%; background: white; border-radius: inherit; transition: width .2s; }

.score-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 4px 2px; color: var(--muted); font-size: 13px; }
.score-line span:last-child { margin-left: auto; font-weight: 900; color: var(--accent); }
.desktop-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.button { border: 0; border-radius: 13px; padding: 10px 13px; background: #eee8de; font-weight: 900; cursor: pointer; transition: .16s ease; }
.button:hover { transform: translateY(-1px); filter: brightness(.98); }
.button:disabled { opacity: .42; cursor: default; transform: none; }
.button.primary { background: var(--accent); color: white; }
.button.danger { background: #fbe4e2; color: var(--danger); }
.button.full { width: 100%; margin-top: 12px; }
.text-button { border: 0; background: transparent; color: var(--accent); font-weight: 900; cursor: pointer; }

.learning-column { display: grid; gap: 14px; }
.teacher-card, .candidates-card, .thinking-order-card, .history-card { padding: 18px; }
.teacher-heading { display: flex; align-items: center; gap: 12px; }
.teacher-avatar { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 17px; background: var(--accent-soft); font-size: 31px; }
.teacher-body { margin-top: 14px; line-height: 1.67; }
.teacher-body > p:last-child { margin-bottom: 0; }
.explain-box { margin-top: 10px; padding: 12px 13px; border-radius: 15px; background: #eef7f3; border: 1px solid #d1e8df; }
.explain-box.warning { background: #fff7e8; border-color: #efd6ad; }
.explain-box.next { background: #eef4ff; border-color: #d4e0f4; }
.explain-label { display: inline-block; margin-bottom: 5px; padding: 3px 8px; border-radius: 999px; background: #d9eee6; color: var(--accent); font-size: 11px; font-weight: 1000; }
.warning .explain-label { background: #ffe6ba; color: var(--warning); }
.next .explain-label { background: #dbe7fb; color: #355f9c; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag { padding: 4px 8px; border-radius: 999px; background: #ece7df; color: #625c54; font-size: 11px; font-weight: 900; }
.lesson-dots { display: flex; gap: 5px; margin-top: 14px; }
.lesson-dots span { flex: 1; height: 6px; border-radius: 99px; background: #ded8cf; }
.lesson-dots span.active { background: var(--accent); }
.teacher-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.candidate-list { display: grid; gap: 9px; margin-top: 13px; }
.candidate { width: 100%; border: 1px solid #dde8e4; border-radius: 16px; background: white; padding: 13px; text-align: left; cursor: pointer; }
.candidate:hover { border-color: var(--accent); }
.candidate-top { display: flex; justify-content: space-between; gap: 10px; }
.candidate-rank { display: flex; align-items: center; gap: 7px; font-weight: 1000; }
.rank-pill { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: var(--accent); color: white; font-size: 12px; }
.candidate:nth-child(2) .rank-pill { background: #7d56c5; }
.candidate:nth-child(3) .rank-pill { background: #da8a2c; }
.candidate p { margin: 8px 0 0; color: #505950; line-height: 1.55; font-size: 14px; }
.candidate .candidate-reply { color: #9b3d38; font-size: 12px; }
.thinking-order { list-style: none; padding: 0; margin: 13px 0 0; display: grid; gap: 9px; }
.thinking-order li { display: grid; grid-template-columns: 88px 1fr; gap: 10px; align-items: center; padding: 10px; border-radius: 13px; background: #f3eee6; }
.thinking-order b { color: var(--accent-dark); }
.thinking-order span { color: var(--muted); font-size: 13px; }
.history-list { margin-top: 12px; max-height: 390px; overflow: auto; display: grid; gap: 9px; }
.history-item { padding: 11px 12px; border-radius: 14px; background: #f4efe7; font-size: 13px; line-height: 1.55; border: 1px solid transparent; }
.history-item.human { background: #f5faf7; border-color: #d8e8e1; }
.history-item.verdict-dubious, .history-item.verdict-mistake { background: #fff8eb; border-color: #efd5a7; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 900; }
.verdict-chip { flex: 0 0 auto; padding: 3px 7px; border-radius: 999px; background: #e3eee9; color: var(--accent); font-size: 10px; font-weight: 1000; }
.verdict-chip.dubious, .verdict-chip.mistake { background: #ffe5b8; color: #965b0c; }
.history-summary { margin: 7px 0 0; color: #465049; }
.history-coach { margin-top: 7px; padding-top: 7px; border-top: 1px dashed rgba(75,69,60,.22); color: #5c554d; }
.history-coach b { color: var(--accent-dark); }
.history-best-button { margin-top: 7px; border: 0; border-radius: 10px; padding: 6px 9px; background: #e0ecf9; color: #2e5d96; font-size: 11px; font-weight: 900; cursor: pointer; }
.history-item strong { color: var(--accent-dark); }
.empty-state { color: var(--muted); font-size: 14px; }

.mobile-action-bar { display: none; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; padding: 18px; background: rgba(25,22,18,.66); backdrop-filter: blur(4px); }
.modal-backdrop.show { display: grid; }
.modal { width: min(530px, 100%); max-height: min(90vh, 800px); overflow: auto; padding: 22px; border-radius: 24px; background: var(--surface-strong); box-shadow: 0 30px 100px rgba(0,0,0,.35); }
.welcome-modal { text-align: center; }
.welcome-icon { font-size: 48px; margin-bottom: 7px; }
.welcome-modal > p:not(.eyebrow):not(.tiny-note) { color: var(--muted); line-height: 1.7; }
.choice-stack { display: grid; gap: 9px; margin: 17px 0; }
.choice { border: 2px solid #e5ddd1; border-radius: 17px; padding: 15px; background: white; text-align: left; cursor: pointer; }
.choice b, .choice span { display: block; }
.choice span { margin-top: 3px; color: var(--muted); font-size: 13px; }
.primary-choice { border-color: var(--accent); background: #eef8f4; }
.tiny-note { margin: 14px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.modal-title-row, .modal-actions { display: flex; justify-content: space-between; align-items: center; gap: 9px; }
.setting-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 15px 0; border-bottom: 1px solid #ece5da; }
.setting-row span { display: grid; gap: 3px; }
.setting-row small { color: var(--muted); line-height: 1.45; }
.setting-row select { min-width: 126px; padding: 8px; border: 1px solid #d8d0c5; border-radius: 10px; background: white; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--accent); }
.result-score { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 15px 0; }
.result-score div { padding: 13px; border-radius: 14px; background: #f3eee6; text-align: center; }
.result-score b { display: block; font-size: 25px; }
.modal-actions { margin-top: 16px; justify-content: flex-start; }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); z-index: 80; max-width: min(90vw, 520px); transform: translate(-50%, 20px); opacity: 0; padding: 11px 16px; border-radius: 999px; background: #262a26; color: white; box-shadow: 0 10px 35px rgba(0,0,0,.28); transition: .2s; pointer-events: none; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .app-shell { padding: 10px 10px calc(92px + var(--safe-bottom)); }
  .app-header { margin-bottom: 10px; }
  .engine-badge { display: none; }
  .main-grid { grid-template-columns: 1fr; gap: 11px; }
  .board-panel { position: static; padding: 10px; border-radius: 18px; }
  .board-stage { border-width: 7px; border-radius: 13px; }
  .learning-column { gap: 11px; }
  .teacher-card, .candidates-card, .thinking-order-card, .history-card { padding: 15px; border-radius: 18px; }
  .desktop-actions { display: none; }
  .mobile-action-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; display: grid; grid-template-columns: repeat(4,1fr);
    padding: 7px 7px calc(7px + var(--safe-bottom)); background: rgba(255,253,248,.96); border-top: 1px solid rgba(80,60,35,.13); backdrop-filter: blur(16px); box-shadow: 0 -8px 30px rgba(50,38,24,.12);
  }
  .mobile-action-bar button { border: 0; background: transparent; padding: 6px 2px; font-size: 11px; font-weight: 900; cursor: pointer; }
  .mobile-action-bar span { display: block; font-size: 20px; margin-bottom: 1px; }
  .score-line span:last-child { width: 100%; margin-left: 0; }
  .teacher-avatar { width: 46px; height: 46px; font-size: 27px; }
  .history-list { max-height: 190px; }
}

@media (max-width: 480px) {
  h1 { font-size: 25px; }
  .app-header .eyebrow { font-size: 10px; }
  .icon-button { width: 39px; height: 39px; }
  .game-strip { margin-bottom: 8px; }
  .game-meta { max-width: 48%; text-align: right; }
  .board-coordinate-grid { grid-template-columns: 5.8% 1fr 5.8%; grid-template-rows: 5.8% 1fr 5.8%; padding: .8%; }
  .coordinate-help { font-size: 11px; }
  .thinking-order li { grid-template-columns: 75px 1fr; }
  .setting-row { align-items: flex-start; flex-direction: column; }
  .setting-row select { width: 100%; }
  .switch-row { flex-direction: row; align-items: center; }
  .modal { padding: 18px; border-radius: 20px; }
}

@media (display-mode: standalone) {
  .app-header { padding-top: env(safe-area-inset-top, 0px); }
}
.version{font-size:12px;color:var(--muted);letter-spacing:0;vertical-align:middle}.course-progress{display:grid;grid-template-columns:repeat(5,1fr);gap:7px;margin:-4px 0 14px}.course-step{border:0;border-radius:13px;padding:8px 6px;background:rgba(255,253,248,.72);color:var(--muted);font-size:11px;font-weight:900;cursor:pointer;box-shadow:0 4px 14px rgba(50,40,28,.06)}.course-step.active{background:var(--accent);color:white}.course-step.done:before{content:"✓ "}.course-modal>p:not(.eyebrow):not(.tiny-note){color:var(--muted);line-height:1.7}.goal-banner{margin:0 0 11px;padding:11px 13px;border-radius:14px;background:#fff4dc;border:1px solid #eed39d;color:#78500f;font-weight:900;line-height:1.5}.simple-callout{margin-top:10px;padding:13px;border-radius:15px;background:#f0f7ff;border:1px solid #d4e2f4;line-height:1.65}.simple-callout b{color:#285c98}.big-word{display:inline-block;padding:1px 7px;border-radius:8px;background:#fff1c9;font-weight:1000}.result-actions-note{color:var(--muted);font-size:13px;line-height:1.6}@media(max-width:600px){.course-progress{gap:4px}.course-step{padding:7px 2px;font-size:9px}}
