@font-face {
    font-family: 'NanumGothic';
    src: url("../font/NanumGothic.ttf") format('truetype');
}

/* 동아리방 노트 위에 그린 보드게임: 모눈종이, 잉크 외곽선, 형광펜 강조 */
:root {
    --attack: #e5513a;
    --defense: #3a9ae0;
    --upgrade: #4bcb65;
    --special: #f5c400;
    --paper: #ffffff;
    --sheet: #f4f7fb;
    --grid: #dce5f0;
    --ink: #1b1b1b;
    --muted: #6d7380;
    --marker: #ffe14d;
    --hard: 3px 3px 0 var(--ink);
    --title: 'Jua', 'NanumGothic', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html {
    font-family: 'NanumGothic', sans-serif;
    color: var(--ink);
    background: var(--sheet);
}
body {
    min-height: 100vh;
    background-color: var(--sheet);
    background-image:
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 24px 24px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
button { font-family: inherit; }
:focus-visible { outline: 3px solid var(--defense); outline-offset: 2px; }

.btn {
    font-family: var(--title);
    font-size: 16px;
    padding: 8px 18px;
    border: 2px solid var(--ink);
    border-radius: 10px;
    background: var(--paper);
    color: var(--ink);
    cursor: pointer;
    box-shadow: var(--hard);
    transition: transform .08s, box-shadow .08s;
}
.btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
a.btn { text-decoration: none; display: inline-block; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--marker); }
.btn.big { font-size: 21px; padding: 11px 30px; }
.btn.small { font-size: 14px; padding: 4px 11px; box-shadow: 2px 2px 0 var(--ink); }

/* 카드 이름 참조 (기록, 태그) */
.cref { font-weight: bold; cursor: help; border-bottom: 2px solid currentColor; }
.r-attack { color: #c63b25; }
.r-defense { color: #1f78c1; }
.r-upgrade { color: #23933f; }
.r-special { color: #a47f00; }

/* ───────── 시작 화면 ───────── */
.setup { max-width: 1000px; margin: 0 auto; padding: 72px 16px 40px; text-align: center; }
.logo {
    font-family: var(--title); font-weight: 400; font-size: 72px; line-height: 1; margin: 0;
    display: inline-flex; align-items: center; gap: 12px;
}
.logo-die {
    display: inline-flex; align-items: center; justify-content: center;
    width: 76px; height: 76px; font-size: 64px; line-height: 1;
    background: var(--marker); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 4px 4px 0 var(--ink);
    transform: rotate(-8deg);
}
.tagline { color: var(--muted); font-size: 17px; margin: 14px 0 30px; }
.solo-title { font-family: var(--title); font-weight: 400; font-size: 26px; margin: 26px 0 14px; }
.logo + .tribe-picks { margin-top: 32px; }
.tribe-picks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.tribe-pick {
    background: var(--paper);
    border: 5px solid var(--tc);
    border-radius: 14px;
    padding: 10px 8px 12px;
    box-shadow: 0 0 0 2px var(--ink), 4px 4px 0 2px var(--ink);
    transition: opacity .2s, filter .2s;
}
.tribe-pick.off { opacity: .45; filter: grayscale(.8); }
.tribe-pick img { width: 100%; max-width: 150px; aspect-ratio: 1; object-fit: contain; cursor: pointer; }
.tp-name { font-family: var(--title); font-size: 22px; margin: 2px 0 6px; }
.tp-trait { font-size: 13px; min-height: 20px; margin-bottom: 10px; }
.tp-trait.disabled { opacity: .35; text-decoration: line-through; }
.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; }
.seg button {
    border: 0; background: var(--paper); padding: 6px 12px; cursor: pointer;
    font-family: var(--title); font-size: 15px; color: var(--ink);
}
.seg button + button { border-left: 2px solid var(--ink); }
.seg button.on { background: var(--marker); }
.options { margin: 28px auto 0; display: flex; justify-content: center; }
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; text-align: left;
    background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; padding: 10px 16px; box-shadow: var(--hard); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.track { flex: none; width: 46px; height: 26px; border: 2px solid var(--ink); border-radius: 999px; background: #e7ebf1; position: relative; transition: background .15s; }
.track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); transition: transform .15s; }
.switch input:checked + .track { background: var(--marker); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 3px solid var(--defense); outline-offset: 2px; }
.switch-text b { font-family: var(--title); font-weight: 400; font-size: 17px; margin-right: 6px; }
.credit { margin: 26px 0 10px; }
.links { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.links a {
    width: 42px; height: 42px; display: inline-flex;
    border: 2px solid var(--ink); border-radius: 11px; overflow: hidden; box-shadow: var(--hard);
    transition: transform .08s, box-shadow .08s;
}
.links a:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.links img { width: 100%; height: 100%; object-fit: cover; display: block; }
.setup-actions { margin: 26px 0 12px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ───────── 온라인 대전 ───────── */
.online-box {
    max-width: 520px; margin: 30px auto 0; padding: 16px 18px 18px;
    background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; box-shadow: 4px 4px 0 var(--ink);
}
.online-box h2 { font-family: var(--title); font-weight: 400; font-size: 26px; margin: 0 0 4px; }
.online-box p { margin: 0 0 12px; font-size: 14px; }
.online-row { display: flex; gap: 10px; margin-top: 10px; }
.online-row .btn { flex: none; min-width: 112px; }
.field {
    flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 8px 12px;
    border: 2px solid var(--ink); border-radius: 10px; background: var(--paper); color: var(--ink);
}
.field.code { text-transform: uppercase; letter-spacing: 3px; font-weight: bold; }
.field::placeholder { font-family: 'NanumGothic', sans-serif; font-weight: normal; letter-spacing: normal; text-transform: none; color: var(--muted); opacity: 1; }
.setup { position: relative; }
.back-link { position: absolute; top: 12px; left: 16px; }
.logo.small { font-size: 44px; }
.logo.small .logo-die { width: 50px; height: 50px; font-size: 40px; border-radius: 12px; }
.lobby-code { margin: 18px 0 24px; font-size: 17px; display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.lobby-code b { font-family: var(--title); font-weight: 400; font-size: 32px; letter-spacing: 4px; background: var(--marker); border: 2px solid var(--ink); border-radius: 10px; padding: 0 12px; }
.tribe-pick.mine { box-shadow: 0 0 0 2px var(--ink), 0 0 0 6px var(--marker), 4px 4px 0 6px var(--ink); }
.seat-who { font-family: var(--title); font-size: 17px; min-height: 26px; margin-bottom: 8px; overflow-wrap: anywhere; }
.seat-act { display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 34px; }
.lobby-opts { gap: 14px; flex-wrap: wrap; align-items: center; }
.speed-pick { display: inline-flex; align-items: center; gap: 10px; background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 14px; box-shadow: var(--hard); }
.speed-pick b { font-family: var(--title); font-weight: 400; font-size: 17px; }
.seg button:disabled { cursor: default; color: var(--ink); }
.switch input:disabled + .track { opacity: .5; }
.flag.timer { background: var(--paper); cursor: default; }
.flag.timer.hot { background: var(--attack); color: #fff; }
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200;
    max-width: calc(100% - 32px); padding: 10px 18px; font-family: var(--title); font-size: 17px;
    background: var(--ink); color: #fff; border-radius: 12px; box-shadow: var(--hard);
}

/* ───────── 게임 화면 ───────── */
.topbar {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 9px 18px;
    background: var(--paper); border-bottom: 2px solid var(--ink);
}
.brand { font-family: var(--title); font-size: 24px; }
.stat { font-size: 14px; }
.stat select { margin-left: 4px; font-family: inherit; border: 2px solid var(--ink); border-radius: 6px; padding: 2px 4px; }
.flag { font-family: var(--title); background: var(--marker); border: 2px solid var(--ink); border-radius: 8px; padding: 2px 10px; cursor: help; }
.spacer { flex: 1; }

.layout { display: grid; grid-template-columns: 1fr 300px; gap: 18px; padding: 18px; max-width: 1500px; margin: 0 auto; }
.main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* 플레이어 패널: 테두리가 종족 색, 바깥은 잉크 선 */
.players { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 14px; }
.player {
    position: relative;
    background: var(--paper);
    border: 5px solid var(--tc);
    border-radius: 14px;
    padding: 8px;
    box-shadow: 0 0 0 2px var(--ink), 4px 4px 0 2px var(--ink);
    display: flex; flex-direction: column; gap: 8px;
    transition: transform .2s, opacity .3s;
}
.player.active { background: #fffbe0; }
.player.dead { opacity: .5; filter: grayscale(1); }
.player.targetable { cursor: pointer; background: #fff3f0; }
.player.targetable:hover { transform: translate(-2px, -2px); box-shadow: 0 0 0 2px var(--ink), 6px 6px 0 2px var(--attack); }
.player.flash-hit { animation: hit .6s; }
.player.flash-up { animation: up .8s; }
@keyframes hit { 20%, 60% { transform: translateX(-6px); background: #ffe1db; } 40%, 80% { transform: translateX(6px); } }
@keyframes up { 30% { transform: translateY(-6px); background: #e3f9e7; } }
.p-head { display: flex; align-items: center; gap: 8px; }
.p-head img { width: 54px; height: 54px; object-fit: contain; flex: none; }
.p-meta { flex: 1; min-width: 0; }
.p-name { font-family: var(--title); font-size: 18px; line-height: 1.25; word-break: keep-all; overflow-wrap: anywhere; }
.who { display: inline-block; white-space: nowrap; font-size: 12px; padding: 0 7px; border-radius: 6px; border: 1.5px solid var(--ink); background: var(--tc); color: var(--ton); vertical-align: 2px; }
.life { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.life-bar { flex: 1; height: 12px; border-radius: 6px; border: 2px solid var(--ink); background: #fff; overflow: hidden; }
.life-bar i { display: block; height: 100%; background: var(--attack); transition: width .5s; }
.life span { font-family: var(--title); font-size: 20px; min-width: 24px; text-align: right; }
.p-dice { display: flex; flex-wrap: wrap; gap: 7px; min-height: 36px; align-items: center; padding: 2px; }
.p-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
    font-size: 12px; padding: 2px 8px; border-radius: 6px;
    background: #fff; border: 1.5px solid var(--ink); cursor: help;
}
.tag:hover { background: var(--marker); }
.tag.plain { border-color: transparent; background: transparent; cursor: default; color: var(--muted); }
.tag.plain:hover { background: transparent; }
.tag.hot { background: var(--marker); }
.p-played { display: flex; justify-content: center; min-height: 112px; align-items: center; }
.p-played [data-card] { cursor: help; }
.slot-empty { font-size: 13px; color: var(--muted); border: 2px dashed #c5cdd8; border-radius: 10px; padding: 36px 8px; width: 80px; text-align: center; }
.dead-mark, .target-mark {
    position: absolute; top: 46%; left: 50%; transform: translate(-50%, -50%) rotate(-12deg);
    font-family: var(--title); font-size: 32px; color: #c0392b; border: 4px solid #c0392b;
    padding: 2px 14px; border-radius: 10px; background: rgba(255,255,255,.85);
    white-space: nowrap; width: max-content; pointer-events: none;
}
.target-mark { transform: translate(-50%, -50%) rotate(-4deg); font-size: 22px; color: var(--ink); border: 2px solid var(--ink); background: var(--marker); box-shadow: var(--hard); }

/* 주사위: 잉크 외곽선 + 종족 색 테두리 + 흰 면 */
.die {
    --dc: #fff;
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 9px;
    background: #fff; border: 4px solid var(--dc);
    box-shadow: 0 0 0 2px var(--ink), 3px 3px 0 2px var(--ink);
    font-family: var(--title); font-size: 15px; line-height: 1;
}
.die.big { background: #fff7c7; }
.die.buffed { background: #ffe0d4; }
.die.merc { border-style: dashed; }
.die.temp { background: #e8f3fc; }
.die.baby { width: 38px; height: 34px; background: none; border: 0; box-shadow: none; }
.die.baby .tri { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.die.baby .tri polygon { stroke-linejoin: round; }
.die.baby .tri .sh { fill: var(--ink); stroke: var(--ink); stroke-width: 4; }
.die.baby .tri .ol { fill: var(--ink); stroke: var(--ink); stroke-width: 8; }
.die.baby .tri .in { fill: #fff; stroke: var(--dc); stroke-width: 4; }
.die.baby b { position: relative; top: 5px; font-size: 13px; }
.die.out { opacity: .25; }
.die.banned { opacity: .3; }
.die.banned::after { content: '✕'; position: absolute; font-size: 26px; color: var(--attack); }
.die.current { transform: translateY(-3px); }
.die.current:not(.baby) { box-shadow: 0 0 0 2px var(--ink), 0 0 0 6px var(--marker), 3px 3px 0 6px var(--ink); }

/* 아레나 */
.arena {
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 18px;
    padding: 18px;
    min-height: 270px;
    box-shadow: 5px 5px 0 var(--ink);
}
.arena.battle-mode { background: #fffaf8; }
.arena.tournament { background: #fffcea; }
.phase { text-align: center; }
.phase h2 { font-family: var(--title); font-weight: 400; font-size: 32px; margin: 4px 0; }
.phase p { color: var(--muted); margin: 4px 0 14px; }
.reveal { display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; }
.reveal-item { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ri-name { font-family: var(--title); display: flex; align-items: center; gap: 4px; }
.ri-name img { width: 30px; height: 30px; }

.battle { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center; }
.side { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.side-head { display: flex; align-items: center; gap: 8px; }
.side-head img { width: 60px; height: 60px; }
.side-name { font-family: var(--title); font-size: 22px; }
.side-role { font-size: 13px; color: var(--muted); }
.face {
    --dc: #fff;
    min-width: 104px; height: 104px; padding: 0 12px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--title); font-size: 42px;
    background: #fff; border: 7px solid var(--dc); border-radius: 22px;
    box-shadow: 0 0 0 3px var(--ink), 5px 5px 0 3px var(--ink);
    transition: transform .2s, opacity .2s;
}
.face.rolling { animation: shake .12s infinite; }
@keyframes shake { 0% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } 100% { transform: rotate(-8deg); } }
.face.win { transform: scale(1.12); background: var(--marker); }
.face.lose { opacity: .45; transform: scale(.92); }
.face.doped { background: #ffd9d9; }
.queue { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; padding: 4px; }
.vs { display: flex; flex-direction: column; align-items: center; text-align: center; }
.vs-text { font-family: var(--title); font-size: 46px; transform: rotate(-6deg); }
.battle-msg { font-family: var(--title); font-size: 17px; min-height: 24px; max-width: 200px; }
.rule-note { margin-top: 8px; font-size: 13px; background: #dff6e6; border: 1.5px solid var(--ink); border-radius: 6px; padding: 3px 10px; cursor: help; }
.rule-note.fair { background: var(--marker); }
.result { margin-top: 18px; text-align: center; font-family: var(--title); font-size: 22px; }
.dmg { color: var(--attack); font-size: 32px; }

.tour { display: flex; justify-content: center; gap: 24px; flex-wrap: wrap; }
.tour-item { display: flex; flex-direction: column; align-items: center; gap: 8px; font-family: var(--title); }
.tour-item img { width: 60px; height: 60px; }
.tour-item .face { --dc: var(--tc); min-width: 72px; height: 72px; font-size: 32px; border-width: 5px; }
.tour-win { text-align: center; font-family: var(--title); font-size: 24px; margin-top: 18px; }

/* 손패: 책상 위 검은 판 */
.hand-zone { background: var(--ink); border-radius: 18px; padding: 14px 16px 18px; color: #fff; }
.hand-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.hand-title { font-family: var(--title); font-size: 20px; display: flex; align-items: center; gap: 8px; }
.hand-title img { width: 34px; height: 34px; }
.hint { color: var(--marker); font-size: 15px; }
.hand { display: flex; gap: 14px; overflow-x: auto; padding: 14px 4px 6px; }
.hand .muted { color: #aaa; }
.hand-card { transition: transform .15s; flex: none; }
.hand-card.pickable { cursor: pointer; }
.hand-card.pickable:hover { transform: translateY(-6px); }
.hand-card.selected { transform: translateY(-12px); }
.hand-card.selected .card { box-shadow: 0 0 0 4px var(--marker), 0 10px 20px rgba(0,0,0,.4); }
.hand-zone .btn { box-shadow: 3px 3px 0 #fff; border-color: #fff; }

/* 카드 */
.card {
    --cc: var(--attack);
    background: var(--cc);
    border-radius: 12px;
    padding: 6px;
    display: flex; flex-direction: column; gap: 5px;
    box-shadow: 0 2px 6px rgba(0,0,0,.18);
    user-select: none;
    color: var(--ink);
}
.card.t-defense { --cc: var(--defense); }
.card.t-upgrade { --cc: var(--upgrade); }
.card.t-special { --cc: var(--special); }
.card-head { display: flex; align-items: center; gap: 6px; color: #fff; font-family: var(--title); padding: 2px 4px 0; }
.card-head svg { fill: #fff; flex: none; }
.card-head span { flex: 1; text-align: center; line-height: 1.1; text-shadow: 0 1px 0 rgba(0,0,0,.15); }
.card-art { background: #fff; border-radius: 7px; display: flex; align-items: center; justify-content: center; }
.card-desc { background: #fff; color: var(--ink); border-radius: 7px; display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1.4; padding: 4px; }
.card-desc small { font-size: .85em; color: var(--muted); }
.card-desc p { margin: 0; }
.card-desc .kill { color: #d8261a; font-weight: bold; }

.c-sm { width: 80px; height: 112px; padding: 4px; gap: 3px; border-radius: 9px; }
.c-sm .card-head { font-size: 12px; gap: 2px; padding: 0 2px; }
.c-sm .card-head svg { width: 12px; height: 12px; }
.c-sm .card-art { flex: 1; font-size: 34px; border-radius: 5px; }
.c-sm .card-desc { display: none; }

.c-md { width: 150px; height: 214px; }
.c-md .card-head { font-size: 17px; }
.c-md .card-head svg { width: 20px; height: 20px; }
.c-md .card-art { height: 84px; font-size: 50px; }
.c-md .card-desc { flex: 1; font-size: 12px; }

.c-lg { width: 240px; height: 340px; padding: 9px; gap: 7px; border-radius: 16px; }
.c-lg .card-head { font-size: 25px; }
.c-lg .card-head svg { width: 30px; height: 30px; }
.c-lg .card-art { height: 140px; font-size: 84px; }
.c-lg .card-desc { flex: 1; font-size: 15px; }

.card-back {
    background: repeating-linear-gradient(45deg, #2a2a2a 0 8px, #3a3a3a 8px 16px);
    border: 3px solid #fff; align-items: center; justify-content: center; font-size: 30px;
}
.flip-in { animation: flip .5s ease-out; }
@keyframes flip { from { transform: rotateY(90deg); } to { transform: none; } }

/* 마우스오버 카드 플로팅 */
.card-tip { position: fixed; z-index: 80; pointer-events: none; filter: drop-shadow(6px 8px 0 rgba(27,27,27,.85)); animation: tip .12s ease-out; }
@keyframes tip { from { opacity: 0; transform: scale(.94); } }

/* 기록: 줄 노트 */
.log-box {
    background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; box-shadow: 4px 4px 0 var(--ink);
    padding: 12px 14px; max-height: calc(100vh - 96px); overflow-y: auto; position: sticky; top: 16px;
    align-self: start;
}
.log-box h3 { font-family: var(--title); font-weight: 400; margin: 0 0 8px; font-size: 21px; }
#log { list-style: none; margin: 0; padding: 0; font-size: 13px; line-height: 1.55; }
#log li { padding: 4px 0; border-bottom: 1px solid #e3e9f1; }
#log li.round { font-family: var(--title); font-size: 16px; text-align: center; background: var(--marker); border-radius: 4px; border: 0; margin: 8px 0 4px; }
#log li.fight { color: #b8351f; }
#log li.good { color: #23833c; }
#log li.bad { color: #a0281a; font-weight: bold; }
#log li.special { color: #8a6a00; }
#log li.muted { color: var(--muted); }

/* 모달 */
.modal {
    position: fixed; inset: 0; background: rgba(27,27,27,.55);
    display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal-box {
    background: var(--paper); border-radius: 18px; border: 2px solid var(--ink);
    padding: 22px 24px; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto;
    box-shadow: 6px 6px 0 var(--ink); text-align: center;
    animation: pop .2s ease-out;
}
.modal-box.wide { max-width: 1020px; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.modal-btns { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pick h3 { font-family: var(--title); font-weight: 400; font-size: 24px; margin: 0 0 6px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.pick h3 img { width: 40px; height: 40px; }
.pick p { margin: 4px 0 16px; line-height: 1.5; }
.pick-dice { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.pick-die {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 14px 14px 10px; cursor: pointer;
    font-family: var(--title); box-shadow: var(--hard);
}
.pick-die:hover { background: var(--marker); }
.pick-die .die { transform: scale(1.25); margin: 4px; }
.announce { display: flex; flex-direction: column; align-items: center; gap: 10px; font-family: var(--title); font-size: 18px; }
.curtain img { width: 150px; height: 150px; object-fit: contain; }
.curtain h2 { font-family: var(--title); font-weight: 400; font-size: 34px; margin: 6px 0; }

/* 규칙 / 카드 도감 */
.book { text-align: left; }
.book-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--ink); margin-bottom: 16px; }
.book-tabs button {
    font-family: var(--title); font-size: 18px; padding: 8px 20px; cursor: pointer;
    background: #eef2f7; border: 2px solid var(--ink); border-bottom: 0; border-radius: 10px 10px 0 0; margin-right: -2px;
    color: var(--ink);
}
.book-tabs button.on { background: var(--marker); }
.rules { line-height: 1.65; max-width: 68ch; }
.rules h2, .rules h3 { font-family: var(--title); font-weight: 400; }
.rules h2 { margin-top: 0; font-size: 26px; }
.rules h3 { font-size: 20px; margin: 18px 0 4px; }
.dex-group + .dex-group { margin-top: 22px; }
.dex-group h3 { font-family: var(--title); font-weight: 400; font-size: 22px; margin: 0 0 10px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dex-group h3 svg { width: 22px; height: 22px; fill: currentColor; }
.dex-group h3 small { font-family: 'NanumGothic', sans-serif; font-size: 13px; color: var(--muted); }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; justify-items: center; }
.dex-grid figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dex-grid figcaption { font-size: 12px; color: var(--muted); max-width: 150px; text-align: center; line-height: 1.45; }
.dex-grid figcaption .note { display: block; margin-top: 4px; color: var(--ink); }
.notes { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 6px 0 0; }
.notes dt { white-space: nowrap; }
.notes dd { margin: 0; }

/* 반응형 */
@media (max-width: 1100px) {
    .layout { grid-template-columns: 1fr; }
    .log-box { position: static; max-height: 260px; }
}
@media (max-width: 760px) {
    .players { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    /* 종족 고르기는 1칸씩 4줄: 왼쪽 그림, 가운데 이름·특성, 오른쪽 참가 방식 */
    .tribe-picks { grid-template-columns: 1fr; gap: 12px; }
    .tribe-pick {
        display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; column-gap: 10px;
        align-items: center; align-content: center; text-align: left; padding: 6px 10px 6px 6px;
    }
    .tribe-pick img { grid-column: 1; grid-row: 1 / span 3; width: 56px; }
    .tp-name, .tp-trait, .seat-who { grid-column: 2; }
    .tribe-pick .seg, .tribe-pick .seat-act { grid-column: 3; grid-row: 1 / span 3; }
    .tp-name { font-size: 18px; margin: 0 0 2px; }
    .tp-trait { font-size: 12px; line-height: 1.35; min-height: 0; margin: 0; word-break: keep-all; }
    .tribe-pick .seg button { padding: 6px 10px; }
    .tp-trait .cref { white-space: nowrap; }
    .seat-who { font-size: 14px; min-height: 0; margin: 2px 0 0; }
    .seat-act { min-height: 0; }
    .player { padding: 6px; }
    .p-head { gap: 6px; }
    .p-head img { width: 42px; height: 42px; }
    .p-name { font-size: 16px; }
    .battle { grid-template-columns: 1fr; }
    .logo { font-size: 46px; }
    .logo-die { width: 52px; height: 52px; font-size: 42px; }
    .layout { padding: 10px; }
}
@media (hover: none) { .card-tip { display: none; } }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
