/* rd — 보드게임 랜더마이저 */
:root {
  --bg: #0f1117; --surface: #171a23; --surface2: #1f2330; --border: rgba(255,255,255,.09);
  --text: #e6e7ee; --muted: #8b90a6; --accent: #f5a524; --accent-ink: #1a1200; --accent2: #6d8bff;
  --danger: #ff6b6b; --ok: #3ecf8e;
  --p1: #ff6b6b; --p2: #4dabf7; --p3: #69db7c; --p4: #ffd43b; --p5: #b197fc; --p6: #ff922b; --p7: #63e6be; --p8: #f783ac;
  --radius: 14px; --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
}
:root[data-theme="light"] {
  --bg: #f5f6fa; --surface: #fff; --surface2: #eef0f6; --border: rgba(0,0,0,.1);
  --text: #1a1c25; --muted: #6b7086; --accent: #e08a00; --accent-ink: #fff;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
:root[data-theme="light"] html, :root[data-theme="light"] { color-scheme: light; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; }
.muted { color: var(--muted); font-size: .9em; }
.inline { display: inline; }
.linklike { background: none; border: 0; padding: 0; color: inherit; }
.is-hidden { display: none !important; }

/* 상단 바 */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .8rem; padding: .6rem 1rem; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.brand { font-weight: 800; font-size: 1.05rem; white-space: nowrap; display: inline-flex; align-items: center; gap: .35rem; }
.brand-meeple { color: var(--accent); flex: none; }
.topbar-search { flex: 1; max-width: 420px; }
.topbar-search input { width: 100%; padding: .45rem .8rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); outline: none; }
.topbar-search input:focus { border-color: var(--accent); }
.topbar-nav { margin-left: auto; display: flex; gap: .9rem; align-items: center; font-size: .9rem; white-space: nowrap; }
.theme-toggle { background: none; border: 1px solid var(--border); border-radius: 999px; width: 30px; height: 30px; }

.page { max-width: 1080px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.footer { max-width: 1080px; margin: 0 auto; padding: 1.5rem 1rem 2.5rem; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--border); }
.footer a { text-decoration: underline; }
.footer-links { display: flex; flex-wrap: wrap; gap: .3rem .5rem; align-items: center; }
.lang-switch { margin-left: auto; }
.lang-switch strong { color: var(--text); }
.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; background: var(--surface2); border: 1px solid var(--border); }
.flash-error { border-color: var(--danger); }
.flash-ok { border-color: var(--ok); }

/* 홈 */
.hero { padding: 1.5rem 0 1.2rem; }
.hero h1 { font-size: 1.7rem; }
.hero p { color: var(--muted); margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .9rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.game-card { display: flex; flex-direction: column; transition: transform .12s, border-color .12s; }
.game-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.game-card.is-pinned { order: -1; }
.card-cover { aspect-ratio: 1 / 1; background: var(--surface2); display: grid; place-items: center; overflow: hidden; }
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.card-cover-fallback { font-size: 2.4rem; opacity: .5; }
.card-body { padding: .7rem .8rem .8rem; }
.card-body h2 { font-size: .98rem; }
.card-meta { display: flex; align-items: center; gap: .4rem; font-size: .8rem; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; background: var(--surface2); border: 1px solid var(--border); font-size: .72rem; }
.badge-official { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
.badge-warn { background: var(--danger); color: #fff; border-color: transparent; }
.pin { margin-left: auto; background: none; border: 0; font-size: 1.05rem; color: var(--muted); padding: 0 .2rem; }
.pin.is-on { color: var(--accent); }

/* 게임 */
.game-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.game-head h1 { font-size: 1.35rem; margin: 0; }
.game-head-meta { display: flex; align-items: center; gap: .5rem; }
.bar { position: sticky; top: 3.2rem; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .5rem .8rem; margin-bottom: .8rem; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 12px; }
.bar-group { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.bar-label { font-size: .78rem; color: var(--muted); font-weight: 600; }
.bar-actions { margin-left: auto; }
.bar-excluded { flex-basis: 100%; border-top: 1px solid var(--border); padding-top: .5rem; max-height: 40vh; overflow: auto; }
.seg { display: flex; flex-wrap: wrap; gap: .3rem; }
.seg label { padding: .3rem .7rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface2); cursor: pointer; font-size: .9rem; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip { padding: .28rem .65rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface2); cursor: pointer; font-size: .85rem; color: var(--muted); }
.chip input { display: none; }
.chip::before { content: ''; display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .4rem; vertical-align: -1px; border: 1px solid var(--muted); }
.chip.is-on { color: var(--accent-ink); border-color: var(--accent); background: var(--accent); font-weight: 700; }
.chip.is-on::before { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.is-on { border-color: var(--accent); color: var(--accent); }
.checks { display: flex; flex-wrap: wrap; gap: .4rem .9rem; }
.checks label { display: inline-flex; gap: .4rem; align-items: center; cursor: pointer; }
.pool { margin: .3rem 0 .6rem; }
.pool-head { display: flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.pool-head .muted { font-weight: 400; }
.pool-items { display: flex; flex-wrap: wrap; gap: .2rem .7rem; font-size: .85rem; }
.pool-items label { display: inline-flex; gap: .3rem; align-items: center; cursor: pointer; }
.pool-items label.is-off { opacity: .45; }
.setup-block { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 .9rem; background: var(--surface); }
.setup-block legend, .setup-block summary { font-weight: 700; padding: 0 .3rem; cursor: pointer; }
.btn { padding: .5rem .95rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface2); font-weight: 600; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn-big { padding: .8rem 1.8rem; font-size: 1.05rem; }
.btn-sm { padding: .3rem .6rem; font-size: .82rem; }

/* 슬롯 배치: 연구판(6열 격자)·부채꼴 */
.slot-grid .tiles { display: grid; grid-template-columns: repeat(var(--cols, 6), max-content); gap: 6px; justify-content: start; }
.result-center .slot-grid .tiles { justify-content: center; }
/* flow: 격자 대신 줄바꿈 flex — 마지막 줄도 가운데 (예: 궁전 5장 = 3+2) */
.slot-grid.slot-flow .tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.slot-grid.slot-flow .tiles .tile { flex: 0 0 auto; width: calc((100% - 6px * (var(--cols, 3) - 1)) / var(--cols, 3) - 1px) !important; height: auto !important; aspect-ratio: var(--ar, 1.8); max-width: 260px; }
@media (max-width: 640px) { .slot-grid.slot-flow .tiles .tile { width: calc((100% - 6px * (var(--mcols, 3) - 1)) / var(--mcols, 3) - 1px) !important; max-width: none; } }
.slot-grid .tiles .tile-span2 { grid-column: span 2; justify-self: center; }
.tiles-headers { display: grid; grid-template-columns: repeat(var(--cols, 6), var(--tw, 120px)); gap: 6px; font-size: .68rem; color: var(--muted); margin-bottom: .15rem; }
.tiles-headers span { text-align: center; white-space: nowrap; overflow: hidden; }
.slot-fan .tiles { overflow: visible; margin: 0 auto; }
.slot-fan .tile { transform-origin: 50% 50%; }
@media (max-width: 640px) { .slot-grid .tiles { grid-template-columns: repeat(var(--mcols, 3), max-content); } .tiles-headers { display: none; } }

/* 가이아 보드형 배치 */
.gb { margin-bottom: 1rem; }
.gb h2 { font-size: .8rem; font-weight: 600; color: var(--muted); margin: 0 0 .3rem; }
.gb .tile { height: auto; width: 100%; cursor: zoom-in; }
.gb .tile img { width: 100%; height: auto; padding: 0; min-width: 0; max-width: none; border-radius: 6px; }
.gb-row { display: flex; flex-wrap: wrap; gap: 4px; }
.gb-factions .gb-row { gap: 6px; flex-wrap: nowrap; }
.gb-faction { flex: 1 1 0; min-width: 0; max-width: 360px; }
.gb-grid6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.gb-head { text-align: center; font-size: .68rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gb-cell { background: color-mix(in srgb, var(--c, #222) 55%, #000); border-radius: 8px; padding: 4px; display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; min-height: 40px; }
.gb-cell .tile { max-width: 150px; }
.gb-cell.gb-blank { background: none; }
.gb-span2 { grid-column: span 2; }
.gb-span3 { grid-column: span 3; }
.gb-rows2 { grid-row: span 2; }
.gb-std { background: var(--surface2); }
.gb-terra-title { font-size: .72rem; color: var(--text); margin-bottom: .2rem; text-align: center; }
.gb-terra-row { display: flex; flex-wrap: nowrap; gap: 6px; justify-content: center; }
.gb-terra-title { font-size: .85rem; margin-bottom: .5rem; }
.gb-terra-item { display: flex; flex-direction: column; align-items: center; gap: .15rem; font-size: .7rem; color: var(--text); }
.gb-terra-line { display: flex; align-items: center; justify-content: center; gap: .8rem; margin: .3rem 0; flex-wrap: nowrap; }
.gb-terra-icon { width: 32px; height: 32px; border-radius: 50%; background-size: auto 100%; background-position: 4% 50%; border: 2px solid rgba(255,255,255,.5); flex: none; }
.gb-terra-line .tag { position: static; }
.gb-terra-who { font-size: .8rem; font-weight: 700; min-width: 5.5em; }
.gb-terra-dot.is-common { box-shadow: 0 0 0 3px var(--accent); }
.gb-terra-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; flex: none; }
.gb-terra-seven .gb-terra-dot { width: 18px; height: 18px; }
.gb-terra-how { font-size: .68rem; color: var(--muted); text-align: center; margin-top: .35rem; line-height: 1.35; }
.gb-terra-dot.is-three { box-shadow: 0 0 0 2px var(--accent); }
.gb-terra-dot.is-used { opacity: .3; }
.gb-shipgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
/* 우주선 카드: [로고·연합 토큰] | 싣고 있는 것(기술 타일 1장 또는 유물 4장) — 모두 한 줄 높이로 */
.gb-ship { display: flex; align-items: center; gap: 8px; background: color-mix(in srgb, var(--c) 45%, #000); border-radius: 10px; padding: 6px 8px; min-height: 68px; }
.gb-ship-empty { background: none; border: 1px dashed var(--border); opacity: .4; }
.gb-shiphead { display: flex; align-items: center; gap: 6px; flex: none; }
.gb-ship .tile { height: 56px; width: auto; }
.gb-ship .tile img { min-width: 0; max-width: none; padding: 0; height: 100%; width: auto; }
.gb-ship .gb-logo { height: 44px; }
.gb-shipcargo { display: flex; flex-wrap: nowrap; justify-content: center; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.gb-shipcargo .gb-art { height: 48px; }
.gb-score { display: grid; grid-template-columns: 3fr 2fr; gap: 1.2rem; align-items: start; }
.gb-score > * { min-width: 0; }
.gb-scoreleft .slot-fan { margin-bottom: 0; }
.slot-arc .tile { background: none; box-shadow: none; border-radius: 0; overflow: visible; }
.slot-arc .tile::after { display: none; }
.slot-arc .tile img, .slot-arc.slot .tile-fit img { padding: 0; border-radius: 0; object-fit: contain; }
.gb-final .gb-row { justify-content: center; margin-top: -4px; }
.gb-final .gb-row .tile { width: calc(32% - 2px); max-width: 200px; }
.gb-boosters .gb-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; max-width: 290px; margin: 0 auto; }
.gb-boosters .gb-row .tile { width: 100% !important; }
@media (max-width: 640px) {
  .gb-head { font-size: .55rem; }
  .gb-cell { padding: 2px; border-radius: 6px; gap: 2px; }
  .gb-shipgrid { gap: 4px; }
  .gb-ship { flex-direction: column; align-items: stretch; gap: 4px; padding: 5px; min-height: 0; }
  .gb-shiphead { justify-content: center; }
  .gb-ship .tile { height: 44px; }
  .gb-ship .gb-logo { height: 36px; }
  .gb-shipcargo { flex: none; }
  .gb-shipcargo .gb-shiptech { height: 40px; }
  .gb-shipcargo .gb-art { height: auto; width: calc(25% - 3px); }
  .gb-shipcargo .gb-art img { width: 100%; height: auto; }
  .gb-score { grid-template-columns: 1fr; gap: .6rem; }
  .gb-final .gb-row .tile { width: calc(36% - 2px); }
  .gb-boosters .gb-row { display: flex; justify-content: center; gap: 4px; max-width: none; }
  .gb-boosters .gb-row .tile { flex: 1 1 0; max-width: 52px; }
  .gb-terra-dot { width: 16px; height: 16px; border-width: 1.5px; }
  .gb-terra-seven .gb-terra-dot { width: 13px; height: 13px; }
  .gb-terra-row { gap: 4px; }
  .gb-terra-icon { width: 24px; height: 24px; }
  .gb-terra-line { gap: .4rem; }
  .gb-terra-how { font-size: .55rem; }
  .gb-terra .small, .gb-terra-title .muted { display: none; }
  .gb-terra-title { font-size: .6rem; }
  .gb-cell .tile { max-width: 110px; }
}

/* 육각 맵 */
.hexmap { max-width: 900px; }
.hexmap-tools { display: none; margin: .25rem 0; }
.hexmap.is-zoomed { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.hexmap.is-zoomed svg { width: 220%; }
.hexmap svg { width: 100%; height: auto; display: block; background: radial-gradient(circle at 40% 30%, #1b2140, #0b0d17 70%); border-radius: 12px; }
.hexmap .hx { fill: rgba(255,255,255,.04); stroke: rgba(255,255,255,.28); stroke-width: 1; }
.hexmap .sector { cursor: pointer; transition: transform .25s; }
.hexmap .sector:hover image { filter: brightness(1.15); }
.hexmap .hx-is-edge, .hexmap .hx-ds-edge { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
.hexmap .hx-ds-num { fill: #fff; font-size: 13px; font-weight: 800; text-anchor: middle; paint-order: stroke; stroke: rgba(0,0,0,.75); stroke-width: 3px; pointer-events: none; }
.hexmap .hx-is { fill: rgba(20,10,40,.85); stroke: #ff6ec7; stroke-width: 2.5; }
.hexmap .hx-ds { fill: rgba(10,10,30,.9); stroke: #ff6ec7; stroke-width: 2.5; }
.hexmap .hx-ship { font-size: 18px; text-anchor: middle; }
.hexmap .hx-ship-name { fill: #fff; font-size: 9px; text-anchor: middle; font-weight: 700; }
.hexmap .hx-ds-label { fill: #ff9ee0; font-size: 14px; font-weight: 800; text-anchor: middle; paint-order: stroke; stroke: rgba(0,0,0,.8); stroke-width: 3px; pointer-events: none; }
.select-sm { width: auto; max-width: 250px; padding: .3rem .5rem; font-size: .85rem; }
.hexmap .hx-bad { fill: rgba(255,60,60,.35); stroke: #ff4d4d; stroke-width: 3; pointer-events: none; }
.hexmap .hx-label { fill: #fff; font-size: 22px; font-weight: 800; text-anchor: middle; paint-order: stroke; stroke: rgba(0,0,0,.7); stroke-width: 3px; pointer-events: none; }

/* 결과: 타일을 원화 비율 그대로 빽빽하게 */
.result .slot { margin-bottom: .55rem; }
.result .slot h2 { font-size: .8rem; font-weight: 600; color: var(--muted); margin: 0 0 .2rem; display: flex; align-items: center; gap: .5rem; }
.tiles { display: flex; flex-wrap: wrap; gap: 3px; }
.slot-sum { font-size: .75rem; font-weight: 700; color: var(--accent-ink); background: var(--accent); border-radius: 999px; padding: .05rem .5rem; }
/* 도움말·가운데 정렬 */
.help-box { margin: 0 0 .8rem; padding: .6rem .8rem; border-radius: 10px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border)); font-size: .82rem; line-height: 1.5; }
.result-center .slot h2, .result-center .slot-note, .result-center .help-box { text-align: center; justify-content: center; }
.result-center .tiles { justify-content: center; }
.result-center .tile-name { text-align: center; }
.result-center .pcards { justify-content: center; }
.result-center .pcard-head { justify-content: center; }
.result-center .pc-items { justify-content: center; }
.result-center .pc-label { text-align: center; }
/* 겹치기 (최종 점수 타일 → 6라운드 타일 위) */
.tile-stack { position: relative; display: inline-block; }
.tile-stack .tile-over { position: absolute; top: 0; right: 0; bottom: 0; left: auto; width: auto !important; background: none; box-shadow: none; z-index: 2; filter: drop-shadow(-2px 0 3px rgba(0,0,0,.6)); }
.tile-stack .tile-over::after { display: none; }
.tile-stack .tile-over img { object-fit: contain; width: auto; height: 100%; min-width: 0; }
.slot-grid .tiles .tile-stack { display: block; }
/* 두 열 세로 나열 (라운드 점수 | 서적 행동) */
.slot-pair { display: flex; justify-content: center; gap: 1.2rem; align-items: flex-start; }
.pair-col { display: flex; flex-direction: column; align-items: center; width: min(46%, 300px); }
.pair-col h2 + .tiles-col { margin-bottom: .8rem; }
.pair-col .tile-name { text-align: center; margin: .2rem 0 .4rem; }
.pair-col .tiles-col { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.pair-col .tile, .pair-col .tile-stack { width: 100%; height: auto; }
.pair-col .tile img { width: 100%; height: auto; min-width: 0; max-width: none; padding: 0; }
.pair-col .tile-stack .tile-over { width: auto !important; }
.pair-col .tile-stack .tile-over img { width: auto; height: 100%; }
/* 세트(zip) 열 */
.zip-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; }
.zip-col { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: .4rem; display: flex; flex-direction: column; gap: .35rem; align-items: center; }
.zip-num { font-size: .72rem; font-weight: 800; color: var(--muted); }
.zip-item { width: 100%; }
.zip-item .tile { height: auto; width: 100%; }
.zip-item .tile img { width: 100%; height: auto; min-width: 0; max-width: none; padding: 0; }
.zip-text { font-size: .8rem; font-weight: 600; text-align: center; padding: .35rem .3rem; border: 1px solid var(--border); border-radius: 8px; }
.zip-item .tile-name { text-align: center; margin-top: .15rem; font-size: .72rem; }
@media (max-width: 640px) { .zip-cols { grid-template-columns: repeat(2, 1fr); } }
/* 플레이어 카드 */
.pcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.pcard { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: .6rem .7rem; display: flex; flex-direction: column; gap: .5rem; }
.pcard-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.pcard-head .tag { position: static; display: inline-block; font-size: .8rem; padding: .1rem .55rem; }
.pc-chip { font-weight: 800; font-size: 1.05rem; }
.pc-chip small { font-weight: 400; color: var(--muted); margin-right: .35rem; }
.pc-note { font-size: .78rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .1rem .55rem; }
.pc-label { font-size: .74rem; color: var(--muted); margin-bottom: .25rem; }
.pc-items { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.pc-text { font-size: 1.05rem; font-weight: 800; }
.pc-item { flex: 1 1 0; min-width: 0; max-width: 150px; }
@media (max-width: 640px) { .pcards { gap: 8px; } .pcard { padding: .5rem .6rem; gap: .35rem; } .pc-item { max-width: 120px; } .tiles-named .tile-wrap { max-width: calc(33.33% - 7px); } .tiles-named .tile { max-width: 100%; } }
.pc-item .tile { height: auto; width: 100%; aspect-ratio: 1 / 1; }
.pc-item .tile img { object-fit: cover; height: 100%; }
.pc-item .tile img { width: 100%; height: auto; min-width: 0; max-width: none; padding: 0; }
.pc-item .tile-name { margin-top: .2rem; font-size: .74rem; }
.slot-players .tiles-named { display: none; }
.slot-note { margin: -.1rem 0 .4rem; font-size: .74rem; line-height: 1.4; color: var(--muted); }
.tiles-named { gap: 8px 10px; }
.tile-wrap { display: flex; flex-direction: column; gap: .2rem; max-width: 260px; }
.tile-name { font-size: .78rem; font-weight: 600; line-height: 1.3; }
.tile-name b { display: block; font-weight: 700; }
.tile-name small { display: block; font-weight: 400; color: var(--muted); font-size: .7rem; }
.tile { position: relative; margin: 0; height: 118px; cursor: zoom-in; border-radius: 8px; overflow: hidden; background: #0b0d14; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 1px 2px rgba(0,0,0,.4); }
.tile::after { content: ''; position: absolute; inset: 0; border-radius: 8px; pointer-events: none; box-shadow: inset 0 0 18px rgba(0,0,0,.35); }
.tile img { height: 100%; width: auto; max-width: 70vw; min-width: 64px; display: block; padding: 2px; box-sizing: border-box; border-radius: 8px; }
.tile-fit img { width: 100%; height: 100%; object-fit: cover; min-width: 0; max-width: none; }
.gb .slot-fan .tile { width: auto; height: 118px; }
.gb .slot-fan .tile img { width: auto; height: 100%; }
.tile-wide { height: 84px; }
.tile-tall { height: 150px; }
.slot-few .tile { height: 150px; }
.slot-few .tile-wide { height: 120px; }
.tile-noimg, .slot .tiles .tile-noimg { height: auto; min-height: 0; cursor: default; padding: .35rem .5rem; border: 1px solid var(--border); display: flex; align-items: center; box-sizing: border-box; }
.tile-noimg .tile-text { font-size: .8rem; font-weight: 600; padding-left: 1.7rem; line-height: 1.3; overflow-wrap: anywhere; }
.slot-text .tile-noimg .tile-text { padding-left: 0; }
.slot-text .tile-noimg .tag ~ .tile-text { padding-left: 1.9rem; }
.tag { position: absolute; top: .25rem; left: .25rem; z-index: 1; min-width: 1.35rem; text-align: center; padding: .05rem .35rem; border-radius: 999px; font-size: .72rem; font-weight: 800; background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.tag.player { color: #fff; }
.p1 { background: var(--p1); } .p2 { background: var(--p2); } .p3 { background: var(--p3); } .p4 { background: var(--p4); }
.p5 { background: var(--p5); } .p6 { background: var(--p6); } .p7 { background: var(--p7); } .p8 { background: var(--p8); }
.warn { color: var(--danger); font-size: .8rem; font-weight: 500; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 40; padding: 1rem; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: .9rem 1rem 1rem; width: min(420px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
/* 광고 제거 구독 (앱 안에서만 native.js 가 띄운다) */
.adfree { display: flex; flex-direction: column; gap: .6rem; }
.adfree-plan { display: flex; flex-direction: column; gap: .15rem; padding: .7rem .8rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface2); }
.adfree-plan b { font-size: 1.05rem; }
.adfree-price { font-weight: 700; color: var(--accent); }
.adfree-benefit, .adfree-status { margin: 0; font-size: .9rem; line-height: 1.5; }
.adfree-status { font-weight: 700; }
.adfree-buy { width: 100%; padding: .75rem; }
.adfree-buy:disabled { opacity: .55; }
.adfree-restore { align-self: center; }
.adfree-fine { margin: 0; font-size: .75rem; line-height: 1.5; color: var(--muted); }
.adfree-links a { text-decoration: underline; }
.chips-col { flex-direction: column; align-items: stretch; gap: .4rem; }
.chips-col .chip { padding: .55rem .8rem; font-size: .95rem; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 50; cursor: zoom-out; padding: 1rem; }
.lightbox { flex-direction: column; }
.lightbox img { max-width: 100%; max-height: 85vh; object-fit: contain; }
.lightbox-cap { color: #fff; margin-top: .6rem; font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--surface2); border: 1px solid var(--border); padding: .6rem 1rem; border-radius: 999px; z-index: 60; font-size: .9rem; }

@media (max-width: 640px) {
  html, body { overflow-x: hidden; max-width: 100%; }
  body { padding-bottom: 1rem; }
  .page { padding: .8rem .8rem 3rem; }
  .game-head h1 { font-size: 1.2rem; }
  /* 설정 바는 고정하지 않고(화면 1/4 을 먹는다) 위에 두고, 하단 고정 바로 다시 뽑는다 */
  .bar { position: static; padding: .5rem .7rem; gap: .35rem .6rem; border-radius: 12px; margin: 0 0 .6rem; }
  .bar-group { gap: .3rem; }
  .bar-label { font-size: .72rem; }
  .seg label { padding: .28rem .6rem; font-size: .85rem; }
  .chip { padding: .22rem .55rem; font-size: .8rem; }
  .select-sm { max-width: 100%; font-size: .8rem; }
  .bar-actions { margin-left: 0; width: 100%; }
  .bar-actions .btn-primary { flex: 1; }
  .hexmap-tools { display: block; }
  .result .slot h2 { font-size: .78rem; }
  .tiles { gap: 3px; }
  .lightbox img { max-height: 80vh; }
  .toast { bottom: 5rem; }
  .topbar { gap: .5rem; padding: .45rem .8rem; }
  .topbar-search { display: none; }
  body.is-home .topbar { flex-wrap: wrap; }
  body.is-home .topbar-search { display: block; order: 3; flex-basis: 100%; max-width: none; }
  .topbar-nav { gap: .55rem; font-size: .82rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .bar-actions { margin-left: 0; }
  .tile { height: 88px; }
  .tile-wide { height: 64px; }
  .tile-tall { height: 120px; }
}

/* 인증·내 목록·폼 */
.auth { max-width: 420px; margin: 2rem auto; text-align: center; }
.auth-buttons { display: flex; flex-direction: column; gap: .6rem; margin: 1.2rem 0; }
.btn-kakao { background: #fee500; color: #191919; border-color: transparent; }
.btn-apple { background: #000; color: #fff; border-color: #333; }
:root[data-theme="light"] .btn-apple { background: #000; }
.small { font-size: .78rem; }
.form { display: flex; gap: .5rem; }
.input, .textarea, .select { width: 100%; padding: .55rem .8rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); outline: none; font: inherit; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-head h1 { margin: 0; font-size: 1.4rem; }
.row-card { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding: .8rem 1rem; margin-bottom: .6rem; }
.row-main { flex: 1; min-width: 200px; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.badge-approved { background: var(--ok); color: #062; border-color: transparent; }
.badge-pending { background: var(--accent2); color: #fff; border-color: transparent; }
.badge-rejected { background: var(--danger); color: #fff; border-color: transparent; }

/* 에디터 */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
.editor-side .sticky { position: sticky; top: 4rem; }
.field { display: block; margin-bottom: .7rem; font-size: .9rem; }
.field .input, .field .select, .field .textarea { margin-top: .25rem; }
.field-row { display: flex; gap: .6rem; }
.field-row .field { flex: 1; }
.cover-row { display: flex; align-items: center; gap: .5rem; margin-top: .3rem; }
.cover-thumb { width: 64px; height: 64px; border-radius: 8px; background: var(--surface2); overflow: hidden; display: grid; place-items: center; }
.cover-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ed-row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .4rem; }
.ed-row .input, .ed-row .select { width: auto; flex: 1; min-width: 100px; }
.ed-row .input.short { flex: 0 0 70px; min-width: 0; }
.ed-row .thumb { width: 36px; height: 36px; border-radius: 6px; background: var(--surface2); object-fit: cover; flex: none; cursor: pointer; display: grid; place-items: center; font-size: .8rem; overflow: hidden; }
.ed-row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.pool-tabs { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .6rem; }
.pool-tab { padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface2); font-size: .85rem; }
.pool-tab.is-active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.ed-slot { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .6rem; background: var(--surface2); }
.ed-slot-rules { margin-top: .4rem; font-size: .85rem; display: flex; flex-direction: column; gap: .3rem; }
.errors { color: var(--danger); font-size: .85rem; margin-top: .6rem; white-space: pre-wrap; }
.preview-result .slot h2 { font-size: .95rem; }
.preview-result .tile { height: 64px; }
.paste-box { width: 100%; min-height: 70px; }
@media (max-width: 860px) { .editor-grid { grid-template-columns: 1fr; } .editor-side .sticky { position: static; } }

/* 관리 */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--border); }
.json { font-size: .78rem; overflow: auto; max-height: 60vh; background: var(--surface2); padding: .8rem; border-radius: 8px; }

/* 안내 페이지 (개인정보·약관·지원) */
.prose { max-width: 720px; margin: 1rem auto 2rem; line-height: 1.65; font-size: .95rem; }
.prose h1 { font-size: 1.5rem; margin: 0 0 .3rem; }
.prose h2 { font-size: 1.1rem; margin: 1.6rem 0 .5rem; }
.prose h3 { font-size: 1rem; margin: 1.2rem 0 .3rem; }
.prose p, .prose ul { margin: .5rem 0; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin: .3rem 0; }
.prose a { text-decoration: underline; }
