:root {
  --ink: #15120f;
  --ink-2: #1f1a15;
  --ink-3: #2d261e;
  --paper: #efe4cd;
  --paper-2: #e6d9bd;
  --paper-line: #cfbe9b;
  --text: #221c16;
  --text-soft: #66594a;
  --seal: #a8231b;
  --seal-bright: #d8432f;
  --gold: #bfa268;
  --on-ink: #eadfc9;
  --on-ink-soft: #a89c88;
  --brush: 'East Sea Dokdo', 'Gowun Batang', serif;
  --hanja-brush: 'Ma Shan Zheng', 'East Sea Dokdo', serif;
  --serif: 'Gowun Batang', 'Noto Serif KR', 'Apple SD Gothic Neo', serif;
  --ad-bar: 40px;
  --ad-dantalk: #a78bfa;
  --ad-ssum: #f472b6;
  --paper-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .27 0 0 0 0 .16 0 0 0 .13 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--ink);
  color: var(--on-ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
/* 빠르게 두 번 눌러도 화면이 확대되지 않게 하고, 브라우저 기본 터치 강조 대신 눌림 반응을 준다. */
button, a, input, textarea { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
input, textarea { -webkit-appearance: none; appearance: none; }
button:active, a:active { opacity: .75; }
body { overscroll-behavior: none; }
h1, h2, h3, p, ul, ol, blockquote { margin: 0; padding: 0; }
ul, ol { list-style: none; }

:focus-visible { outline: 2px solid var(--seal-bright); outline-offset: 2px; }

/* ------------------------------------------------------------ 입문 화면 */
#gate {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--app-height, 100dvh) - var(--ad-bar));
  overflow-y: auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 24px clamp(16px, 7vw, 110px);
  background: var(--ink) url('art/bg-gate.webp') center / cover no-repeat;
}

#gate::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, rgba(21, 18, 15, .55) 62%, rgba(21, 18, 15, .82));
}

.gate-card {
  position: relative;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: auto 0;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .55);
}

.gate-title {
  font-weight: 400;
  line-height: .95;
  font-size: clamp(76px, 13vw, 124px);
  letter-spacing: -.02em;
  white-space: nowrap;
}

.gate-title .hangul { display: block; font-family: var(--brush); }
.gate-title .talk { display: block; margin-top: .08em; font-size: .3em; line-height: 1; letter-spacing: .08em; color: var(--on-ink); }
.gate-title .hanja { font-family: var(--hanja-brush); font-size: 1.3em; letter-spacing: 0; color: var(--seal-bright); }

.gate-title .beta {
  display: inline-block;
  margin-left: .35em;
  padding: .12em .38em .08em;
  border: 2px solid var(--seal-bright);
  border-radius: 3px;
  font-family: var(--serif);
  font-size: .42em;
  font-weight: 700;
  letter-spacing: .12em;
  line-height: 1;
  vertical-align: .45em;
  color: var(--seal-bright);
  text-shadow: none;
  transform: rotate(-6deg);
}

.gate-home {
  align-self: flex-start;
  padding: 4px 11px;
  border: 1px solid rgba(191, 162, 104, .55);
  border-radius: 999px;
  background: rgba(21, 18, 15, .55);
  color: var(--on-ink-soft);
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
  text-shadow: none;
  transition: color .15s, border-color .15s;
}

.gate-home:hover { color: var(--on-ink); border-color: var(--gold); }

.gate-sub { font-family: var(--brush); font-size: clamp(30px, 5vw, 38px); line-height: 1.1; color: var(--on-ink); }

#gate-form label { display: block; margin-bottom: 8px; font-size: 14px; color: var(--on-ink); }

.gate-row { display: flex; gap: 8px; margin-top: 8px; }

#nick-input, #room-input {
  display: block;
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--gold);
  border-radius: 2px;
  background: rgba(239, 228, 205, .96);
  color: var(--text);
  font-size: 18px;
  text-shadow: none;
}

#room-input { flex: 1; letter-spacing: .18em; }
#nick-input::placeholder, #room-input::placeholder { color: var(--text-soft); font-size: 15px; letter-spacing: normal; }

.gate-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }

.gate-btn {
  height: 50px;
  border: 1px solid var(--gold);
  border-radius: 2px;
  background: rgba(21, 18, 15, .72);
  color: var(--on-ink);
  font-family: var(--brush);
  font-size: 28px;
  line-height: 1;
  text-shadow: none;
  transition: background .15s;
}

.gate-btn:hover, .gate-btn.active { background: var(--ink-3); }
.gate-btn.primary { border-color: var(--seal); background: var(--seal); color: #f7ecd8; }
.gate-btn.primary:hover { background: var(--seal-bright); }
.gate-btn:disabled { opacity: .6; cursor: wait; }
#btn-enter { flex: none; width: 88px; }

.join-or { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--on-ink-soft); }
.join-or::before, .join-or::after { content: ''; flex: 1; height: 1px; background: rgba(191, 162, 104, .4); }

#btn-random {
  width: 100%;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-color: var(--seal-bright);
}

.random-hint { font-family: var(--serif); font-size: 13px; letter-spacing: 0; color: var(--on-ink-soft); }
.random-hint.live { color: #f0b9a8; }

#gate-invite { margin-bottom: 8px; padding: 7px 11px; border-left: 3px solid var(--seal-bright); background: rgba(21, 18, 15, .6); font-size: 14px; }
#gate-error { min-height: 20px; margin-top: 5px; color: #ff9c8c; font-size: 14px; }

.gate-rules { counter-reset: rule; display: grid; gap: 5px; font-size: 15px; }
.gate-rules li { counter-increment: rule; position: relative; padding-left: 24px; }
.gate-rules li::before { content: counter(rule); position: absolute; left: 2px; top: 0; font-family: var(--brush); font-size: 21px; line-height: 1.1; color: var(--seal-bright); }
.gate-rules b { font-weight: 700; }

.gate-motto { padding-top: 10px; border-top: 1px solid rgba(191, 162, 104, .45); font-size: 14px; color: var(--on-ink); }
.motto-hanja { margin-right: 6px; font-family: var(--hanja-brush); font-size: 19px; color: var(--seal-bright); }
#gate-online { margin-top: -8px; font-size: 13px; color: var(--on-ink-soft); }

/* ------------------------------------------------------------ 광고 */
.ad-label {
  flex: none;
  padding: 0 5px;
  border: 1px solid rgba(234, 223, 201, .45);
  border-radius: 2px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--on-ink-soft);
  text-shadow: none;
}

.gate-ads { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }

.ad-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }

.ad-card {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(234, 223, 201, .22);
  border-left: 3px solid var(--ad-accent);
  border-radius: 2px;
  background: rgba(13, 10, 8, .86);
  color: var(--on-ink);
  text-decoration: none;
  text-shadow: none;
  transition: background .15s, transform .15s;
}

.ad-card:hover { background: rgba(45, 38, 30, .95); transform: translateY(-1px); }
.ad-dantalk { --ad-accent: var(--ad-dantalk); }
.ad-ssum { --ad-accent: var(--ad-ssum); }

.ad-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 12px; line-height: 1.45; color: var(--on-ink-soft); }
.ad-text b { font-size: 15px; line-height: 1.3; color: var(--ad-accent); }
.ad-arrow { flex: none; color: var(--ad-accent); font-size: 18px; }

#ad-bar {
  position: fixed;
  left: 0;
  right: 0;
  /* 휴대폰 키보드에 가려지지 않도록 화면 높이에서 거꾸로 잡는다. */
  top: calc(var(--app-height, 100dvh) - var(--ad-bar));
  height: var(--ad-bar);
  z-index: 16;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 0 12px;
  border-top: 1px solid rgba(191, 162, 104, .35);
  background: #0f0c09;
}

.ad-bar-item {
  min-width: 0;
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--on-ink-soft);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.ad-bar-copy { flex: none; font-weight: 700; color: var(--on-ink); }
.ad-bar-item b { flex: none; color: var(--ad-accent); }
.ad-bar-item span { overflow: hidden; text-overflow: ellipsis; }
.ad-bar-item:hover span { color: var(--on-ink); text-decoration: underline; }

#death-ad {
  position: fixed;
  left: 50%;
  top: calc(50% - var(--ad-bar) / 2);
  z-index: 30;
  width: min(520px, calc(100vw - 24px));
  max-height: calc(var(--app-height, 100dvh) - var(--ad-bar) - 24px);
  overflow-y: auto;
  transform: translate(-50%, -50%);
  padding: 18px;
  border: 1px solid var(--seal);
  background: #0d0a08;
  box-shadow: 0 12px 60px rgba(0, 0, 0, .8);
  animation: cardin .25s ease-out;
}

.death-title { font-family: var(--brush); font-size: 46px; line-height: 1; color: var(--seal-bright); }
#death-timer { margin: 6px 0 14px; font-size: 15px; color: var(--on-ink); font-variant-numeric: tabular-nums; }
#death-ad .ad-cards { margin-top: 6px; }
#death-ad .ad-card { padding: 12px; }

/* ------------------------------------------------------------ 연무장 뼈대 */
#arena {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--app-height, 100dvh) - var(--ad-bar));
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 300px;
  grid-template-rows: 54px minmax(0, 1fr);
  grid-template-areas:
    'top top top'
    'roster scroll records';
  gap: 0 14px;
  padding: 0 14px 14px;
  background:
    linear-gradient(rgba(15, 12, 9, .72), rgba(15, 12, 9, .5)),
    var(--ink) url('art/bg-arena.webp') center / cover no-repeat;
}

#topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  flex: none;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  font-family: var(--brush);
  font-size: 36px;
  line-height: 1;
  white-space: nowrap;
  transition: opacity .15s;
}

.brand:hover { opacity: .75; }
.brand-sub { margin-left: 8px; font-family: var(--serif); font-size: 13px; letter-spacing: .06em; color: var(--on-ink-soft); }
.brand .hanja { font-family: var(--hanja-brush); font-size: 19px; letter-spacing: 0; color: var(--seal-bright); }

#room-tag { padding: 2px 8px; border: 1px solid var(--seal-bright); border-radius: 2px; color: var(--on-ink); font-size: 13px; letter-spacing: .06em; white-space: nowrap; }

.motto { flex: 1; min-width: 0; font-size: 14px; color: var(--on-ink-soft); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.top-actions { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
#online-count { font-size: 13px; color: var(--on-ink-soft); margin-right: 4px; }

.top-btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(191, 162, 104, .5);
  border-radius: 2px;
  background: rgba(21, 18, 15, .6);
  font-size: 13px;
  transition: background .15s;
}

.top-btn:hover { background: var(--ink-3); }
#btn-records, #records-close { display: none; }

/* ------------------------------------------------------------ 곁 패널 */
#roster, #records {
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  border: 1px solid rgba(191, 162, 104, .22);
  background: rgba(17, 14, 11, .7);
  backdrop-filter: blur(5px);
  scrollbar-width: thin;
  scrollbar-color: var(--ink-3) transparent;
}

#roster { grid-area: roster; }
#records { grid-area: records; }

#roster h2, #records h2 { font-family: var(--brush); font-weight: 400; font-size: 26px; line-height: 1.1; color: var(--on-ink); }
#records h2 + * { margin-top: 6px; }
#records ol + h2 { margin-top: 22px; }

#players { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; margin-top: 10px; }

.row { position: relative; }

.row-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  text-align: left;
  transition: background .15s, border-color .15s;
}

.row-btn:hover { background: rgba(234, 223, 201, .07); border-color: rgba(191, 162, 104, .3); }
.row.me .row-btn { background: rgba(191, 162, 104, .1); cursor: default; }

.avatar { display: block; flex: none; border-radius: 50%; object-fit: cover; background: var(--paper-2); }
.avatar.xs { width: 24px; height: 24px; }
.avatar.sm { width: 30px; height: 30px; }
.avatar.md { width: 46px; height: 46px; border: 1px solid rgba(191, 162, 104, .5); }

.row-info { flex: 1; min-width: 0; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.row-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-title { flex: none; font-size: 12px; color: var(--gold); }

.hp { position: relative; height: 7px; margin: 4px 0 3px; background: rgba(234, 223, 201, .13); overflow: hidden; }
.hp-fill, .hp-ghost { position: absolute; inset: 0 auto 0 0; width: 100%; }
.hp-fill { background: linear-gradient(90deg, #8e7e5f, #d9c9a4); transition: width .25s ease-out; }
.hp-ghost { background: var(--seal-bright); transition: width .9s .25s ease-out; }
.row.low .hp-fill { background: var(--seal-bright); }

.row-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--on-ink-soft); }
.hp-text { font-variant-numeric: tabular-nums; color: var(--on-ink); }

.row.down .avatar { filter: grayscale(1) brightness(.5); }
.row.down .row-name { color: var(--on-ink-soft); text-decoration: line-through; }
.row.down .row-status { color: var(--seal-bright); }

.row.hit .row-btn { animation: rowhit .5s ease-out; }
@keyframes rowhit {
  0% { background: rgba(216, 67, 47, .6); transform: translateX(-5px); }
  30% { transform: translateX(4px); }
  60% { transform: translateX(-2px); }
  100% { transform: none; }
}

.float-damage {
  position: absolute;
  top: 2px;
  right: 10px;
  font-family: var(--brush);
  font-size: 32px;
  line-height: 1;
  color: var(--seal-bright);
  text-shadow: 0 1px 6px #000;
  pointer-events: none;
  animation: floatup 1.4s ease-out forwards;
}

@keyframes floatup {
  0% { opacity: 0; transform: translateY(8px) scale(1.5); }
  15% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-24px); }
}

/* ------------------------------------------------------------ 전황 족자 */
#scroll {
  grid-area: scroll;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper) var(--paper-grain);
  color: var(--text);
  box-shadow: 0 8px 40px rgba(0, 0, 0, .6);
  border-top: 7px solid var(--ink-3);
  border-bottom: 7px solid var(--ink-3);
}

#banner { padding: 6px 16px; background: var(--ink-3); color: var(--on-ink); font-size: 13px; text-align: center; }

#feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px clamp(14px, 3vw, 34px) 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
  scrollbar-color: var(--paper-line) transparent;
}

#feed > :first-child { margin-top: auto; }

.sys { text-align: center; font-size: 13px; color: var(--text-soft); }
.sys.revive { color: #3c5a3a; }

.chat { display: flex; gap: 9px; align-items: flex-start; }
.chat-body { min-width: 0; }
.chat-nick { display: block; font-size: 12px; font-weight: 700; color: var(--text-soft); }
.chat-text { white-space: pre-wrap; }
.chat.mine .chat-nick { color: var(--seal); }
.chat.ghosted { opacity: .55; }

.card {
  flex: none;
  padding: 12px 14px;
  border: 1px solid var(--paper-line);
  background: rgba(255, 250, 236, .55);
  animation: cardin .25s ease-out;
}

@keyframes cardin {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.card.aimed-at-me { border-color: var(--seal); box-shadow: inset 3px 0 0 var(--seal); }
.card.mine { box-shadow: inset 3px 0 0 var(--text-soft); }
.card.tier-3, .card.tier-4 { background: rgba(255, 246, 224, .9); border-color: var(--seal); }
.card.tier-4 { border-width: 2px; }
.card.foul { background: rgba(32, 26, 20, .06); border-style: dashed; border-color: var(--text-soft); }

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-who { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; }
.who-name { font-weight: 700; }
.who-arrow { color: var(--seal); }

.card-quote {
  margin-top: 8px;
  padding-left: 11px;
  border-left: 2px solid var(--paper-line);
  color: var(--text-soft);
  font-size: 15px;
  white-space: pre-wrap;
}

.mention { color: var(--seal); font-weight: 700; }

.card-result { margin-top: 10px; }

.charging { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-soft); }
.charging-dot { width: 13px; height: 13px; border-radius: 50%; background: var(--ink); animation: gather 1s ease-in-out infinite; }
@keyframes gather {
  0%, 100% { transform: scale(.55); opacity: .4; }
  50% { transform: scale(1); opacity: 1; }
}

.technique { font-family: var(--brush); font-weight: 400; font-size: 34px; line-height: 1.1; color: var(--text); }
.tier-0 .technique { font-size: 25px; color: var(--text-soft); }
.tier-1 .technique { font-size: 29px; }
.tier-3 .technique { font-size: 40px; color: var(--seal); }
.tier-4 .technique { font-size: 50px; color: var(--seal); }

.speech { display: flex; gap: 8px; margin-top: 7px; font-size: 15px; }
.speaker { flex: none; font-size: 12px; font-weight: 700; line-height: 1.95; color: var(--text-soft); }
.line { font-weight: 700; }
.line::before { content: '“'; }
.line::after { content: '”'; }

.narration { margin-top: 7px; font-size: 15.5px; line-height: 1.7; }
.narration.typing::after { content: '▌'; color: var(--text-soft); }

.ko-line {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--seal);
  color: var(--seal);
  font-weight: 700;
}

.judge-tag { margin-top: 7px; font-size: 11px; color: var(--text-soft); }

.seal {
  flex: none;
  min-width: 58px;
  padding: 4px 7px 3px;
  border-radius: 3px;
  background: var(--seal);
  color: #f9edd8;
  text-align: center;
  line-height: 1;
}

.seal b { display: block; font-family: var(--brush); font-weight: 400; font-size: 28px; line-height: 1; }
.seal small { display: block; margin-top: 2px; font-size: 11px; }
.tier-0 .seal { background: transparent; color: var(--text-soft); box-shadow: inset 0 0 0 1px var(--paper-line); }
.seal.backfire { background: var(--ink); }
.seal.stamp { animation: stamp .35s cubic-bezier(.2, 1.6, .4, 1); }

@keyframes stamp {
  from { opacity: 0; transform: scale(2.4) rotate(-14deg); }
  to { opacity: 1; transform: none; }
}

#jump {
  position: absolute;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  padding: 5px 14px;
  border: 0;
  border-radius: 20px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 13px;
  z-index: 3;
}

/* ------------------------------------------------------------ 입력창 */
#composer {
  position: relative;
  padding: 8px clamp(10px, 2vw, 18px) 10px;
  border-top: 1px solid var(--paper-line);
  background: var(--paper-2) var(--paper-grain);
}

.composer-row { display: flex; align-items: flex-end; gap: 10px; }

.composer-field {
  position: relative;
  flex: 1;
  min-width: 0;
  border: 1px solid var(--paper-line);
  background: #fbf5e6;
  transition: border-color .15s;
}

#composer.attack .composer-field { border-color: var(--seal); }

#aim { padding: 5px 10px 0; font-size: 12px; font-weight: 700; color: var(--seal); }
#aim.warn { color: var(--text-soft); font-weight: 400; }

/* 칸 전체를 눌러도 키보드가 뜨도록 여백을 입력창 안에 둔다. */
#input {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  max-height: 150px;
}

#input::placeholder { color: var(--text-soft); }

#counter { position: absolute; right: 8px; top: 5px; font-size: 11px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
#counter.over { color: var(--seal); font-weight: 700; }

/* 먹 원판 버튼과 그 둘레를 붓으로 그리는 원상(圓相). 그림은 tools/gen_brush.py 가 만든 알파 마스크다. */
#send {
  --send-face: var(--ink);
  --send-stroke: var(--ink);
  position: relative;
  flex: none;
  width: 62px;
  height: 62px;
  margin: 0 4px 0 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #f9edd8;
  isolation: isolate;
}

#composer.attack #send { --send-face: var(--seal); --send-stroke: var(--seal); }
#send.cooling, #composer.attack #send.cooling { --send-stroke: var(--seal); }
#send.blocked, #composer.attack #send.blocked { --send-face: #4f4438; cursor: not-allowed; }

#send span { position: absolute; display: block; pointer-events: none; }

#send-face {
  inset: 3.5%;
  background: var(--send-face);
  -webkit-mask: url('art/ink-disc.webp') center / contain no-repeat;
  mask: url('art/ink-disc.webp') center / contain no-repeat;
  transition: background .25s;
}

#send-ghost, #send-stroke {
  -webkit-mask: url('art/enso.webp') center / contain no-repeat;
  mask: url('art/enso.webp') center / contain no-repeat;
}

#send-ghost { inset: -14%; background: var(--ink); opacity: 0; transition: opacity .25s; }
#send.cooling #send-ghost { opacity: .17; }

#send-ring { inset: -14%; }
#send-stroke { inset: 0; background: var(--send-stroke); transition: background .25s; }

/* 붓끝이 지나가는 자리만 드러낸다. 끝을 살짝 흐려 먹이 번지며 나아가는 느낌을 준다. */
#send.cooling #send-ring {
  -webkit-mask-image: conic-gradient(#000 calc(var(--done, 0deg) - 5deg), transparent var(--done, 0deg));
  mask-image: conic-gradient(#000 calc(var(--done, 0deg) - 5deg), transparent var(--done, 0deg));
}

#send span#send-label {
  position: relative;
  font-family: var(--brush);
  font-size: 27px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* 원이 닫히는 순간 붓을 탁 내려놓는 느낌을 준다. */
#send.ready-pulse #send-ring { animation: ensodone .55s ease-out; }
@keyframes ensodone {
  0% { transform: scale(1.16) rotate(-5deg); filter: brightness(1.7); }
  100% { transform: none; filter: none; }
}

#composer.nudge .composer-row { animation: nudge .35s; }
@keyframes nudge {
  20% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  80% { transform: translateX(-2px); }
}

#toast {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(100% + 6px);
  padding: 6px 12px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 14px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity .15s, transform .15s;
  z-index: 4;
}

#toast.show { opacity: 1; transform: none; }

#mention-list {
  position: absolute;
  left: clamp(10px, 2vw, 18px);
  bottom: calc(100% - 4px);
  min-width: 220px;
  border: 1px solid var(--paper-line);
  background: #fbf5e6;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .3);
  z-index: 5;
}

.mention-item { display: flex; align-items: center; gap: 9px; padding: 7px 10px; cursor: pointer; }
.mention-item small { margin-left: auto; color: var(--text-soft); }
.mention-item.selected { background: var(--ink); color: var(--on-ink); }
.mention-item.selected small { color: var(--on-ink-soft); }

/* ------------------------------------------------------------ 강호비록 */
.records-note { font-size: 13px; color: var(--on-ink-soft); }

#strikes, #fighters { display: grid; gap: 6px; margin-top: 10px; }
.empty { font-size: 13px; color: var(--on-ink-soft); }

.strike details { border-bottom: 1px solid rgba(191, 162, 104, .2); padding-bottom: 6px; }
.strike summary { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; list-style: none; }
.strike summary::-webkit-details-marker { display: none; }
.strike-damage { flex: none; width: 42px; font-family: var(--brush); font-size: 26px; line-height: 1; color: var(--seal-bright); }
.strike-label { min-width: 0; }
.strike-label b { display: block; font-weight: 700; font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.strike-label small { font-size: 12px; color: var(--on-ink-soft); }
.strike blockquote { margin-top: 7px; padding-left: 10px; border-left: 2px solid var(--gold); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.strike .mention { color: var(--seal-bright); }
.strike-narration { margin-top: 6px; font-size: 13px; color: var(--on-ink-soft); }

.fighter { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.fighter-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fighter-score { margin-left: auto; flex: none; color: var(--gold); font-size: 13px; }

/* ------------------------------------------------------------ 타격 연출 */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }

.shake-2 { animation: shake .3s; }
.shake-3 { animation: shake .45s; --amp: 9px; }
.shake-4 { animation: shake .7s; --amp: 16px; }
@keyframes shake {
  15% { transform: translate(calc(var(--amp, 4px) * -1), calc(var(--amp, 4px) * .5)); }
  35% { transform: translate(var(--amp, 4px), calc(var(--amp, 4px) * -.6)); }
  55% { transform: translate(calc(var(--amp, 4px) * -.6), calc(var(--amp, 4px) * .3)); }
  75% { transform: translate(calc(var(--amp, 4px) * .4), calc(var(--amp, 4px) * -.2)); }
}

.vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 140px 30px rgba(168, 35, 27, .85);
  animation: vignette .7s ease-out forwards;
}

@keyframes vignette { from { opacity: 1; } to { opacity: 0; } }

.ink-burst {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  mix-blend-mode: multiply;
  transform-origin: 50% 46%;
  animation: inkburst 2.2s ease-out forwards;
}

@keyframes inkburst {
  0% { opacity: 0; transform: scale(.55); }
  9% { opacity: .95; transform: scale(1); }
  55% { opacity: .75; }
  100% { opacity: 0; transform: scale(1.04); }
}

.overlay {
  position: absolute;
  left: 50%;
  top: 44%;
  width: min(100vw, 1000px);
  padding: 44px 20px 40px;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #fff6e4;
  /* 밝은 족자 위에서도 글자가 읽히도록 먹구름을 깐다. */
  background: radial-gradient(closest-side, rgba(13, 10, 8, .94), rgba(13, 10, 8, .86) 62%, rgba(13, 10, 8, 0));
  text-shadow: 0 2px 16px #000;
  animation: overlayfade 2.1s ease-in forwards;
}

@keyframes overlayfade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

.overlay-grade { font-size: 16px; letter-spacing: .4em; padding-left: .4em; animation: overlayin .3s ease-out both; }

.overlay-technique {
  font-family: var(--brush);
  font-size: clamp(46px, 9vw, 104px);
  line-height: 1.05;
  overflow-wrap: anywhere;
  animation: brushin .42s cubic-bezier(.2, .8, .3, 1) .06s both;
}

.overlay.tier-4 .overlay-technique { font-size: clamp(54px, 11vw, 132px); }

.overlay-damage {
  margin-top: 8px;
  font-family: var(--brush);
  font-size: clamp(40px, 7vw, 76px);
  line-height: 1;
  color: #ff7a63;
  animation: stamp .3s cubic-bezier(.2, 1.6, .4, 1) .34s both;
}

@keyframes overlayin {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes brushin {
  from { opacity: 0; clip-path: inset(0 100% 0 0); transform: translateX(-16px); }
  to { opacity: 1; clip-path: inset(0 -5% 0 -5%); transform: none; }
}

.ko-banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 22%;
  padding: 8px 16px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(90deg, transparent, rgba(21, 18, 15, .92) 18%, rgba(21, 18, 15, .92) 82%, transparent);
  color: var(--on-ink);
  font-size: 18px;
  overflow-wrap: anywhere;
  animation: kobanner 2.6s ease-out forwards;
}

.ko-banner b { font-family: var(--hanja-brush), var(--serif); font-weight: 400; font-size: 44px; line-height: 1; color: var(--seal-bright); white-space: nowrap; }

@keyframes kobanner {
  0% { opacity: 0; transform: scaleY(.2); }
  8% { opacity: 1; transform: none; }
  82% { opacity: 1; }
  100% { opacity: 0; }
}

/* ------------------------------------------------------------ 좁은 화면 */
@media (max-width: 1180px) {
  #arena {
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-areas:
      'top top'
      'roster scroll';
  }
  #btn-records, #records-close { display: inline-block; }
  #records {
    position: fixed;
    top: 0;
    right: 0;
    height: calc(var(--app-height, 100dvh) - var(--ad-bar));
    width: min(340px, 88vw);
    z-index: 15;
    background: rgba(17, 14, 11, .97);
    transform: translateX(102%);
    transition: transform .22s ease-out;
    visibility: hidden;
  }
  #records.open { transform: none; visibility: visible; }
  #records-close { float: right; }
}

@media (max-width: 760px) {
  html, body { overflow: hidden; }
  :root { --ad-bar: 38px; }
  #gate { justify-content: center; align-items: flex-start; padding-top: 18px; }
  #gate::before { background: rgba(21, 18, 15, .62); }
  .gate-card { gap: 11px; }

  #ad-bar { gap: 10px; padding: 0 8px; }
  .ad-bar-item { font-size: 12px; gap: 5px; }

  #arena {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: 'top' 'roster' 'scroll';
    gap: 0;
    padding: 0;
  }

  #topbar { height: 44px; padding: 0 8px; gap: 6px; }
  .brand { font-size: 26px; }
  #room-tag { padding: 1px 5px; font-size: 12px; letter-spacing: 0; }
  .motto, #online-count, .wide { display: none; }
  .top-actions { margin-left: auto; gap: 4px; }
  .top-btn { height: 30px; padding: 0 7px; font-size: 12px; }

  #roster { padding: 0 6px 6px; border: 0; backdrop-filter: none; background: transparent; overflow: visible; }
  #roster h2 { display: none; }
  #players { display: flex; gap: 6px; margin: 0; overflow-x: auto; scrollbar-width: none; }
  #players::-webkit-scrollbar { display: none; }
  .row { flex: none; width: 128px; }
  .row-btn { padding: 5px 6px; gap: 6px; background: rgba(17, 14, 11, .82); border-color: rgba(191, 162, 104, .25); }
  .avatar.md { width: 30px; height: 30px; }
  .row-title { display: none; }
  .row-name { font-size: 13px; }
  .row-foot { font-size: 11px; }
  .hp { height: 5px; margin: 2px 0 1px; }
  .float-damage { font-size: 26px; right: 4px; }

  #scroll { border-top-width: 4px; border-bottom-width: 0; }
  #feed { padding: 12px 12px 8px; }
  .technique { font-size: 30px; }
  .tier-3 .technique { font-size: 34px; }
  .tier-4 .technique { font-size: 40px; }
  #send { width: 54px; height: 54px; }
  #jump { bottom: 80px; }
}

/* 하단 광고 바가 좁아지면 설명을 빼고 공통 문구와 서비스 이름만 남긴다. */
@media (max-width: 900px) {
  .ad-bar-item:not(.ad-bar-copy) span { display: none; }
}

@media (max-width: 380px) {
  .ad-card { padding: 8px; }
  .tag-label { display: none; }
}

/* 휴대폰 가로 화면: 세로 공간이 귀하다. */
@media (max-height: 500px) {
  :root { --ad-bar: 30px; }
  #gate { padding: 10px 16px; }
  .gate-card { gap: 6px; }
  .gate-title { font-size: 56px; }
  .gate-sub { font-size: 24px; }
  #gate-form label { margin-bottom: 3px; }
  #nick-input, #room-input { height: 42px; }
  .gate-btn { height: 42px; font-size: 24px; }
  .gate-actions, .gate-row, #btn-random { margin-top: 6px; }
  .join-or { margin-top: 6px; }
  .motto { display: none; }
  #send { width: 50px; height: 50px; }
  #composer { padding-top: 5px; padding-bottom: 5px; }
}

@media (max-height: 500px) and (min-width: 761px) {
  #arena { grid-template-columns: 210px minmax(0, 1fr); grid-template-rows: 42px minmax(0, 1fr); padding: 0 8px 4px; gap: 0 8px; }
  #roster { padding: 8px; }
  #roster h2 { display: none; }
  #players { margin-top: 0; }
  .brand { font-size: 28px; }
  #scroll { border-top-width: 4px; border-bottom-width: 4px; }
}

/* 키보드가 올라와 보이는 높이가 아주 작을 때는 입력창과 전황만 남긴다.
   iOS 는 키보드가 떠도 창 높이가 그대로라 미디어 쿼리로는 알 수 없어 app.js 가 이 클래스를 붙인다. */
:root.tiny-height { --ad-bar: 26px; }
.tiny-height #arena { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); grid-template-areas: 'scroll'; padding: 0; gap: 0; }
.tiny-height #topbar, .tiny-height #roster, .tiny-height #records, .tiny-height #aim { display: none !important; }
.tiny-height #scroll { border-width: 0; }
.tiny-height #feed { padding: 6px 12px; }
.tiny-height #composer { padding: 3px 8px; }
.tiny-height #send { width: 42px; height: 42px; }
.tiny-height #send-label { font-size: 22px; }

/* 손가락으로 누르는 화면에서는 누를 곳을 넉넉하게 한다. */
@media (pointer: coarse) {
  .top-btn { height: 36px; min-width: 36px; }
  .mention-item { padding: 11px 12px; }
  #jump { padding: 9px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
