/* 기본 레이아웃 + 게임 HUD. 첫 화면 · 대기실 · 결과는 css/panel.css 에 있다. */
@import url("/css/panel.css");

:root {
  --bg: #10141c;
  --fg: #eef2f8;
  --dim: #8b96a8;
  --accent: #ffd24d;
  --panel: rgba(18, 23, 34, 0.9);
  --line: rgba(255, 255, 255, 0.1);
  --red: #e5484d;
  --green: #3fb364;
  --blue: #3d7fe0;
  --danger: #ff8a80;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: "Pretendard", "Malgun Gothic", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

#cv {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  touch-action: none; /* 브라우저 스크롤·확대 제스처가 입력을 가로채지 않게 */
  cursor: grab;
}

[hidden] { display: none !important; }

button {
  font: inherit;
  color: #231a00;
  background: var(--accent);
  border: 0;
  border-radius: 12px;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}
button:disabled { opacity: 0.35; cursor: default; }
button.ghost { background: rgba(255, 255, 255, 0.1); color: var(--fg); }
button.small { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
button.wide { width: 100%; }

/* 칩 색 점 */
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.85); vertical-align: middle; }
.dot.big { width: 22px; height: 22px; }
.dot.r, .chip.r, .place.r { --c: var(--red); }
.dot.g, .chip.g, .place.g { --c: var(--green); }
.dot.b, .chip.b, .place.b { --c: var(--blue); }
.dot.r, .dot.g, .dot.b { background: var(--c); }
.dot.w, .chip.w::before { background: conic-gradient(#e5484d, #f0a13a, #f5d94a, #3fb364, #3d7fe0, #8a5cc7, #e5484d); }

/* ── 위: 현황 ── */
.top {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--panel);
  pointer-events: none;
  white-space: nowrap;
}
.top-info { display: flex; align-items: center; gap: 14px; font-size: 15px; }
.top .round { font-weight: 700; color: var(--dim); }
.top .sum { display: inline-flex; align-items: baseline; gap: 5px; font-variant-numeric: tabular-nums; }
.top .sum i { width: 12px; height: 12px; border-radius: 3px; align-self: center; }
.top .sum.r i { background: var(--red); }
.top .sum.g i { background: var(--green); }
.top .sum.b i { background: var(--blue); }
.top .sum b { font-size: 20px; }
.top .sum.hot b { color: #ffb347; }
.top .sum small { color: var(--dim); font-size: 12px; }
.top-timer { min-width: 2.2em; text-align: right; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.top-timer:empty { display: none; }
.top-timer.low { color: var(--danger); }

/* ── 왼쪽: 참가자 표 ── */
.board {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: calc(8px + env(safe-area-inset-left));
  width: 208px;
  max-height: calc(100dvh - 190px);
  overflow-y: auto;
  padding: 8px;
  border-radius: 14px;
  background: var(--panel);
  font-size: 14px;
}
.board .row { display: grid; grid-template-columns: 20px 1fr auto 28px; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 8px; }
.board .row.turn { background: rgba(255, 210, 77, 0.18); outline: 1px solid rgba(255, 210, 77, 0.6); }
.board .row.me .name { color: var(--accent); }
.board .row.off .name { color: var(--dim); text-decoration: line-through; }
.board .ord { color: var(--dim); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
.board .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.board .first { display: inline-block; margin-right: 5px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #231a00; font-style: normal; font-size: 11px; font-weight: 800; }
.board .play { display: inline-flex; align-items: center; gap: 4px; }
.board .play b { font-size: 15px; }
.board .play small { color: var(--dim); font-size: 11px; }
.board .pen { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--dim); }
.board .pen.has { color: var(--danger); }

/* ── 알림 ── */
.toast {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--panel);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}
.toast.strong { background: rgba(122, 28, 28, 0.94); font-size: 17px; }

/* ── 아래: 손패 · 차례 ── */
.dock-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 120px);
  pointer-events: none; /* 빈 곳을 눌러도 뒤의 3D 화면이 받는다 */
}
.dock-wrap > * { pointer-events: auto; }

.dock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 18px;
  background: var(--panel);
}
.dock:empty { display: none; }
.dock .status { font-size: 14px; color: var(--dim); text-align: center; }
.dock .hand { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
.dock .cards, .dock .chips { display: flex; gap: 6px; }

.card {
  width: 46px;
  height: 62px;
  padding: 0;
  border-radius: 8px;
  background: #fbf6ea;
  color: #7a2e1c;
  font-size: 26px;
  font-weight: 900;
  border: 2px solid #c8b89a;
  transition: transform 0.1s;
}
.card:disabled { background: transparent; color: transparent; border-style: dashed; border-color: var(--line); opacity: 1; }
.card.on { transform: translateY(-8px); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent); }

.chip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border-radius: 50%;
  background: var(--c, #555);
  color: #fff;
  font-size: 12px;
  border: 3px solid rgba(255, 255, 255, 0.85);
  overflow: hidden;
  transition: transform 0.1s;
}
.chip.w::before { content: ""; position: absolute; inset: 0; }
.chip span, .chip small { position: relative; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7); }
.chip small { font-weight: 800; }
.chip.on { transform: translateY(-8px); box-shadow: 0 0 0 3px var(--accent); }
.chip:disabled { filter: grayscale(1); opacity: 0.25; }

button.primary { padding: 14px 26px; font-size: 17px; }

.dock .mine { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--dim); }
.brick { display: inline-block; min-width: 40px; padding: 2px 10px; border-radius: 6px; background: #c25a3a; color: #fff7ea; font-size: 18px; text-align: center; }

.dock .turn { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.dock .turn button { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 150px; padding: 10px 16px; }
.dock .turn small { font-weight: 600; font-size: 12px; opacity: 0.85; }
.place { background: var(--c); color: #fff; }
.place.bust { outline: 3px solid var(--danger); }
.place.bust small { color: #ffe1dd; opacity: 1; }

.corner-btn {
  position: fixed;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: var(--panel);
  color: var(--fg);
}
.corner-btn.off { opacity: 0.4; }

.app-ver {
  position: fixed;
  left: calc(10px + env(safe-area-inset-left));
  bottom: calc(8px + env(safe-area-inset-bottom));
  font-size: 11px;
  color: var(--dim);
  pointer-events: none;
}

/* 낮은 화면(가로로 든 휴대폰): 조작부를 줄인다 */
@media (max-height: 480px) {
  .top { padding: 5px 12px; gap: 10px; }
  .top-info { font-size: 13px; gap: 10px; }
  .top .sum b { font-size: 16px; }
  .board { width: 168px; font-size: 12px; max-height: calc(100dvh - 120px); padding: 5px; }
  .board .row { padding: 3px 4px; }
  .toast { top: calc(44px + env(safe-area-inset-top)); font-size: 13px; }
  .dock-wrap { gap: 4px; bottom: calc(4px + env(safe-area-inset-bottom)); }
  .dock { padding: 6px 10px; gap: 4px; }
  .dock .status { font-size: 12px; }
  .dock .hand { gap: 8px; flex-wrap: nowrap; }
  .card { width: 34px; height: 46px; font-size: 20px; }
  .chip { width: 44px; height: 44px; font-size: 10px; }
  button.primary { padding: 10px 16px; font-size: 15px; }
  .dock .turn button { min-width: 120px; padding: 7px 10px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ── 감정표현: 손패 바로 위의 한 줄 ── */
.emote-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--panel);
}
.emote-target {
  padding: 5px 10px;
  border-radius: 999px;
  background: transparent;
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
}
.emote-target.aimed { color: var(--accent); }
.emote-list { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.emote { padding: 6px 12px; border-radius: 999px; font-size: 13px; background: rgba(255, 255, 255, 0.12); color: var(--fg); }
.emote.taunt { background: rgba(229, 72, 77, 0.55); }
.emote.confident { background: rgba(61, 127, 224, 0.5); }
.emote.despair { background: rgba(138, 92, 199, 0.5); }
.emote.slam1, .emote.slam2 { background: rgba(200, 60, 40, 0.7); }
@media (max-height: 480px) {
  .emote-bar { padding: 3px 6px; gap: 4px; }
  .emote { padding: 4px 9px; font-size: 12px; }
  .emote-target { padding: 3px 6px; font-size: 11px; }
}
