/*
  할리갈리 — 조각보 테이블.
  카드는 과일 칸을 솔기로 이은 조각, 자리마다 한 조각, 종은 쪽빛 큰 조각.
  치자 = 지금 내가 할 일, 홍화 = 잘못 침, 쑥 = 성공·승리.
*/
.halli-page {
  /* arcade-chat.css가 쓰는 이름을 조각보 토큰에 연결 */
  --line: var(--seam);
  --muted: var(--ink-soft);
  --paper: var(--sheet);
  --cobalt: var(--indigo);

  --gardenia-press: #c99018;
  --header-h: 56px;
  --gutter: 24px;
}

.halli-main {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- 머리 ---------- */
.halli-header {
  flex: none;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--seam-width);
  min-height: var(--header-h);
  background: var(--seam);
  border-bottom: var(--seam-width) solid var(--seam-strong);
}
.halli-header > * { background: var(--sheet); }

.back-link {
  display: flex;
  align-items: center;
  padding: 0 20px;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 680;
  text-decoration: none;
}
.back-link:hover { background: var(--sheet-hover); }
.back-link:focus-visible { outline-offset: -4px; }

.header-title {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 6px 20px;
}
.header-title h1 { flex: none; font-size: var(--text-lg); font-weight: 800; }
#headerStatus {
  min-width: 0;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.halli-page[data-my-turn="true"] #headerStatus { color: var(--ink); font-weight: 680; }

.header-tools { display: flex; gap: var(--seam-width); background: var(--seam); }
.header-tools button {
  min-height: 100%;
  padding: 0 20px;
  border: 0;
  border-radius: 0;
  background: var(--sheet);
}
.header-tools button:focus-visible { outline-offset: -4px; }

/* 알림 */
#notice {
  position: fixed;
  z-index: 20;
  top: calc(var(--header-h) + 12px);
  left: 16px;
  right: 16px;
  width: fit-content;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--on-dye);
  font-size: var(--text-sm);
  font-weight: 600;
  animation: patch-in var(--steady) var(--ease);
}

/* ---------- 카드 ----------
   카드 한 장 = 과일 칸을 솔기로 이은 조각. 칸 배치는 과일 수마다 다르게 해 한눈에 세기 쉽게. */
.halli-card {
  flex: none;
  aspect-ratio: 2 / 3;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: var(--seam-width);
  background: var(--seam);
  border: var(--seam-width) solid var(--seam-strong);
  border-radius: var(--radius);
  overflow: hidden;
  container-type: inline-size;
}
.halli-card img {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 7cqw;
  object-fit: contain;
  background: var(--sheet);
  -webkit-user-drag: none;
  user-select: none;
}
.halli-card[data-count="1"],
.halli-card[data-count="2"],
.halli-card[data-count="3"] { grid-template-columns: minmax(0, 1fr); }
.halli-card[data-count="1"] img { padding: 12cqw; }
.halli-card[data-count="5"] img:last-child { grid-column: 1 / -1; }

.halli-card.back {
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  background: transparent;
  border: var(--seam-width) dashed var(--seam);
}
.halli-card.back::after {
  content: '비어 있음';
  color: var(--ink-soft);
  font-size: var(--text-xs);
  font-weight: 600;
}

/* 방금 펼친 카드: 뒤집히며 놓이고, 다음 공개 전까지 먹 테두리로 남습니다. */
.halli-card.just-open { border-color: var(--ink); animation: card-land 540ms cubic-bezier(.2,.8,.25,1); }
@keyframes card-land {
  0% { transform: translateY(-12px) scale(1.07); }
  28% { transform: translateY(5px) scale(1.09,.91); }
  54% { transform: translateY(-6px) scale(.96,1.05) rotate(-3deg); }
  78% { transform: translateY(2px) rotate(2deg); }
  100% { transform: none; }
}

/* ---------- 첫 화면 ---------- */
.halli-setup {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 48px var(--gutter) 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
  grid-template-areas: "head entry" "sample entry";
  align-content: start;
  gap: 36px 56px;
}
.setup-head { grid-area: head; }
.setup-head h2 {
  max-width: 13em;
  font-size: clamp(2rem, 1.2rem + 2.8vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -.035em;
  line-height: 1.12;
  text-wrap: balance;
}
.setup-head p { max-width: 32em; margin-top: 16px; color: var(--ink-soft); }

.halli-entry {
  grid-area: entry;
  align-self: start;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-color: var(--seam-strong);
}
.halli-entry > * {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
}
.entry-name,
.entry-foot { grid-column: 1 / -1; }
.entry-name { background: var(--cloth); }
.halli-entry h3 { font-size: var(--text-md); font-weight: 780; }
.entry-create .btn,
.entry-join .btn { margin-top: auto; }
.entry-create h3 + label,
.entry-join h3 + label { margin-top: 4px; }
#joinCode { font-variant-numeric: tabular-nums; letter-spacing: .12em; }
.entry-foot { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 12px 18px; background: var(--cloth); }
#entryHelp { color: var(--ink-soft); font-size: var(--text-sm); }
#forgetSession { min-height: 40px; padding: 0 10px; color: var(--safflower); }
.halli-entry .entry-practice { grid-column:1/-1; display:grid; grid-template-columns:1fr auto 80px; align-items:center; }
.entry-practice p { font-size:var(--text-sm); color:var(--ink-soft); margin:4px 0 0; }
.entry-practice .btn { grid-column:1/-1; }

.rule-sample {
  grid-area: sample;
  margin: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 24px;
}
.sample-cards { display: flex; gap: 10px; }
.sample-cards .halli-card { width: 72px; }
.sample-cards .halli-card:nth-child(2) { opacity: .55; }
.rule-sample figcaption { color: var(--ink-soft); font-size: var(--text-sm); }
.rule-sample figcaption b { display: block; margin-bottom: 4px; color: var(--ink); font-size: var(--text-md); }

/* ---------- 대기실 ---------- */
.halli-waiting {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 32px var(--gutter) 56px;
  display: grid;
  gap: 24px;
}
.waiting-top {
  grid-template-columns: minmax(0, 1fr) auto;
  border-color: var(--seam-strong);
}
.waiting-title { padding: 18px 20px; }
.waiting-title h2 { font-size: var(--text-xl); font-weight: 800; }
#waitingHelp { margin-top: 4px; color: var(--ink-soft); font-size: var(--text-sm); }
#copyCode {
  min-height: 100%;
  padding: 12px 24px;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  border: 0;
  border-radius: 0;
}
#copyCode:focus-visible { outline-offset: -4px; }
#copyCode span { color: var(--ink-soft); font-size: var(--text-xs); font-weight: 600; }
#copyCode b {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
}

.halli-seats { --n: 4; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
.halli-seats[data-count="2"] { --n: 2; }
.halli-seats[data-count="3"] { --n: 3; }
.halli-seats[data-count="5"] { --n: 5; }
.halli-seats[data-count="6"] { --n: 3; }
.waiting-seat {
  min-width: 0;
  min-height: 76px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}
.waiting-seat strong { display: flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; font-weight: 720; }
.waiting-seat small { color: var(--ink-soft); font-size: var(--text-sm); }
.waiting-seat.ready { background: var(--mugwort-tint); }
.waiting-seat.ready small { color: var(--mugwort); font-weight: 720; }
.waiting-seat.empty { background: var(--cloth); }
.waiting-seat.empty strong { color: var(--ink-soft); font-weight: 560; }

.tag {
  flex: none;
  padding: 0 5px;
  border-radius: var(--radius-small);
  background: var(--ink);
  color: var(--on-dye);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.5;
}

.fruit-settings { display: grid; gap: 12px; }
.fruit-head h3 { font-size: var(--text-lg); font-weight: 780; }
#fruitHelp { margin-top: 2px; color: var(--ink-soft); font-size: var(--text-sm); }
.fruit-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fruit-option {
  min-width: 0;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}
.fruit-option img { width: 72px; height: 72px; object-fit: contain; }
.fruit-option strong { font-weight: 720; }
.fruit-option > span { color: var(--ink-soft); font-size: var(--text-sm); }
.fruit-upload {
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--seam-strong);
  border-radius: var(--radius);
  background: var(--sheet);
  cursor: pointer;
  font-weight: 680;
}
.fruit-upload:hover { background: var(--sheet-hover); }
.fruit-upload:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.fruit-option button { min-height: 40px; padding: 0 10px; color: var(--ink-soft); font-size: var(--text-sm); }
#assetStatus { color: var(--ink-soft); font-size: var(--text-sm); }

.waiting-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.waiting-actions .btn { min-height: 52px; padding: 0 24px; font-size: var(--text-md); }
#readyButton:not(.is-ready):not(:disabled) { background: var(--gardenia); border-color: var(--gardenia); color: var(--ink); }
#readyButton:not(.is-ready):not(:disabled):hover { background: var(--gardenia-press); border-color: var(--gardenia-press); }
#leaveWaiting { margin-left: auto; }

/* 대기실 채팅: arcade-chat.js가 대기 중에는 #waitingRoom 끝에 붙입니다. 넓은 화면에서는 오른쪽 조각. */
#waitingRoom .arcade-chat {
  min-width: 0;
  margin: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  border: var(--seam-width) solid var(--seam);
  border-radius: var(--radius);
  background: var(--sheet);
}
#waitingRoom .arcade-chat .chat-heading h2 { font-size: var(--text-md); font-weight: 760; }
#waitingRoom .arcade-chat-list { flex: 1; min-height: 120px; }
@media (min-width: 861px) {
  .halli-waiting:has(> .arcade-chat:not([hidden])) {
    width: min(1240px, 100%);
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    column-gap: 24px;
  }
  #waitingRoom .arcade-chat {
    grid-column: 2;
    grid-row: 1 / span 4;
    height: 0;
    min-height: 100%;
  }
  #waitingRoom .arcade-chat-list { max-height: none; }
}

/* ---------- 게임 화면: 한 화면에 테이블·종·뒤집기 ---------- */
.halli-page.playing .halli-main { height: 100dvh; min-height: 0; overflow: hidden; }
.halli-game {
  flex: 1;
  min-height: 0;
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 16px var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 안내와 판정 */
.round-bar {
  flex: none;
  min-height: 64px;
  grid-template-columns: minmax(0, 1fr);
  border-color: var(--seam-strong);
}
.round-bar:has(#resultStrip:not([hidden])) { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); }
.round-message,
.result-strip {
  min-width: 0;
  padding: 8px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: background-color var(--quick) var(--ease);
}
.round-message strong { font-size: var(--text-lg); font-weight: 780; line-height: 1.3; }
.round-message span { color: var(--ink-soft); font-size: var(--text-sm); }
.halli-page[data-my-turn="true"] .round-message { background: var(--gardenia-tint); }
.round-bar:has(#resultStrip:not([hidden])) .round-message span { display: none; }
.round-bar:has(.result-strip.correct:not([hidden])) .round-message { background: var(--mugwort-tint); }
.round-bar:has(.result-strip.wrong:not([hidden])) .round-message { background: var(--safflower-tint); }
.round-bar:has(.result-strip.tie:not([hidden])) .round-message { background: var(--gardenia-tint); }
.halli-game:has(#endActions:not([hidden])) .round-message { background: var(--mugwort); color: var(--on-dye); }
.halli-game:has(#endActions:not([hidden])) .round-message span { display: block; color: var(--on-dye); }

.result-strip { background: var(--gardenia-tint); animation: patch-in var(--quick) var(--ease); }
.result-strip b { font-size: var(--text-md); font-weight: 760; line-height: 1.35; }
.result-strip .timings { font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.result-strip.correct { background: var(--mugwort); color: var(--on-dye); }
.result-strip.wrong { background: var(--safflower); color: var(--on-dye); }

/* 자리: 사람마다 한 조각 */
.card-table {
  --n: 2;
  flex: 1;
  min-height: 0;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  border-color: var(--seam-strong);
}
.card-table[data-count="1"] { --n: 1; }
.card-table[data-count="3"] { --n: 3; }
.card-table[data-count="4"] { --n: 4; }
.card-table[data-count="5"] { --n: 5; }
.card-table[data-count="6"] { --n: 6; }

.player-station {
  min-width: 0;
  min-height: 0;
  container: station / inline-size;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  transition: background-color var(--steady) var(--ease);
}
.station-head {
  min-width: 0;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: var(--seam-width) solid var(--seam);
  transition: background-color var(--steady) var(--ease);
}
.player-name { min-width: 0; display: flex; align-items: center; gap: 6px; }
.player-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 720; }

.player-cards {
  min-height: 0;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}
.player-cards .halli-card { height: min(100cqh, 150cqw, 360px); }

/* 끝난 뒤: 카드 대신 최종 장 수 */
.final-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  animation: patch-in var(--steady) var(--ease);
}
.final-count b {
  font-size: clamp(2.5rem, 12cqmin, 5.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.final-count span { color: var(--ink-soft); font-size: var(--text-sm); }
.player-station.winner .final-count b { color: var(--mugwort); }

.station-count {
  padding: 4px 12px 8px;
  color: var(--ink-soft);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.station-count:empty::before { content: '\00a0'; }

.player-station.mine { outline: var(--seam-width) solid var(--ink); outline-offset: calc(-1 * var(--seam-width)); }
.player-station.current .station-head { background: var(--gardenia); border-bottom-color: var(--gardenia-press); }
.player-station.winner .station-head { background: var(--mugwort); color: var(--on-dye); }
.player-station.winner .station-count { color: var(--mugwort); font-weight: 760; }
.player-station.out { background: var(--cloth-deep); }
.player-station.out .player-cards { opacity: .45; }
.player-station.out .station-count { color: var(--safflower); }

/* 조작: 뒤집기 · 종 · 반응 시간 */
.halli-controls {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px) minmax(0, 1fr);
  grid-template-areas: "flip bell read";
  align-items: center;
  gap: 16px 24px;
}

.table-bell {
  grid-area: bell;
  width: 100%;
  height: 132px;
  padding: 0;
  flex-direction: column;
  gap: 10px;
  border: var(--seam-width) solid var(--indigo);
  background: var(--indigo);
  color: var(--on-dye);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.table-bell:hover:not(:disabled) { background: var(--indigo-press); border-color: var(--indigo-press); }
.table-bell:active:not(:disabled),
.table-bell.hit { background: var(--indigo-press); border-color: var(--ink); }
.table-bell:disabled { background: var(--cloth-deep); border-color: var(--seam); color: var(--ink-soft); }
.table-bell:disabled .bell-icon { color: var(--seam); }
.table-bell:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* 평면 종: 꼭지 · 돔 · 받침 (솔기 한 줄로 돔과 받침을 나눔) */
.bell-icon { position: relative; flex: none; width: 92px; height: 60px; color: var(--on-dye); }
.bell-stem,
.bell-dome,
.bell-base { position: absolute; background: currentColor; }
.bell-stem {
  left: calc(50% - 8px);
  top: 0;
  width: 16px;
  height: 12px;
  border-radius: var(--radius-small) var(--radius-small) 0 0;
  transition: transform var(--quick) var(--ease);
}
.bell-dome { left: 12px; right: 12px; top: 10px; height: 40px; border-radius: 34px 34px 0 0; }
.bell-base { left: 0; right: 0; bottom: 0; height: 8px; border-radius: var(--radius-small); }
.table-bell:active:not(:disabled) .bell-stem,
.table-bell.hit .bell-stem { transform: translateY(7px); }
.bell-label { font-size: var(--text-md); font-weight: 780; line-height: 1; }
.bell-label kbd { margin-left: 4px; border-color: currentColor; background: transparent; color: inherit; }

.reaction-readout { grid-area: read; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#myReaction { font-size: var(--text-xl); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
#bellHelp { color: var(--ink-soft); font-size: var(--text-sm); }

/* 끝 */
.halli-game:has(#endActions:not([hidden])) .halli-controls { display: none; }
.end-actions {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 12px;
  min-height: 132px;
}
.end-actions p { flex-basis: 100%; color: var(--ink-soft); font-size: var(--text-sm); text-align: center; }
.end-actions .btn { min-height: 56px; min-width: 200px; font-size: var(--text-md); }

/* ---------- 대화상자 ---------- */
.halli-dialog { width: min(560px, calc(100vw - 24px)); }
.dialog-title {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 8px 10px 8px 20px;
  border-bottom: var(--seam-width) solid var(--seam);
  background: var(--cloth);
}
.dialog-title h2 { font-size: var(--text-lg); font-weight: 780; }
.halli-dialog > :not(.dialog-title) { margin: 16px 20px; }
.halli-dialog > :last-child { margin-bottom: 20px; }
.halli-dialog ol { padding-left: 1.3em; }
.halli-dialog li { margin-bottom: 8px; padding-left: 2px; }
.halli-dialog h3 { margin-top: 24px; font-size: var(--text-md); font-weight: 780; }
.halli-dialog h3 + p { margin-top: 6px; }
.halli-dialog p,
.halli-dialog li { color: var(--ink); font-size: var(--text-sm); line-height: 1.7; }
.halli-dialog > a { display: inline-block; font-size: var(--text-sm); font-weight: 650; }
#connectionStatus { color: var(--ink-soft); font-size: var(--text-sm); }
.menu-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
/* 메뉴 대화상자: 채팅은 대기실(#waitingRoom)과 게임 화면(#gameChat)으로 옮겨 가므로 여기서는 보통 비어 있습니다(예비 위치). */
#menuDialog[open] { display: flex; flex-direction: column; }
#menuDialog .menu-actions { order: 2; padding-top: 16px; border-top: var(--seam-width) solid var(--seam); margin-top: 0; }
#menuDialog .arcade-chat { margin-top: 0; padding: 0; border: 0; }

/* ---------- 좁은 화면 ---------- */
@media (max-width: 860px) {
  .halli-setup {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "head" "entry" "sample";
    gap: 28px;
    padding-top: 32px;
  }
  .halli-entry { max-width: 560px; width: 100%; }
}

@media (max-width: 640px) {
  .halli-page { --gutter: 16px; --header-h: 52px; }
  #headerStatus { display: none; }
  .back-link { padding: 0 14px; }
  .header-title { gap: 10px; padding: 4px 12px; }
  .header-title h1 { font-size: var(--text-md); white-space: nowrap; }
  .header-tools button { padding: 0 12px; white-space: nowrap; }
  .header-tools > .presence-inline { padding: 0 10px; }

  .halli-entry { grid-template-columns: minmax(0, 1fr); }
  .halli-entry > * { padding: 16px; }
  .rule-sample { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .sample-cards .halli-card { width: 64px; }

  .halli-waiting { padding-top: 20px; gap: 18px; }
  .waiting-top { grid-template-columns: minmax(0, 1fr); }
  #copyCode { align-items: flex-start; padding: 12px 20px; }
  #copyCode b { font-size: 2rem; }
  /* 6자리도 휴대폰에서는 두 칸씩: 세 칸이면 '친구를 기다립니다'와 이름이 글자 단위로 꺾입니다. */
  .halli-seats, .halli-seats[data-count] { --n: 2; }
  .halli-seats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .waiting-seat strong > * { flex: none; }
  .waiting-seat { min-height: 64px; padding: 12px 14px; }
  .fruit-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fruit-option img { width: 56px; height: 56px; }
  #waitingRoom .arcade-chat { order: 1; }
  #waitingRoom .arcade-chat-list { max-height: 200px; }
  .waiting-actions {
    order: 2;
    position: sticky;
    z-index: 2;
    bottom: 0;
    margin-inline: calc(-1 * var(--gutter));
    padding: 10px var(--gutter);
    border-top: var(--seam-width) solid var(--seam);
    background: var(--cloth);
  }
  .waiting-actions .btn { flex: 1 1 auto; }
  #leaveWaiting { margin-left: 0; flex: 0 0 auto; }

  .halli-game { padding: 10px var(--gutter) 12px; gap: 8px; }
  .round-bar { min-height: 60px; }
  .round-message,
  .result-strip { padding: 6px 12px; }
  .round-message strong { font-size: var(--text-md); }
  .round-message span,
  .result-strip .timings { font-size: var(--text-xs); }
  .result-strip b { font-size: var(--text-sm); }

  .player-name b { font-size: var(--text-sm); }
  .player-cards { padding: 8px; }
  .station-count { padding: 2px 6px 6px; }

  .halli-controls {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "flip read" "bell bell";
    gap: 8px 12px;
  }
  .reaction-readout { align-items: flex-end; text-align: right; }
  #myReaction { font-size: var(--text-lg); }
  #bellHelp { font-size: var(--text-xs); }
  .table-bell { height: 96px; flex-direction: row; gap: 16px; }
  .bell-icon { transform: scale(.85); }
  .bell-label { font-size: var(--text-lg); }
  .bell-label kbd { display: none; }
  .end-actions { min-height: 0; padding-bottom: 4px; }
  .end-actions .btn { flex: 1 1 140px; min-width: 0; }
}

/* 아주 좁은 머리줄: 접속 인원 배지를 빼서 '할리갈리' 제목이 잘리지 않게 합니다(게임 중 설정 버튼이 더해지면 420px까지). */
@media (max-width: 359px) {
  .header-tools > .presence-inline { display: none; }
}
@media (max-width: 420px) {
  .header-tools:has(#menuButton:not([hidden])) > .presence-inline { display: none; }
}
@media (max-width: 640px) {
  /* 판정 띠가 옆에 붙으면 안내 문장이 두 줄이 되므로, 48px 띠 안에 들어가게 글자와 줄 간격을 줄입니다. */
  .round-bar:has(#resultStrip:not([hidden])) .round-message strong { font-size: 14px; line-height: 1.2; }
}

/* 세로로 긴 화면: 4명 이상은 두 줄로 */
@media (max-aspect-ratio: 4/3) {
  .card-table[data-count="4"] { --n: 2; }
  .card-table[data-count="6"] { --n: 3; }
  .card-table[data-count="5"] { --n: 6; }
  .card-table[data-count="5"] > * { grid-column: span 2; }
  .card-table[data-count="5"] > :nth-child(n + 4) { grid-column: span 3; }
}

/* 낮은 화면(가로 폰 등): 조작부를 낮게 */
@media (max-height: 600px) {
  .halli-game { padding-block: 8px; gap: 6px; }
  .round-bar { min-height: 48px; }
  .round-message span { display: none; }
  .station-count { display: none; }
  .table-bell { height: 76px; flex-direction: row; gap: 14px; }
  .bell-icon { transform: scale(.75); }
  .end-actions { min-height: 0; }
}

.table-settings { grid-template-columns: 1fr 1fr; }
.table-settings label { display:flex; align-items:center; gap:14px; padding:18px; cursor:pointer; }
.table-settings input { width:24px; height:24px; flex:none; accent-color:var(--indigo); }
.table-settings span { display:grid; gap:4px; }
.table-settings small { color:var(--ink-soft); font-size:14px; }
.fruit-options { grid-template-columns:repeat(2,minmax(0,1fr)); }
.fruit-option { align-items:stretch; gap:10px; padding:16px; }
.fruit-current { display:flex; align-items:center; gap:14px; }
.fruit-current > div { display:grid; text-align:left; gap:4px; }
.fruit-current img { width:84px; height:84px; object-fit:contain; }
.fruit-current span { font-size:14px; color:var(--ink-soft); }
.photo-admin { display:flex; flex-wrap:wrap; gap:6px; }
.photo-candidates { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.photo-candidate { display:grid; gap:4px; padding:8px; background:var(--cloth); min-width:0; }
.photo-candidate.selected { background:var(--gardenia-tint); }
.photo-candidate img { width:100%; height:90px; object-fit:contain; }
.photo-candidate b { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.photo-candidate button[aria-pressed='true'] { background:var(--indigo); color:white; }
.photo-candidate span { font-size:14px; }
@media(min-width:861px) { #waitingRoom .arcade-chat { grid-row:1 / span 5; } }

.halli-page.playing { background:#e6e9dd; }
.halli-page.playing[data-my-turn='true'] { background:#f3df94; }
.halli-game { width:100%; max-width:1800px; display:grid; grid-template-columns:minmax(0,1fr) 260px; grid-template-rows:auto minmax(0,1fr) auto; gap:12px; }
.round-bar { grid-column:1; grid-row:1; }
.card-table { grid-column:1; grid-row:2; --n:3; }
.card-table[data-count='4'], .card-table[data-count='5'], .card-table[data-count='6'] { --n:3; }
.card-table[data-count='2'] { --n:2; }
.card-table[data-count='4'] { --n:2; }
.card-table[data-count='5'] > * { grid-column:auto; }
.halli-controls, .end-actions { grid-column:1; grid-row:3; }
.player-station { position:relative; overflow:hidden; }
.player-station.mine { outline:0; }
.player-station.mine .player-name b { text-decoration:underline; text-underline-offset:5px; }
.player-station.current { background:#fff2bb; }
.player-cards { padding:10px 14px 14px; perspective:700px; }
.player-cards .halli-card { height:min(100cqh, 146cqw, 400px); }
.halli-card { position:relative; background:#fffefa; border:2px solid #273e34; border-radius:7px; gap:0; padding:5px; box-shadow:1px 2px 0 #b6b9a7,2px 4px 0 #8c9984,4px 7px 0 #263e3429; }
.halli-card img { padding:1cqw; background:transparent; }
.halli-card[data-count='1'] img { padding:3cqw; }
.halli-card[data-count='3'] { grid-template-columns:repeat(2,minmax(0,1fr)); }
.halli-card[data-count='3'] img:first-child { grid-column:1/-1; }
.halli-card[data-count='5'] img:last-child { width:58%; justify-self:center; }
.halli-card.back { box-shadow:none; background:transparent; }
.halli-card.is-turning { animation:card-flip 120ms cubic-bezier(.3,0,.8,.2) both; background:var(--indigo); }
.halli-card.is-turning img { visibility:hidden; }
.halli-card.is-turning::after { content:''; position:absolute; inset:9px; border:3px double #f5e3b5; background:repeating-linear-gradient(45deg,transparent 0 10px,#ffffff18 10px 12px); }
@keyframes card-flip { from { transform:translateY(-24px) rotateY(-180deg) rotate(-12deg); } to { transform:translateY(-12px) rotateY(-270deg) rotate(3deg); } }
.table-bell { height:108px; border-radius:6px; background:#efb93f; border:2px solid #604921; color:#2c321c; box-shadow:0 5px 0 #795521; transition:transform 120ms,background 120ms; }
.table-bell:hover:not(:disabled) { background:#ffcc56; transform:translateY(-2px); }
.table-bell:disabled { opacity:.48; }
.bell-icon { color:#fff3b2; filter:drop-shadow(2px 3px 0 #ad7322); }
.bell-dome { background:linear-gradient(105deg,#fff6c5,#ecae2a 55%,#bd7817); border:2px solid #8f611c; }
.bell-base { background:#654c2a; }
.table-bell.hit { animation:bell-kick 550ms cubic-bezier(.2,.8,.25,1); }
.table-bell.hit .bell-icon { animation:bell-rattle 440ms ease-out; }
@keyframes bell-kick { 0% { transform:translateY(5px) scale(1.12,.8); } 26% { transform:translateY(-12px) scale(.93,1.12); } 50% { transform:translateY(3px) scale(1.06,.95); } 74% { transform:translateY(-4px); } 100% { transform:none; } }
@keyframes bell-rattle { 0%,100% { rotate:0deg; } 20% { rotate:18deg; } 40% { rotate:-14deg; } 60% { rotate:9deg; } 80% { rotate:-5deg; } }
[data-outcome='wrong'] .card-table { animation:table-argue 500ms ease-out; }
[data-outcome='wrong'] .round-message { background:#b8323f; color:white; }
[data-outcome='wrong'] .round-message span { color:white; }
[data-outcome='correct'] .table-bell { background:#a3d27c; }
@keyframes table-argue { 0%,100% { transform:none; } 18% { transform:translateX(-6px) rotate(-.4deg); } 36% { transform:translateX(6px) rotate(.4deg); } 54% { transform:translateX(-4px); } 72% { transform:translateX(3px); } }
#halliEffects { position:fixed; inset:0; pointer-events:none; z-index:12; overflow:hidden; }
.flying-card { position:absolute; margin:0; }
.flying-fruit { position:absolute; width:48px; height:48px; object-fit:contain; filter:drop-shadow(2px 3px 0 #0002); }
.wrong-stamp { position:absolute; font-size:120px; font-weight:900; color:#b8323f; line-height:1; text-shadow:3px 4px #fff6de; }
#gameChat { grid-column:2; grid-row:1/4; min-height:0; overflow:hidden; background:var(--sheet); border:2px solid var(--seam); }
#gameChat .arcade-chat { height:100%; display:flex; flex-direction:column; gap:10px; padding:14px; margin:0; border:0; }
#gameChat .chat-heading { flex:none; }
#gameChat .chat-heading span { display:none; }
#gameChat .arcade-chat-list { flex:1; min-height:0; max-height:none; overflow:auto; }
#gameChat .chat-message { padding:9px 0; font-size:15px; }
#gameChat .chat-message p { font-size:15px; overflow-wrap:anywhere; }
#gameChat .arcade-chat-form { flex:none; }
#gameChat textarea { min-height:42px; max-height:80px; font-size:16px; }
#gameChat .chat-status:empty { display:none; }
#gameChat .chat-empty { font-size:14px; }
@media(max-width:1000px) {
  .halli-game { grid-template-columns:minmax(0,1fr); grid-template-rows:auto minmax(0,1fr) auto 116px; gap:8px; }
  #gameChat { grid-column:1; grid-row:4; }
  #gameChat .arcade-chat { display:grid; grid-template-columns:1fr minmax(160px, .7fr); grid-template-rows:minmax(0,1fr); gap:12px; padding:8px 12px; }
  #gameChat .chat-heading { display:none; }
  #gameChat .arcade-chat-list { grid-column:1; grid-row:1; }
  #gameChat .chat-empty { grid-column:1; grid-row:1; align-self:center; }
  #gameChat .arcade-chat-form { grid-column:2; grid-row:1; align-self:end; }
  #gameChat .chat-status:not(:empty) { grid-column:2; grid-row:1; align-self:start; font-size:12px; }
  #gameChat .chat-message { padding:3px 0; }
  #gameChat .chat-message p { margin:0; }
  #gameChat .chat-message time { display:none; }
  .table-bell { height:86px; }
}
@media(max-width:640px) {
  .halli-game { padding:8px; gap:6px; grid-template-rows:48px minmax(0,1fr) 82px 106px; }
  .halli-controls { grid-template-columns:minmax(0,1fr) minmax(0,1.35fr); grid-template-areas:'flip bell'; gap:8px; position:relative; }
  .reaction-readout { display:none; }
  .table-bell { height:76px; gap:8px; }
  .bell-icon { width:72px; transform:scale(.8); margin:-10px; }
  .bell-label { font-size:16px; }
  .round-bar { min-height:0; }
  .round-message, .result-strip { padding:5px 8px; }
  .round-message strong { font-size:16px; }
  .round-message span { font-size:12px; }
  .result-strip b { font-size:14px; }
  .player-name { gap:3px; }
  .player-name b { font-size:14px; }
  .player-name .tag { display:none; }
  .player-cards { padding:6px 8px 10px; }
  .station-count { display:none; }
  .player-station { grid-template-rows:auto minmax(0,1fr); }
  .halli-card { padding:3px; border-width:1px; }
  #gameChat .arcade-chat { grid-template-columns:1fr; grid-template-rows:minmax(0,1fr) 36px; gap:4px; padding:5px 8px; }
  #gameChat .arcade-chat-form { grid-column:1; grid-row:2; }
  #gameChat .arcade-chat-form textarea, #gameChat .arcade-chat-form button { min-height:34px; padding:6px 10px; height:34px; }
  #gameChat .chat-message div { display:inline; }
  #gameChat .chat-message b { font-size:12px; margin-right:8px; }
  #gameChat .chat-message p { display:inline; font-size:13px; }
  #gameChat .chat-status:not(:empty) { grid-column:1; grid-row:1; background:var(--sheet); }
  .table-settings { grid-template-columns:1fr; }
  .fruit-options { grid-template-columns:1fr; }
  .fruit-current img { width:72px; height:72px; }
}
@media(max-height:560px) and (min-width:641px) {
  .halli-game { grid-template-columns:minmax(0,1fr) 210px; grid-template-rows:44px minmax(0,1fr) 70px; }
  #gameChat { grid-column:2; grid-row:1/4; }
  #gameChat .arcade-chat { display:flex; }
  .table-bell { height:64px; }
}
@media(prefers-reduced-motion:reduce) {
  .halli-page *, .halli-page *::before, .halli-page *::after { animation:none!important; transition:none!important; }
}

#gameChat .chat-empty { z-index:1; pointer-events:none; padding:8px; }
@media(min-width:641px) and (max-width:1000px) {
  .halli-controls { grid-template-columns:minmax(130px,1fr) minmax(180px,1.5fr) minmax(100px,.7fr); gap:16px; }
}
.halli-page[data-practice='true'] .halli-game { grid-template-columns:minmax(0,1fr); grid-template-rows:auto minmax(0,1fr) auto; max-width:1400px; }
.halli-page[data-practice='true'] #gameChat { display:none; }
.sound-preview { margin-top:24px; border-top:1px solid var(--seam); padding-top:16px; }
.sound-preview h3 { margin:0 0 12px; }
.sound-preview > div { display:flex; flex-wrap:wrap; gap:8px; }
.sound-preview > .wide { margin-top:12px; }
.collection-count { position:absolute; font-size:clamp(48px,7vw,96px); line-height:1; color:#fff7d9; text-shadow:3px 4px 0 #315d42,-2px -2px 0 #315d42; }
.bell-dome::before, .bell-dome::after { content:''; position:absolute; top:16px; width:5px; height:8px; border-radius:50%; background:#493420; }
.bell-dome::before { left:18px; }
.bell-dome::after { right:18px; }
[data-outcome='wrong'] .bell-dome::before, [data-outcome='wrong'] .bell-dome::after { height:3px; top:20px; transform:rotate(30deg); }
[data-outcome='wrong'] .bell-dome::after { transform:rotate(-30deg); }
.just-missed .player-cards { animation:card-flinch 600ms cubic-bezier(.2,.7,.3,1); }
@keyframes card-flinch { 0%,100% { transform:none; } 25% { transform:translateY(8px) rotate(-5deg) scale(.92,1.05); } 55% { transform:translateY(-6px) rotate(4deg); } }
@media(prefers-reduced-motion:reduce) { .just-missed .player-cards { animation:none; } }

.player-station { grid-template-rows:auto minmax(0,1fr); }
.station-count { position:absolute; bottom:7px; right:7px; padding:0; font-size:12px; pointer-events:none; }
.player-cards { padding:7px 14px 12px; }
@media(max-width:640px) {
  .player-cards { padding:5px 7px 9px; }
}

/* ---------- 조작부: 카드 뒤집기 · 종 · 반응 시간 ----------
   뒤집기와 종을 같은 높이의 한 쌍으로 두고, 둘 다 눌리는 덩어리 모양(아래 턱)으로 맞춥니다. */
.halli-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, .75fr);
  grid-template-areas: "flip bell read";
  align-items: stretch;
  gap: 12px;
  width: min(100%, 980px);
  justify-self: center;
  padding-bottom: 5px;
}

.flip-button {
  grid-area: flip;
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  justify-content: start;
  gap: 16px;
  height: 108px;
  min-height: 0;
  padding: 0 20px;
  border: 2px solid var(--seam-strong);
  border-radius: 6px;
  background: var(--sheet);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 5px 0 var(--seam-strong);
  touch-action: manipulation;
  transition: transform 120ms, background 120ms, box-shadow 120ms;
}

.flip-button:not(:disabled) { background: var(--indigo); border-color: #0f2140; color: var(--on-dye); box-shadow: 0 5px 0 #0f2140; }
.flip-button:hover:not(:disabled) { background: #2b5694; transform: translateY(-2px); box-shadow: 0 7px 0 #0f2140; }
.flip-button:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 #0f2140; }
.flip-button:disabled { background: var(--cloth); border-color: var(--seam); color: var(--ink-soft); box-shadow: 0 3px 0 var(--seam); cursor: default; }
.flip-button:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* 카드 더미 그림: 세 장이 겹친 뒷면 */
.flip-stack { position: relative; width: 50px; height: 68px; flex: none; }
.flip-stack i {
  position: absolute;
  inset: 0;
  border: 2px solid var(--ink);
  border-radius: 5px;
  background: var(--indigo);
}
.flip-stack i::after { content: ""; position: absolute; inset: 5px; border: 2px solid var(--gardenia-tint); border-radius: 2px; }
.flip-stack i:nth-child(1) { transform: translate(6px, 6px) rotate(6deg); background: #1a3862; }
.flip-stack i:nth-child(2) { transform: translate(3px, 3px) rotate(3deg); }
.flip-stack i:nth-child(3) { transform-origin: 0 100%; }
.flip-button:not(:disabled) .flip-stack i { border-color: var(--sheet); background: var(--gardenia); }
.flip-button:not(:disabled) .flip-stack i::after { border-color: #795521; }
.flip-button:not(:disabled) .flip-stack i:nth-child(1) { background: #c98f17; }
.flip-button:disabled .flip-stack { opacity: .5; }
.halli-page[data-my-turn="true"] .flip-button:not(:disabled) .flip-stack i:nth-child(3) { animation: flip-nudge 1.8s ease-in-out infinite; }
.flip-button:active:not(:disabled) .flip-stack i:nth-child(3) { transform: rotate(-24deg) translateY(-6px); animation: none; }

@keyframes flip-nudge {
  0%, 62%, 100% { transform: none; }
  72% { transform: rotate(-12deg) translateY(-4px); }
  84% { transform: rotate(3deg); }
}

.flip-text { display: grid; gap: 3px; min-width: 0; }
.flip-text b { font-size: clamp(18px, 1.6vw, 24px); font-weight: 850; line-height: 1.1; }
#flipHelp, .flip-count { font-size: var(--text-sm); font-weight: 650; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flip-count { font-variant-numeric: tabular-nums; opacity: .8; }
.flip-count:empty, #flipHelp:empty { display: none; }
.flip-key { position: absolute; top: 8px; right: 10px; border-color: currentColor; background: transparent; color: inherit; }

.table-bell { grid-area: bell; height: 108px; width: 100%; }

.reaction-readout {
  grid-area: read;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  height: 108px;
  padding: 0 16px;
  border: 2px solid var(--seam);
  border-radius: 6px;
  background: var(--sheet);
}

@media (min-width: 641px) and (max-width: 1000px) {
  .halli-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, .7fr); gap: 10px; }
  .flip-button { gap: 12px; padding: 0 14px; }
  .flip-stack { width: 40px; height: 56px; }
  .flip-key { display: none; }
}

/* 휴대폰: 엄지로 누르기 좋게 아래쪽에 뒤집기 | 종 한 쌍 */
@media (max-width: 640px) {
  .halli-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); grid-template-areas: "flip bell"; gap: 8px; padding-bottom: 4px; }
  .flip-button { gap: 10px; height: 92px; padding: 0 12px; }
  .flip-stack { width: 34px; height: 46px; }
  .flip-stack i::after { inset: 3px; border-width: 1.5px; }
  .flip-text b { font-size: 17px; }
  #flipHelp, .flip-count { font-size: 12px; }
  .flip-key { display: none; }
  .table-bell { height: 92px; }
  .reaction-readout { display: none; }
  .halli-game { grid-template-rows: 48px minmax(0, 1fr) 82px auto; }
  .halli-page[data-practice="true"] .halli-game { grid-template-rows: auto minmax(0, 1fr) auto; }
}

@media (max-width: 360px) {
  .flip-stack { display: none; }
  .flip-button { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
}

/* 낮은 화면(가로 폰 등) */
@media (max-height: 560px) and (min-width: 641px) {
  .flip-button, .table-bell, .reaction-readout { height: 64px; }
  .flip-stack { width: 30px; height: 40px; }
  .flip-key { display: none; }
}

/* ---------- HP 바: 덮인 카드 = 체력 (포켓몬 배틀처럼) ----------
   머리줄 첫 줄은 이름 | 12/14, 그 아래는 [HP|■■■■■□□]. 처음 받은 장 수를 넘은 체력은 아래에 같은 길이의
   금색 줄을 한 줄씩 더 쌓아 보여 줍니다. */
.station-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name num" "bar bar";
  align-items: center;
  gap: 4px 8px;
  padding: 6px 10px 8px;
}
.station-head .player-name { grid-area: name; }
/* 체력은 늘 빨강. 20% 아래로 떨어지면 막대가 숨 쉬듯 깜빡여 위험을 알립니다. */
.hp { display: contents; --hp-color: #e0464f; }
.hp[data-tone="low"] .hp-fill { animation: hp-danger 900ms ease-in-out infinite alternate; }
@keyframes hp-danger { from { filter: none; } to { filter: brightness(1.45); } }
.hp-num { grid-area: num; color: var(--ink-soft); font-size: 13px; font-weight: 700; line-height: 1; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hp-num b { color: var(--ink); font-size: 18px; font-weight: 820; letter-spacing: -.01em; }
.hp.is-over .hp-num b { color: #a26d06; }
.hp-row { grid-area: bar; display: flex; align-items: flex-start; min-width: 0; }
.hp-bars { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hp-tag {
  flex: none;
  height: 14px;
  padding: 0 4px 0 5px;
  border-radius: 6px 0 0 6px;
  background: #273e34;
  color: #f5e3b5;
  font: normal 850 10px/14px var(--font);
  letter-spacing: .04em;
}
.hp-track {
  position: relative;
  flex: none;
  min-width: 0;
  height: 14px;
  border: 2px solid #273e34;
  border-left-width: 0;
  border-radius: 0 7px 7px 0;
  background: #3a4841;
  overflow: hidden;
  transform-origin: top;
  transition: box-shadow 200ms var(--ease);
}
/* 초과 체력 줄: 첫 줄과 같은 길이, 금색. 왼쪽 HP 글자 아래로 들여 쓰지 않고 첫 줄 막대와 끝을 맞춥니다. */
.hp-track.hp-extra { height: 10px; border-left-width: 2px; border-radius: 5px; }
.hp-extra .hp-fill { background: #ffcf3d; box-shadow: inset 0 2px 0 #fff4b8; }
.hp-track > span { position: absolute; top: 0; bottom: 0; left: 0; }
.hp-trail { background: #fff3cf; }
.hp-trail { width: var(--hp-trail, 0%); }
.hp-fill { width: var(--hp, 0%); background: var(--hp-color); box-shadow: inset 0 3px 0 #ffffff4d; transition: background-color 160ms; }
/* 5칸마다 눈금. 모든 줄이 같은 눈금이라 몇 장 더 가졌는지 셀 수 있습니다. */
.hp-track::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(var(--hp-seg, 20%) - 1.5px), #273e3466 calc(var(--hp-seg, 20%) - 1.5px) var(--hp-seg, 20%));
  pointer-events: none;
}
.hp-shine {
  width: 36%;
  left: -40% !important;
  opacity: 0;
  background: linear-gradient(105deg, transparent 15%, #fffdf2 50%, transparent 85%);
  pointer-events: none;
}
/* 회복 중: 막대가 은은하게 빛나고 끝에서 반짝입니다. */
.hp.is-filling .hp-track { box-shadow: 0 0 0 2px #fff3b0, 0 0 12px 3px #ffe27a; }
.hp.is-filling .hp-track:last-child .hp-fill::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 0;
  bottom: 2px;
  width: 4px;
  border-radius: 2px;
  background: #fffdf2;
  animation: hp-sparkle 240ms ease-in-out infinite alternate;
}
@keyframes hp-sparkle { from { opacity: .35; } to { opacity: 1; } }
.player-station.winner .hp-num, .player-station.winner .hp-num b { color: var(--on-dye); }
.player-station.out .hp-row, .player-station.out .hp-num { opacity: .45; }

/* 좁은 자리(폰·5~6명): 숫자는 작게, HP 글자는 막대 테두리로 대신합니다. */
@container station (max-width: 170px) {
  .station-head { gap: 3px 4px; padding: 4px 6px 6px; }
  .hp-num { font-size: 11px; }
  .hp-num b { font-size: 14px; }
  .hp-tag { display: none; }
  .hp-track { height: 11px; border-left-width: 2px; border-radius: 6px; }
  .hp-track.hp-extra { height: 8px; border-radius: 4px; }
}
@media (max-width: 640px) {
  .station-head { gap: 3px 4px; padding: 4px 6px 6px; }
  .hp-num { font-size: 11px; }
  .hp-num b { font-size: 14px; }
}

/* ---------- 게임 중 채팅 (#gameChat) ----------
   arcade-chat.js가 게임이 시작되면 채팅을 #gameChat으로 옮깁니다. 메뉴를 열지 않아도 대화가 보이고,
   새 메시지는 입력칸 바로 위에 쌓입니다. 높이는 고정이라 메시지가 와도 카드·종 자리가 움직이지 않습니다. */
#gameChat .arcade-chat-list { display: flex; flex-direction: column; }
#gameChat .chat-message { flex: none; padding-inline: 12px; }
#gameChat .chat-message:first-child { margin-top: auto; }
/* 막 도착한 남의 메시지는 치자빛으로 한 번 반짝이고 가라앉습니다(움직임 줄이기에서는 위의 규칙이 꺼 줍니다). */
#gameChat .chat-message:not(.mine):last-child { animation: chat-in var(--quick) var(--ease) both, game-chat-arrive 1.6s var(--ease); }
@keyframes game-chat-arrive {
  from { background: var(--gardenia-tint); box-shadow: inset 4px 0 0 var(--gardenia); }
  to { background: var(--sheet); box-shadow: inset 0 0 0 var(--gardenia); }
}
/* 넓은 화면·낮은 가로 화면의 오른쪽 기둥: 빈 안내문을 목록 칸 안쪽(입력칸 바로 위)에 겹쳐 둡니다. */
@media (min-width: 1001px), (min-width: 641px) and (max-height: 560px) {
  #gameChat .arcade-chat { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; }
  #gameChat .chat-heading { grid-row: 1; }
  #gameChat .chat-empty, #gameChat .arcade-chat-list { grid-row: 2; grid-column: 1; }
  #gameChat .chat-empty { align-self: end; padding: 12px; text-align: center; }
  #gameChat .arcade-chat-form { grid-row: 3; grid-column: 1; align-self: auto; }
  #gameChat .chat-status, #gameChat .chat-status:not(:empty) { grid-row: 4; grid-column: 1; align-self: auto; }
}
@media (max-width: 1000px) {
  #gameChat .chat-message { padding: 3px 10px; }
}
/* 휴대폰: 아래쪽 얇은 띠(최근 두어 줄 + 입력칸). 뒤집기·종 줄은 버튼 높이만큼, 채팅 띠는 고정 높이라
   조작부와 겹치지 않고 메시지가 늘어도 카드 칸이 줄었다 늘었다 하지 않습니다. */
@media (max-width: 640px) {
  .halli-game { grid-template-rows: 48px minmax(0, 1fr) auto 104px; }
  #gameChat .chat-empty { align-self: center; padding: 0 10px; font-size: 13px; }
  #gameChat .chat-message { padding: 2px 10px; line-height: 1.35; }
  #gameChat .chat-message p { line-height: 1.35; }
}
