:root {
  color-scheme: dark;
  background: #111514;
  color: #f1f4e9;
  font: 100%/1.58 Inter, "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --surface: #1a211e;
  --surface-dark: #131a17;
  --layer: #202925;
  --line: #34413b;
  --text: #f1f4e9;
  --muted: #a8b6ac;
  --lime: #d9f583;
  --mint: #7bd6bc;
  --error: #ffbbb0;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
h1, h2, h3, p, ul, ol { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .53; }
button, input, textarea, summary, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }
[hidden] { display: none !important; }
.shell { width: min(1192px, calc(100% - 64px)); margin-inline: auto; }
.header { background: #141a17; border-bottom: 1px solid #2b3630; }
.header-inner { min-height: 70px; display: flex; gap: 15px; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; font-weight: 760; letter-spacing: -.045em; font-size: 1.24rem; }
.mark { display: grid; grid-template-columns: repeat(2, 6px); place-content: center; gap: 3px; width: 29px; height: 29px; border-radius: 8px; background: var(--lime); transform: rotate(-8deg); }
.mark i { width: 6px; height: 6px; background: #293328; border-radius: 50%; }
.mark i:last-child { grid-column: 2; }
.health { color: var(--muted); font: .84rem var(--mono); display: inline-flex; align-items: center; gap: 8px; }
.health span { height: 8px; width: 8px; border-radius: 50%; background: #8a9289; flex-shrink: 0; }
.health[data-kind="ok"] span { background: var(--mint); box-shadow: 0 0 0 3px #7bd6bc22; }
.health[data-kind="error"] span { background: var(--error); }
main { padding-block: 36px 55px; }
.intro { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 18px; margin-bottom: 27px; }
.intro h1 { font-size: clamp(2rem, 4.5vw, 3.2rem); line-height: 1.13; letter-spacing: -.065em; font-weight: 780; }
.intro p { margin-top: 10px; color: var(--muted); }
.move-constructor { display: grid; gap: 4px; color: var(--muted); font-size: .82rem; }
select { border: 1px solid #4c5e54; border-radius: 8px; background: #19241d; min-height: 40px; padding: 5px 9px; color: var(--text); }
.workspace { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: 17px; align-items: start; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 5px 24px #0002; padding: clamp(17px, 2.5vw, 25px); border-radius: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; min-height: 38px; gap: 8px; }
h2 { font-size: 1.3rem; letter-spacing: -.04em; line-height: 1.3; }
button { border-radius: 9px; min-height: 39px; padding: 6px 12px; font-weight: 690; font-size: .87rem; }
.quiet { border: 1px solid transparent; background: transparent; color: #c3cfc6; }
.quiet:enabled:hover { background: #283730; color: white; }
.secondary { border: 1px solid #47594f; background: #26332c; color: var(--text); }
.secondary:enabled:hover { background: #34483c; }
.turn-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; min-height: 31px; gap: 6px; margin: 21px 0 8px; }
.turn, .classification { display: inline-flex; font-size: .85rem; font-weight: 700; border-radius: 5px; line-height: 1.25; padding: 5px 8px; }
.turn { color: #e1efd9; background: #32473b; }
.turn[data-kind="end"] { background: var(--lime); color: #202a17; }
.classification { color: var(--mint); border: 1px solid #416455; }
.classification[data-kind="lose"] { color: #ebc497; border-color: #675645; }
.board { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 11px; }
.board.three-piles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.board.card-board { grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); }
.pair-card { min-width: 0; min-height: 106px; padding: 10px; border: 1px solid #3d4d43; border-radius: 12px; background: #161e19; }
.pair-card[data-removed="true"] { border-style: dashed; background: transparent; color: var(--muted); }
.card-faces { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin-top: 8px; }
.card-face { display: grid; justify-items: center; padding: 4px; border-radius: 6px; background: #dfeabf; color: #273521; font-size: .7rem; }
.card-face + .card-face { background: #28473b; color: #d0ebdc; }
.card-face strong { font: 730 1.36rem var(--mono); }
.removed-card { margin-top: 15px; font-size: .85rem; }
.counter-board { display: block; padding: 14px; border: 1px solid #3d4d43; border-radius: 12px; background: #161e19; }
.number-track { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.number-tick { display: grid; place-items: center; min-height: 27px; border-radius: 4px; background: #202b23; color: var(--muted); font: .75rem var(--mono); }
.number-tick[data-reached="past"] { background: #335242; color: #d2e7d9; }
.number-tick[data-reached="current"] { background: var(--lime); color: #182109; font-weight: 700; }
.number-tick:last-child { outline: 1px solid #a27972; outline-offset: -1px; }
.pile { text-align: left; display: flex; flex-direction: column; align-items: stretch; min-width: 0; min-height: 198px; padding: 13px; border-radius: 12px; border: 1px solid #3d4d43; background: #161e19; transition: border-color .15s, background-color .15s; }
.pile[aria-pressed="true"] { border-color: #b7d978; background: #202a20; box-shadow: inset 0 0 0 1px #b7d95e30; }
.pile:enabled:hover { background: #27342a; }
.pile[disabled] { opacity: 1; }
.pile-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 2px 8px; }
.pile-head code { color: var(--muted); font: .83rem var(--mono); }
.pile-count { font: 730 clamp(1.9rem, 3.5vw, 2.5rem)/1.1 var(--mono); letter-spacing: -.045em; margin-block: 13px 10px; }
.stones { display: grid; grid-template-columns: repeat(auto-fit, minmax(19px, 23px)); gap: 7px; align-items: center; min-height: 23px; }
.stone { aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 34% 26%, #e8ff9c, #a6cc54 77%); border: 1px solid #e8ffb52e; box-shadow: 0 2px 0 #50692c; }
.stones-right .stone { background: radial-gradient(circle at 34% 26%, #9aefce, #4baf92 77%); border-color: #cfffea3c; box-shadow: 0 2px 0 #285849; }
.empty-stones, .overflow-stones { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); }
.actions { display: flex; justify-content: space-between; gap: 9px 16px; align-items: end; flex-wrap: wrap; margin-top: 15px; }
.take-form { display: flex; gap: 7px 9px; flex-wrap: wrap; align-items: end; }
.take-form label { font-size: .85rem; color: var(--muted); }
.move-args, .start-values, .suggested-moves { display: flex; flex-wrap: wrap; gap: 6px; }
.move-args label { display: grid; gap: 2px; }
.move-args input[type="text"] { width: 112px; }
.suggested-moves { margin-top: 10px; }
.suggested-moves button { min-height: 33px; padding: 3px 8px; font: .78rem var(--mono); }
input { color-scheme: dark; border: 1px solid #4c5e54; border-radius: 8px; background: #121a15; min-height: 39px; width: 62px; padding: 5px 7px; font: .9rem var(--mono); }
.run-reply { color: var(--lime); padding-inline: 8px; }
.board-note { min-height: 21px; margin-top: 7px; color: var(--muted); font-size: .83rem; }
.play-bottom { display: grid; grid-template-columns: minmax(0, 1fr); margin-top: 8px; }
details { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding-block: 10px; }
summary { color: #d4dfd6; font-weight: 650; cursor: pointer; }
details[open] > summary { margin-bottom: 9px; }
details a { color: var(--mint); text-underline-offset: 4px; }
details ul, #history { padding-left: 21px; margin: 6px 0; }
#history { max-height: 170px; overflow-y: auto; }
#history li { padding-bottom: 3px; }
#history-count { margin-left: 4px; color: var(--muted); font: .8rem var(--mono); }
.setup { display: flex; align-items: end; gap: 7px; flex-wrap: wrap; }
.setup label { display: grid; gap: 2px; }
.setup p { width: 100%; color: var(--error); }
.editor-field { margin-top: 13px; }
.tutorial-steps { margin-top: 12px; color: var(--muted); font-size: .88rem; }
.tutorial-steps p + p, .tutorial-steps pre { margin-top: 8px; }
.tutorial-steps pre { padding: 8px 10px; background: var(--surface-dark); border-radius: 6px; overflow-x: auto; }
.editor-field label { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 3px 8px; margin-bottom: 6px; }
.editor-field label code { font: 700 .93rem var(--mono); color: var(--lime); }
.editor-field label span { color: var(--muted); font-size: .82rem; }
textarea { display: block; width: 100%; resize: vertical; background: #111914; border: 1px solid #394940; border-radius: 9px; padding: 11px 13px; color: #e5f2da; font: .93rem/1.62 var(--mono); tab-size: 2; }
textarea::placeholder { color: #8c9b90; opacity: 1; }
textarea:focus-visible { outline-offset: 1px; }
.sample-answer { padding-bottom: 5px; }
.sample-actions p { margin-top: 7px; }
.verify-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.primary { color: #182109; background: var(--lime); box-shadow: 0 3px 0 #788d3b; border: 1px solid #dff69d; min-height: 42px; padding-inline: 17px; }
.primary:enabled:hover { background: #ecffac; }
.feedback { margin-top: 15px; padding: 12px; border-radius: 9px; border: 1px solid #3d4b43; background: var(--surface-dark); }
.feedback h3 { font-size: .96rem; letter-spacing: -.025em; }
.feedback p { color: var(--muted); font-size: .84rem; margin-top: 3px; overflow-wrap: anywhere; }
.feedback[data-kind="verified"] { border-color: #56755b; }
.feedback[data-kind="verified"] h3 { color: var(--lime); }
.feedback[data-kind="rejected"] h3, .feedback[data-kind="invalid"] h3 { color: var(--error); }
.feedback[data-kind="inconclusive"] h3 { color: #ebc497; }
.feedback button { margin-top: 9px; }
.feedback details { margin-top: 9px; padding-bottom: 0; }
.feedback pre { max-height: 170px; overflow: auto; font: .78rem/1.55 var(--mono); margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 850px) {
  .shell { width: min(650px, calc(100% - 32px)); }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  main { padding-block: 25px 35px; }
}
@media (max-width: 420px) {
  .shell { width: calc(100% - 22px); }
  .header-inner { min-height: 56px; }
  .brand { font-size: 1.05rem; }
  .health { font-size: .73rem; }
  .board { gap: 7px; }
  .pile { min-height: 174px; padding: 10px; }
  .stones { grid-template-columns: repeat(auto-fit, minmax(14px, 18px)); gap: 5px; }
  .syntax-terms div { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

.action-link { display: inline-flex; align-items: center; border-radius: 9px; min-height: 39px; padding: 7px 12px; text-decoration: none; font-size: .87rem; font-weight: 700; }
.action-link:hover { filter: brightness(1.13); }
.back-link { display: inline-block; color: var(--mint); margin-bottom: 8px; text-underline-offset: 4px; font-size: .88rem; }
.lobby-intro { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; border: 1px solid #405344; border-radius: 20px; background: linear-gradient(128deg, #202c23 0%, #1a241e 55%, #253421 100%); padding: clamp(17px, 3vw, 27px); box-shadow: 0 8px 32px #0002; }
.lobby-intro h1 { color: var(--lime); font-size: clamp(1.85rem, 5vw, 2.8rem); letter-spacing: -.065em; line-height: 1.05; }
.catalog-section { margin-top: 28px; }
.catalog-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; gap: 5px 13px; }
.catalog-meta { font-size: .88rem; color: var(--muted); }
.progress-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#level-progress { margin-left: auto; font-variant-numeric: tabular-nums; }
.catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.game-card { min-width: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 13px; text-decoration: none; }
a.game-card:hover { border-color: #b0cc82; background: #212c24; }
.game-card h3 { margin: 9px 0 3px; font-size: 1.05rem; letter-spacing: -.035em; }
.card-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 5px; margin-top: auto; padding-top: 11px; font-size: .77rem; }
.card-start { color: #d0ded1; }
.card-visual { display: flex; position: relative; align-items: center; flex-wrap: wrap; gap: 7px; min-height: 72px; padding: 9px 12px; border-radius: 8px; background: radial-gradient(ellipse at 15% 60%, #2c4031, #1b261e 80%); }
.card-stone-group { display: flex; flex-wrap: wrap; gap: 3px; max-width: 75px; padding: 5px; }
.card-stone-group i { border-radius: 50%; width: 13px; height: 13px; background: var(--lime); box-shadow: 0 2px 0 #758e42; }
.card-stone-group.mint i { background: var(--mint); box-shadow: 0 2px 0 #3f846f; }
.card-number { display: grid; place-items: center; width: 35px; height: 36px; border-radius: 5px; background: #334938; color: #d3f9cf; font: 700 .96rem var(--mono); }
.card-number:last-child { background: var(--lime); color: #182109; }
.level-map {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: radial-gradient(ellipse at top, #222d25, var(--surface-dark) 72%);
}
#level-links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.level-rows { position: relative; display: grid; gap: 41px; padding: 23px clamp(9px, 2vw, 26px); }
.map-row { display: flex; justify-content: center; gap: clamp(6px, 3.6vw, 40px); }
.map-card {
  --circle: 52px;
  position: relative;
  flex: 0 1 var(--circle);
  width: var(--circle);
  aspect-ratio: 1;
  min-width: 0;
  align-self: center;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
}
.map-card-number { font-size: 1rem; font-weight: 720; font-variant-numeric: tabular-nums; line-height: 1; }
.map-card[data-status="locked"] { background: #1b2420; border-color: #415047; color: #b0bcb3; }
.map-card[data-status="open"] { border-color: #c5dd81; background: #d3e894; color: #212c19; }
.map-card[data-status="complete"] { border-color: #659780; background: #273e35; color: #c0e5d5; }
.map-card[data-status="locked"] .map-card-number,
.map-card[data-status="complete"] .map-card-number { transform: translateY(-3px); }
.map-check, .map-lock { position: absolute; bottom: 5px; color: currentColor; }
.map-check { font-size: .62rem; line-height: 1; color: var(--mint); }
.map-lock { width: 8px; height: 6px; border: 1px solid currentColor; border-radius: 2px; opacity: .7; }
.map-lock::before { content: ""; position: absolute; inset: -4px 1px auto; height: 3px; border: 1px solid currentColor; border-bottom: 0; border-radius: 4px 4px 0 0; }
.map-card.map-selected { border-color: #c4e890; box-shadow: 0 0 0 3px #c4e89030; }
.map-card.map-muted { opacity: .55; }
@media (max-width: 530px) {
  .map-card { --circle: clamp(31px, 9vw, 46px); }
  .map-row { gap: clamp(5px, 2vw, 10px); }
  .map-card-number { font-size: .85rem; }
  .map-check, .map-lock { bottom: 3px; }
}
.level-init { margin-top: 8px; color: var(--mint); font: .82rem/1.55 var(--mono); overflow-wrap: anywhere; }
.level-navigation { margin-top: 15px; border-top: 1px solid var(--line); padding-top: 12px; }
.level-navigation ul { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 7px; padding: 0; list-style: none; }
.level-navigation .map-card { --circle: 38px; }
.level-navigation .map-card-number { font-size: .87rem; }
.level-navigation .map-check, .level-navigation .map-lock { bottom: 3px; }

.game-rules { margin-bottom: 17px; padding: 14px 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.game-rules h2 { font-size: 1rem; }
.game-rules dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; margin: 10px 0 0; }
.game-rules dt { color: var(--muted); font-size: .78rem; font-weight: 650; }
.game-rules dd { margin: 3px 0 0; font-size: .86rem; line-height: 1.43; overflow-wrap: anywhere; }
.rule-moves-row { grid-column: 1 / -1; }
.game-rules ul { margin: 0; padding: 0; list-style: none; }
.game-rules li + li { margin-top: 4px; }
.move-rule { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.move-rule code { color: var(--mint); }

.board[data-layout="tokens"], .board[data-layout="words"],
.board[data-layout="knights"], .board[data-layout="scored-grid"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.board-wide { grid-column: 1 / -1; color: var(--muted); }
.rule-tile {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  min-height: 70px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
}
.rule-tile strong { font-size: 1.4rem; }
.rule-tile small, .tile-label { font-size: .76rem; }
.rule-tile[data-used="true"] .tile-label { text-decoration: line-through; }
.rule-tile[data-color="1"] { background: #183642; color: #b8e7ff; }
.rule-tile[data-color="2"] { background: #48272e; color: #ffd1d8; }
.rule-tile[data-color="0"] strong { color: var(--muted); }
.amount-picker { display: flex; gap: 8px; border: 1px solid var(--line); border-radius: 8px; margin: 0; }
.amount-picker label { align-items: center; }
.amount-picker input { width: auto; min-height: auto; margin: 0; }
#setup-piles { width: 150px; }
.workshop-form { display: grid; gap: 13px; }
.workshop-form label { display: grid; gap: 5px; color: #d4dfd6; font-size: .92rem; }
.workshop-form input:not([type="checkbox"]), .workshop-form select { width: 100%; }
.workshop-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.workshop-form label.fixed-check { display: flex; gap: 7px; align-items: center; }
.fixed-check input { width: 16px; min-height: 16px; accent-color: var(--lime); }
.workshop-preview h2 { margin-bottom: 9px; }
.workshop-preview p { color: var(--muted); font-size: .91rem; }
.workshop-preview dl { display: grid; gap: 9px; margin-block: 14px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.workshop-preview dt { color: var(--mint); font-weight: 670; font-size: .85rem; }
.workshop-preview dd { margin-inline: 0; }
#create-status { margin-top: 8px; color: var(--muted); min-height: 1.3em; }
@media (max-width: 720px) {
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 470px) {
  .catalog-grid, .workshop-fields { grid-template-columns: minmax(0, 1fr); }
}

.breadcrumbs { margin-bottom: 8px; font-size: .84rem; color: var(--mint); }
.breadcrumbs a { text-underline-offset: 4px; }
.game-intro .level-init { color: var(--mint); }
.board-controls { margin-top: 12px; }
.board-controls h3 { font-size: .85rem; color: var(--muted); font-weight: 650; }
.manual-move { margin-top: 9px; }
.suggested-moves .move-choice {
  background: #26332c;
  border: 1px solid #47594f;
  color: var(--text);
}
.suggested-moves .move-choice:hover:enabled { background: #34483c; }
.context { color: var(--muted); font-size: .78rem; font-weight: 580; margin-left: 4px; }
#proof-state { color: var(--mint); font: .83rem var(--mono); overflow-wrap: anywhere; }
#setup-error:empty, #create-status:empty { display: none; }
#catalog-error { margin-top: 12px; color: var(--error); }
.level-init code, .card-start code { font-family: var(--mono); }

.help-dialog {
  color: var(--text);
  background: var(--surface);
  border: 1px solid #4b6353;
  border-radius: 13px;
  padding: 0;
  width: min(590px, calc(100vw - 30px));
  max-height: min(78vh, 680px);
  overflow: auto;
}
.help-dialog::backdrop { background: #0b120dcc; }
.help-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 13px 19px;
}
.help-close { font-size: 1.35rem; line-height: 1; }
.help-content { display: grid; gap: 16px; padding: 15px 19px 20px; }
.help-content h3 { font-size: .95rem; margin-bottom: 5px; }
.help-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 7px; }
.help-section-head a { color: var(--mint); font-size: .8rem; text-underline-offset: 4px; }
.help-table { margin: 0; font-size: .86rem; }
.help-table > div {
  display: grid;
  grid-template-columns: 7.55rem minmax(0, 1fr);
  gap: 6px;
  padding: 4px 0;
}
.help-table dt { font-weight: 660; color: var(--muted); }
.help-table dd { margin: 0; overflow-wrap: anywhere; }
.help-table dd ul { list-style: none; padding-left: 0; margin: 0; }
.help-table li + li { margin-top: 3px; }
.help-content code { font-family: var(--mono); }
.help-content details { padding-bottom: 0; }
.help-content pre {
  margin: 4px 0 9px;
  padding: 8px 9px;
  background: var(--surface-dark);
  border-radius: 6px;
  overflow-x: auto;
  font: .8rem/1.5 var(--mono);
}
.help-content #sample-outline { margin-bottom: 9px; }
@media (max-width: 440px) {
  .help-dialog { max-height: 86vh; }
  .help-content { padding-inline: 13px; }
  .help-table > div { grid-template-columns: 5.5rem minmax(0, 1fr); font-size: .81rem; }
}

