/* DoodlePang 테마: 노을 그라데이션 + 굵은 외곽선/하드 섀도우 스티커 스타일 */
:root {
  --ink: #1d1b3a;
  --paper: #fffaf0;
  --soft: #f3effe;
  --muted: #6b6890;
  --yellow: #ffd23f;
  --pink: #ff5d8f;
  --mint: #3ddc97;
  --sky: #4cc9f0;
  --violet: #7b5cff;
  --orange: #ff8c42;
  --red: #ff4b4b;
  --good: #14a46c;
  --good-bg: #d9fbe9;
  --info: #5a3fe0;
  --warn: #e07a00;
  --leave: #e0453a;
  --dark-panel: #2a2650;
  --radius: 18px;
  --shadow: 5px 5px 0 var(--ink);
  --font: 'Nunito', 'Jua', system-ui, -apple-system, 'Malgun Gothic', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(130deg, #4b1fc2, #9d1fb5 35%, #ff4f7b 70%, #ff9a3c);
  background-size: 300% 300%;
  animation: bgShift 22s ease-in-out infinite;
  background-attachment: fixed;
  overflow-x: hidden;
}
body::before {
  /* 점 그리드 */
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .16) 1.6px, transparent 1.8px);
  background-size: 26px 26px;
  pointer-events: none;
  z-index: 0;
}
@keyframes bgShift { 0%, 100% { background-position: 0% 30%; } 50% { background-position: 100% 70%; } }

/* 떠다니는 장식 */
.bg-deco { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bg-deco span {
  position: absolute;
  font-size: 46px;
  opacity: .3;
  animation: drift 18s ease-in-out infinite;
}
.bg-deco span:nth-child(1) { left: 4%; top: 12%; }
.bg-deco span:nth-child(2) { left: 88%; top: 8%; animation-delay: -3s; font-size: 60px; }
.bg-deco span:nth-child(3) { left: 12%; top: 70%; animation-delay: -6s; }
.bg-deco span:nth-child(4) { left: 78%; top: 62%; animation-delay: -9s; font-size: 70px; }
.bg-deco span:nth-child(5) { left: 46%; top: 88%; animation-delay: -12s; }
.bg-deco span:nth-child(6) { left: 30%; top: 4%; animation-delay: -2s; font-size: 36px; }
.bg-deco span:nth-child(7) { left: 94%; top: 40%; animation-delay: -7s; font-size: 40px; }
.bg-deco span:nth-child(8) { left: 2%; top: 42%; animation-delay: -11s; font-size: 54px; }
.bg-deco span:nth-child(9) { left: 62%; top: 22%; animation-delay: -15s; font-size: 32px; }
.bg-deco span:nth-child(10) { left: 22%; top: 90%; animation-delay: -4s; font-size: 38px; }
/* 귀여운 장식 추가 (도넛·향수·장미·컵케이크 등) — 게임 화면을 가리지 않게 주로 가장자리 */
.bg-deco span:nth-child(11) { left: 8%; top: 26%; animation-delay: -5s; font-size: 50px; }
.bg-deco span:nth-child(12) { left: 91%; top: 74%; animation-delay: -8s; font-size: 48px; }
.bg-deco span:nth-child(13) { left: 85%; top: 24%; animation-delay: -13s; font-size: 42px; }
.bg-deco span:nth-child(14) { left: 6%; top: 84%; animation-delay: -1s; font-size: 44px; }
.bg-deco span:nth-child(15) { left: 96%; top: 56%; animation-delay: -10s; font-size: 36px; }
.bg-deco span:nth-child(16) { left: 14%; top: 54%; animation-delay: -14s; font-size: 34px; }
.bg-deco span:nth-child(17) { left: 70%; top: 92%; animation-delay: -6.5s; font-size: 40px; }
.bg-deco span:nth-child(18) { left: 82%; top: 88%; animation-delay: -16s; font-size: 50px; }
.bg-deco span:nth-child(19) { left: 38%; top: 93%; animation-delay: -9.5s; font-size: 34px; }
.bg-deco span:nth-child(20) { left: 52%; top: 3%; animation-delay: -12.5s; font-size: 34px; }
.bg-deco span:nth-child(21) { left: 74%; top: 5%; animation-delay: -3.5s; font-size: 30px; }
.bg-deco span:nth-child(22) { left: 15%; top: 8%; animation-delay: -17s; font-size: 32px; }
@keyframes drift {
  0%, 100% { transform: translate(0, 0) rotate(-10deg); }
  33% { transform: translate(30px, -40px) rotate(12deg); }
  66% { transform: translate(-25px, 20px) rotate(-4deg); }
}

.view { position: relative; z-index: 1; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.panel {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ------------------------------------------------------------ 로고 */
.logo {
  margin: 0;
  font-family: 'Jua', var(--font);
  font-size: clamp(54px, 10vw, 100px);
  line-height: 1;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  user-select: none;
  color: #fff;
}
.logo span {
  display: inline-block;
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
  text-shadow: 5px 6px 0 var(--ink);
  animation: hop 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * .09s);
}
.logo span:nth-child(n+7) { color: var(--yellow); }
.logo span:nth-child(odd) { transform: rotate(-4deg); }
.logo .pencil {
  font-size: .62em;
  margin-left: 8px;
  display: inline-block;
  animation: scribble 1.4s ease-in-out infinite;
  filter: drop-shadow(3px 3px 0 var(--ink));
}
.logo.small { font-size: 38px; }
.logo.small span { -webkit-text-stroke: 3px var(--ink); text-shadow: 3px 3px 0 var(--ink); }

@keyframes hop { 0%, 80%, 100% { translate: 0 0; } 88% { translate: 0 -10px; } }
@keyframes scribble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg) translate(-3px, 2px); } 75% { transform: rotate(8deg) translate(3px, -2px); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }

/* ------------------------------------------------------------ 홈 */
#home { display: flex; flex-direction: column; align-items: center; padding: 28px 16px 40px; }
.hero { text-align: center; }
.hero-crew { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 14px; min-height: 52px; }
.hero-crew img { width: 52px; height: 52px; animation: bob 1.8s ease-in-out infinite; filter: drop-shadow(3px 3px 0 rgba(29, 27, 58, .55)); }
.tagline {
  display: inline-block;
  background: var(--ink);
  color: var(--yellow);
  font-weight: 900;
  font-size: 16px;
  padding: 6px 16px;
  border-radius: 999px;
  margin: 14px 0 22px;
  transform: rotate(-1.5deg);
}

.home-card {
  width: min(430px, 100%);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 8px 8px 0 var(--ink);
}
.row { display: flex; gap: 8px; }
#nameInput {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 12px;
  border: 3px solid var(--ink);
  font-weight: 800;
  font-size: 17px;
  outline: none;
  background: #fff;
}
#nameInput:focus { box-shadow: 0 0 0 4px var(--yellow); }
select {
  padding: 8px 10px;
  border-radius: 12px;
  border: 3px solid var(--ink);
  background: #fff;
  font-weight: 800;
}
.avatar-picker {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 14px;
  border-radius: 14px;
  border: 3px dashed rgba(29, 27, 58, .35);
  background:
    radial-gradient(circle at 50% 60%, rgba(255, 210, 63, .55), transparent 60%),
    var(--soft);
}
.avatar-stage { width: 124px; height: 124px; display: grid; place-items: center; }
.avatar-stage img { width: 124px; height: 124px; animation: pop .25s ease-out; filter: drop-shadow(4px 5px 0 rgba(29, 27, 58, .4)); }
.arrow {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .1s;
}
.arrow:hover { transform: scale(1.12); background: var(--yellow); }
.arrow:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.dice { position: absolute; top: 6px; right: 8px; border: none; background: none; font-size: 26px; transition: transform .3s; }
.dice:hover { transform: rotate(180deg) scale(1.15); }

.btn {
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 900;
  font-size: 18px;
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover { filter: brightness(1.06); transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { filter: grayscale(.8) opacity(.6); cursor: not-allowed; transform: none; }
.btn.big { font-size: 30px; padding: 8px; }
.btn-green { background: var(--mint); }
.btn-blue { background: var(--sky); }
.btn-purple { background: var(--violet); color: #fff; font-size: 22px !important; }
.btn-red { background: var(--pink); color: #fff; }

.info-grid {
  margin-top: 44px;
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}
.info { padding: 18px 20px; }
.info:nth-child(1) { background: #fff3c4; transform: rotate(-1deg); }
.info:nth-child(2) { background: #d7f9ea; transform: rotate(.8deg); }
.info:nth-child(3) { background: #ffe0ec; transform: rotate(-.6deg); }
.info h2 { margin: 0 0 10px; font-size: 22px; text-align: center; }
.info p { line-height: 1.6; margin: 0; font-weight: 600; }
.how { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; font-weight: 600; }
.how li { display: flex; gap: 10px; align-items: flex-start; line-height: 1.45; }
.how-ic { font-size: 22px; }
.feats { padding-left: 4px; list-style: none; margin: 0; line-height: 2; font-weight: 700; }
.foot { margin-top: 30px; color: rgba(255, 255, 255, .7); font-size: 13px; font-weight: 700; }

/* ------------------------------------------------------------ 게임 */
#game { max-width: 1400px; margin: 0 auto; padding: 8px 16px 16px; }
.game-head { padding: 4px 0 8px; }
.game-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 6px 14px;
  min-height: 60px;
  margin-bottom: 12px;
  border-radius: 999px;
}
.bar-left { display: flex; align-items: center; gap: 12px; }
.bar-right { justify-self: end; }
.clock {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: conic-gradient(var(--yellow) var(--pct, 100%), #fff 0);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 17px;
  box-shadow: 2px 2px 0 var(--ink);
}
.clock span { background: #fff; border-radius: 50%; width: 34px; height: 34px; display: grid; place-items: center; }
.clock.hurry { background: conic-gradient(var(--red) var(--pct, 100%), #fff 0); animation: shake .5s infinite; }
.clock.hurry span { color: var(--red); }
@keyframes shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.round {
  font-weight: 900;
  font-size: 16px;
  white-space: nowrap;
  background: var(--ink);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
}
.bar-center { text-align: center; padding: 0 8px; }
.word-label { font-size: 11px; font-weight: 900; letter-spacing: 2px; color: var(--muted); }
.word-hint { display: flex; justify-content: center; align-items: flex-start; gap: 16px; flex-wrap: wrap; min-height: 30px; }
.word-seg { display: flex; gap: 5px; align-items: flex-end; }
.letter {
  display: inline-block;
  min-width: 18px;
  text-align: center;
  font-family: 'Jua', ui-monospace, Consolas, monospace;
  font-size: 26px;
  line-height: 1.1;
  border-bottom: 4px solid var(--ink);
  border-radius: 2px;
}
.letter.known { border-bottom-color: transparent; color: var(--violet); }
.letter.new { color: var(--good); animation: pop .4s; }
.word-len { font-size: 11px; font-weight: 900; margin-left: 3px; align-self: flex-start; background: var(--yellow); border-radius: 6px; padding: 0 4px; }
.icon-btn { border: none; background: none; font-size: 30px; transition: transform .3s; }
.icon-btn:hover { transform: rotate(60deg); }

.game-main {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: stretch;
}

/* 플레이어 목록: 카드형 */
.players {
  padding: 0;
  align-self: start;
  background: none;
  border: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.player {
  position: relative;
  display: grid;
  grid-template-columns: 36px 1fr 50px;
  align-items: center;
  padding: 5px 8px 5px 6px;
  min-height: 60px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .15s, background .2s;
  animation: pop .3s;
}
.player.clickable { cursor: pointer; }
.player.clickable:hover { transform: translateX(4px); }
.player.me { background: #fff3c4; }
.player.guessed { background: var(--mint) !important; }
.player.me .p-name { color: var(--violet); }
.p-rank {
  font-weight: 900;
  font-size: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--soft);
  border: 2px solid var(--ink);
}
.p-info { text-align: center; min-width: 0; }
.p-name { font-weight: 900; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-score { font-size: 13px; font-weight: 800; color: var(--muted); }
.player.guessed .p-score { color: var(--ink); }
.p-av { position: relative; width: 50px; height: 50px; }
.p-av img { width: 50px; height: 50px; }
.p-badge { position: absolute; font-size: 20px; filter: drop-shadow(0 1px 0 #fff); }
.p-badge.pen { left: -14px; bottom: 0; animation: scribble 1s infinite; }
.p-badge.crown { left: 50%; top: -14px; transform: translateX(-50%); font-size: 18px; }
.p-delta {
  position: absolute;
  right: -10px;
  top: -10px;
  font-weight: 900;
  font-size: 13px;
  color: var(--ink);
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0 7px;
  animation: pop .4s;
}
.p-votes {
  position: absolute;
  left: -6px;
  bottom: -8px;
  font-size: 11px;
  background: var(--red);
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 0 5px;
  font-weight: 800;
}

/* 캔버스: 스케치북 */
.board { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.canvas-wrap { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: #fff; }
.canvas-wrap::before, .canvas-wrap::after {
  /* 마스킹 테이프 */
  content: '';
  position: absolute;
  top: -6px;
  width: 90px;
  height: 26px;
  background: rgba(255, 210, 63, .75);
  border: 1px solid rgba(29, 27, 58, .15);
  z-index: 2;
  pointer-events: none;
}
.canvas-wrap::before { left: 18px; transform: rotate(-6deg); }
.canvas-wrap::after { right: 18px; transform: rotate(5deg); background: rgba(255, 93, 143, .6); }
#canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: #fff;
}
#canvas.can-draw { cursor: none; }
#canvas.can-fill { cursor: crosshair; }
.brush-cursor {
  position: absolute;
  pointer-events: none;
  border: 2px solid rgba(0, 0, 0, .7);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .8);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
}
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(42, 38, 80, .9);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 5;
  animation: fadeIn .25s;
  overflow: auto;
}
.overlay.solid {
  background:
    radial-gradient(rgba(255, 255, 255, .07) 1.5px, transparent 1.7px) 0 0 / 22px 22px,
    var(--dark-panel);
  justify-content: flex-start;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.ov-title { font-family: 'Jua', var(--font); font-size: clamp(24px, 3.4vw, 38px); margin: 4px 0; text-align: center; animation: pop .35s; }
.ov-sub { font-size: clamp(14px, 1.6vw, 18px); font-weight: 700; opacity: .85; margin-bottom: 14px; text-align: center; }
.ov-word { color: var(--yellow); }
.ov-count { font-size: 46px; font-weight: 900; animation: pop .3s; color: var(--yellow); }
.choices { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin: 18px 0; }
.choice {
  border: 3px solid var(--ink);
  background: #fff;
  color: var(--ink);
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 900;
  padding: 10px 20px;
  border-radius: 14px;
  box-shadow: 4px 4px 0 var(--yellow);
  transition: transform .12s, background .12s;
  animation: pop .3s backwards;
}
.choice:nth-child(2) { box-shadow: 4px 4px 0 var(--pink); }
.choice:nth-child(3) { box-shadow: 4px 4px 0 var(--mint); }
.choice:nth-child(4) { box-shadow: 4px 4px 0 var(--sky); }
.choice:hover { background: var(--yellow); transform: scale(1.07) rotate(-2deg); }
.ov-avatar { width: 100px; height: 100px; animation: bob 1.4s infinite; }
.score-list { display: grid; grid-template-columns: auto auto; gap: 4px 50px; font-size: clamp(14px, 1.8vw, 20px); font-weight: 800; }
.score-list .pos { color: var(--mint); text-align: right; }
.score-list .zero { color: #ff7a7a; text-align: right; }

/* 시상대 */
.podium { display: flex; align-items: flex-end; gap: 10px; margin: 10px 0 14px; }
.pod { display: flex; flex-direction: column; align-items: center; width: clamp(80px, 14vw, 130px); animation: pop .5s backwards; }
.pod img { width: 70%; animation: bob 1.6s infinite; }
.pod .pod-name { font-weight: 900; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .pod-score { font-size: 13px; opacity: .85; }
.pod .block {
  width: 100%;
  margin-top: 6px;
  border: 3px solid var(--ink);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 900;
  color: var(--ink);
}
.pod.p1 .block { height: 110px; background: var(--yellow); }
.pod.p2 .block { height: 80px; background: var(--sky); }
.pod.p3 .block { height: 60px; background: var(--orange); }
.pod.p1 { order: 2; animation-delay: .4s; }
.pod.p2 { order: 1; animation-delay: .2s; }
.pod.p3 { order: 3; }
.rest { font-size: 14px; opacity: .85; text-align: center; }

/* 로비 설정 */
.lobby { width: 100%; max-width: 760px; display: flex; flex-direction: column; gap: 6px; }
.set-row { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 10px; }
.set-row label { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.set-ic { font-size: 22px; width: 28px; text-align: center; }
.set-row select { width: 100%; padding: 5px 8px; color: var(--ink); border-width: 2px; border-radius: 10px; }
.custom-head { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-weight: 900; }
.custom-head label { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.custom-head input { width: 18px; height: 18px; accent-color: var(--yellow); }
.lobby textarea {
  width: 100%;
  min-height: 90px;
  flex: 1;
  resize: vertical;
  border-radius: 12px;
  border: 2px solid var(--ink);
  padding: 8px;
  color: var(--ink);
}
.lobby-actions { display: grid; grid-template-columns: 1fr auto 1.1fr; gap: 8px; margin-top: 6px; }
.invite {
  background: #fff;
  color: var(--violet);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 8px;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  filter: blur(4px);
  transition: filter .2s;
  user-select: all;
}
.invite:hover, .invite:focus { filter: none; }
.lobby .btn { font-size: 18px; }
.lobby .wait-msg { grid-column: 2 / 4; align-self: center; text-align: center; font-weight: 800; opacity: .85; }
.lobby select:disabled, .lobby textarea:disabled, .lobby input:disabled { opacity: .7; }

/* 도구 */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 10px; }
.cur-color { position: relative; width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--ink); overflow: hidden; box-shadow: 2px 2px 0 var(--ink); }
.cur-color input { position: absolute; inset: -10px; width: 70px; height: 70px; border: none; padding: 0; cursor: pointer; opacity: 0; }
.palette { display: grid; grid-template-columns: repeat(13, 22px); grid-auto-rows: 22px; gap: 2px; }
.swatch { border: 2px solid var(--ink); border-radius: 6px; padding: 0; width: 22px; height: 22px; }
.swatch:hover { transform: scale(1.3); position: relative; z-index: 1; }
.tool-group { display: flex; gap: 5px; }
.tool, .size {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 22px;
  transition: transform .1s;
}
.tool:hover, .size:hover { transform: translateY(-2px); }
.tool.active, .size.active { background: var(--yellow); box-shadow: 2px 2px 0 var(--ink); }
.size i { display: block; background: var(--ink); border-radius: 50%; }

.rate-box { position: absolute; top: 26px; right: 14px; display: flex; gap: 6px; z-index: 4; }
.rate-box button { border: none; background: none; font-size: 36px; filter: drop-shadow(2px 2px 0 rgba(29, 27, 58, .4)); transition: transform .12s; }
.rate-box button:hover { transform: scale(1.2) rotate(-8deg); }

.react-layer { position: absolute; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.float-react { position: absolute; bottom: 0; font-size: 38px; animation: floatUp 2.6s ease-out forwards; text-align: center; }
.float-react small { display: block; font-size: 11px; font-weight: 800; background: var(--ink); color: #fff; border-radius: 6px; padding: 0 5px; }
@keyframes floatUp {
  0% { transform: translateY(20px) scale(.5); opacity: 0; }
  15% { transform: translateY(-20px) scale(1.2); opacity: 1; }
  100% { transform: translateY(-340px) scale(1) rotate(var(--rot)); opacity: 0; }
}

/* 채팅: 말풍선 */
.chat { position: relative; min-height: 300px; }
.chat-inner { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 8px; }
.chat-log { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 4px; padding-right: 2px; }
.chat-log::before { content: ''; flex: 1; }
.msg {
  align-self: flex-start;
  max-width: 100%;
  padding: 4px 10px;
  font-size: 14px;
  line-height: 1.35;
  word-break: break-word;
  background: var(--soft);
  border-radius: 4px 14px 14px 14px;
  font-weight: 600;
}
.msg b { font-weight: 900; color: var(--violet); }
.msg.sys {
  align-self: center;
  text-align: center;
  background: none;
  font-size: 13px;
  font-weight: 800;
  border-radius: 999px;
  padding: 2px 10px;
}
.msg.c-good { color: var(--good); background: var(--good-bg); }
.msg.c-info { color: var(--info); }
.msg.c-warn { color: var(--warn); }
.msg.c-leave { color: var(--leave); }
.msg.known { background: var(--good-bg); color: #0d6b47; }
.react-bar { display: flex; justify-content: space-between; padding: 6px 2px; border-top: 2px dashed rgba(29, 27, 58, .15); margin-top: 4px; }
.react-bar button { border: none; background: none; font-size: 19px; padding: 2px; transition: transform .1s; }
.react-bar button:hover { transform: scale(1.35) rotate(-10deg); }
#chatInput {
  width: 100%;
  padding: 9px 12px;
  border-radius: 12px;
  border: 3px solid var(--ink);
  outline: none;
  background: #fff;
  font-weight: 700;
}
#chatInput:focus { box-shadow: 0 0 0 3px var(--yellow); }

/* 팝오버 */
.popover {
  position: fixed;
  z-index: 50;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px;
  min-width: 210px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: pop .15s;
}
.pop-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 800; }
.pop-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--violet); }
.pop-row input[type=range] { width: 110px; accent-color: var(--violet); }
.pm-head { display: flex; align-items: center; gap: 10px; font-weight: 900; }
.pm-head img { width: 44px; height: 44px; }
.popover .btn { font-size: 15px; }

/* 토스트 & 꽃가루 */
.toast {
  position: fixed;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--yellow);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 900;
  z-index: 100;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .25);
  animation: pop .2s;
  max-width: calc(100% - 32px);
}
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 14px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translate3d(var(--dx), 110vh, 0) rotate(var(--r)); } }

/* ------------------------------------------------------------ 반응형 */
@media (max-width: 1100px) {
  .game-main { grid-template-columns: 190px minmax(0, 1fr) 250px; }
  .palette { grid-template-columns: repeat(13, 18px); grid-auto-rows: 18px; }
  .swatch { width: 18px; height: 18px; }
}
@media (max-width: 860px), (max-width: 1100px) and (orientation: portrait) {
  #game { padding: 6px 8px 10px; }
  .game-head { display: none; }
  .info-grid { grid-template-columns: 1fr; }
  .info { transform: none !important; }
  .game-bar { grid-template-columns: auto 1fr auto; padding: 4px 8px; border-radius: 18px; }
  .round { font-size: 12px; padding: 3px 8px; }
  .clock { width: 42px; height: 42px; font-size: 14px; }
  .clock span { width: 28px; height: 28px; }
  .letter { font-size: 19px; min-width: 13px; }
  .game-main {
    grid-template-columns: 44% 1fr;
    grid-template-areas: "board board" "players chat";
    gap: 10px;
  }
  .board { grid-area: board; }
  .players { grid-area: players; max-height: var(--rest, 320px); overflow-y: auto; padding: 2px 6px 6px 2px; }
  .chat { grid-area: chat; height: var(--rest, 320px); min-height: 0; }
  .player { grid-template-columns: 28px 1fr 40px; min-height: 48px; }
  .p-rank { width: 24px; height: 24px; font-size: 12px; }
  .p-av, .p-av img { width: 40px; height: 40px; }
  .p-name { font-size: 13px; }
  .toolbar { gap: 6px; justify-content: center; }
  .tool, .size { width: 36px; height: 36px; font-size: 18px; }
  .set-row { grid-template-columns: 1.2fr 1fr; gap: 6px; }
  .set-row label { font-size: 13px; gap: 4px; }
  .lobby-actions { grid-template-columns: 1fr auto; }
  .lobby-actions .btn-green, .lobby .wait-msg { grid-column: 1 / 3; }
}

/* 오른쪽→왼쪽 언어(아랍어 등): 로고와 시계 숫자는 항상 왼→오 */
.logo, .clock, .round { direction: ltr; }
[dir=rtl] .player.clickable:hover { transform: translateX(-4px); }
.foot a { color: rgba(255, 255, 255, .6); font-size: 11px; text-decoration: none; }
.foot a:hover { text-decoration: underline; }
.foot { text-align: center; max-width: 900px; line-height: 1.8; }
.lang-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; margin-bottom: 10px; }
.lang-links a { font-size: 12px; color: rgba(255, 255, 255, .75); }
.lang-links a[aria-current] { color: var(--yellow); font-weight: 900; }

/* ------------------------------------------------------------ 모바일 보완 */
#langSelect { max-width: 45%; min-width: 0; }
.react-bar { flex-wrap: wrap; justify-content: center; gap: 2px 6px; }

@media (max-width: 860px), (max-width: 1100px) and (orientation: portrait) {
  /* 비공개방 설정 화면: 캔버스 크기에 갇히지 않고 내용만큼 늘어남 */
  .canvas-wrap.lobby-mode { aspect-ratio: auto; }
  .canvas-wrap.lobby-mode #canvas { display: none; }
  .canvas-wrap.lobby-mode .overlay { position: relative; inset: auto; overflow: visible; padding: 14px 12px; }
  .react-bar button { font-size: 17px; }
  .home-card { padding: 14px; }
  .btn.big { font-size: 26px; }
}

/* 가로 모드 휴대폰: 3단 배치 + 캔버스를 화면 높이에 맞춤 */
@media (max-width: 1000px) and (max-height: 500px) and (orientation: landscape) {
  .game-head { display: none; }
  #game { padding: 4px 8px; }
  .game-bar { min-height: 44px; margin-bottom: 6px; padding: 2px 10px; }
  .game-main { grid-template-columns: 150px minmax(0, 1fr) 210px; grid-template-areas: none; gap: 8px; }
  .board, .players, .chat { grid-area: auto; }
  .canvas-wrap:not(.lobby-mode) { width: 100%; max-width: calc((100vh - 70px) * 4 / 3); margin: 0 auto; }
  .players { max-height: calc(100vh - 70px); }
  .chat { height: calc(100vh - 70px); }
  .player { grid-template-columns: 22px 1fr 34px; min-height: 40px; padding: 3px 5px; }
  .p-av, .p-av img { width: 34px; height: 34px; }
}
@media (max-width: 860px), (max-width: 1100px) and (orientation: portrait) {
  /* 점수 배지(+440)가 목록 밖으로 삐져나가 가로 스크롤이 생기지 않게 */
  .players { overflow-x: hidden; padding: 12px 12px 6px 2px; }
}
@media (max-width: 1000px) and (max-height: 500px) and (orientation: landscape) {
  /* 가로 모드: 도구를 캔버스 옆 세로 막대로 (스크롤 없이 그리기) */
  .board { flex-direction: row; align-items: flex-start; gap: 6px; }
  .board .canvas-wrap { flex: 1; min-width: 0; }
  .toolbar {
    flex-direction: column; flex-wrap: nowrap; width: 92px; flex-shrink: 0; gap: 5px; padding: 5px;
    max-height: calc(100vh - 70px); overflow-y: auto;
  }
  .cur-color { width: 30px; height: 30px; }
  .palette { grid-template-columns: repeat(4, 17px); grid-auto-rows: 17px; }
  .swatch { width: 17px; height: 17px; }
  .tool-group { flex-wrap: wrap; justify-content: center; gap: 3px; }
  .tool, .size { width: 26px; height: 26px; font-size: 14px; border-radius: 8px; }
}

/* ------------------------------------------------------------ 캐릭터 그리드 선택 */
.avatar-stage img { cursor: pointer; }
.grid-btn {
  position: absolute; top: 6px; left: 8px; border: none; background: none;
  font-size: 24px; line-height: 1; color: var(--ink); transition: transform .15s;
}
.grid-btn:hover { transform: scale(1.2); }
.av-count {
  position: absolute; bottom: 6px; right: 10px; font-size: 12px; font-weight: 900;
  color: var(--muted); direction: ltr;
}
.modal {
  position: fixed; inset: 0; z-index: 80; background: rgba(29, 27, 58, .55);
  display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadeIn .2s;
}
.modal-panel {
  position: relative; width: min(640px, 100%); max-height: min(80vh, 640px);
  padding: 18px 14px 14px; display: flex; flex-direction: column; animation: pop .2s;
}
.modal-close {
  position: absolute; top: -14px; right: -14px; width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid var(--ink); background: var(--pink); color: #fff; font-weight: 900; font-size: 16px;
  box-shadow: 2px 2px 0 var(--ink);
}
.char-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px;
  overflow-y: auto; padding: 4px;
}
.char-grid button {
  aspect-ratio: 1; border: 3px solid transparent; border-radius: 14px; background: var(--soft);
  padding: 6px; transition: transform .12s, border-color .12s;
}
.char-grid button:hover { transform: translateY(-3px) rotate(-3deg); border-color: var(--ink); }
.char-grid button.active { border-color: var(--ink); background: var(--yellow); box-shadow: 2px 2px 0 var(--ink); }
.char-grid img { width: 100%; height: 100%; display: block; }
@media (max-width: 860px) {
  .char-grid { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
  .modal-close { top: -10px; right: -6px; }
}

/* 국기 (Windows 도 국기 모양으로 보이도록 국기 지원 컬러 이모지 폰트 사용) */
.flag {
  font-family: 'Noto Color Emoji', 'Apple Color Emoji', sans-serif;
  font-weight: 400;
  margin-right: 4px;
  display: inline-block;
  vertical-align: -1px;
  cursor: help;
}

/* ------------------------------------------------------------ 글자 선명도 */
.clarity-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 800; font-size: 14px; }
.clarity-select { padding: 6px 10px; }

/* 선명하게: 작은 글자를 화면에 또렷하게 나오는 기본 글꼴로 + 대비 강화 (로고·큰 제목은 그대로) */
:root[data-clarity] {
  --font: system-ui, -apple-system, 'Segoe UI', 'Malgun Gothic', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Noto Sans', sans-serif;
  --muted: #45426a;
  --good: #0a7a4f;
  --info: #3b25b8;
  --warn: #a85400;
  --leave: #c0321f;
}
:root[data-clarity] body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
:root[data-clarity] .msg { font-weight: 500; color: var(--ink); }
:root[data-clarity] .msg b { font-weight: 700; }
:root[data-clarity] .msg.sys { font-weight: 700; }
:root[data-clarity] .msg.c-good { color: var(--good); }
:root[data-clarity] .msg.c-info { color: var(--info); }
:root[data-clarity] .msg.c-warn { color: var(--warn); }
:root[data-clarity] .msg.c-leave { color: var(--leave); }
:root[data-clarity] .p-name { font-weight: 700; }
:root[data-clarity] .p-score { font-weight: 600; color: var(--ink); }
:root[data-clarity] .tagline, :root[data-clarity] .info p, :root[data-clarity] .how, :root[data-clarity] .feats { font-weight: 500; }
:root[data-clarity] .word-label { color: var(--ink); }
:root[data-clarity] .overlay { background: rgba(28, 25, 52, .94); }
:root[data-clarity] .ov-sub, :root[data-clarity] .rest { opacity: 1; }

/* 아주 선명하게: 위 설정 + 글자 크기 키움 */
:root[data-clarity="large"] .msg { font-size: 16px; line-height: 1.45; padding: 5px 11px; }
:root[data-clarity="large"] .msg.sys { font-size: 15px; }
:root[data-clarity="large"] .p-name { font-size: 17px; }
:root[data-clarity="large"] .p-score { font-size: 15px; }
:root[data-clarity="large"] #chatInput { font-size: 17px; }
:root[data-clarity="large"] .round { font-size: 18px; }
:root[data-clarity="large"] .word-label { font-size: 13px; }
:root[data-clarity="large"] .score-list { font-size: clamp(16px, 2vw, 22px); }
:root[data-clarity="large"] .set-row label { font-size: 16px; }
:root[data-clarity="large"] .info p, :root[data-clarity="large"] .how li, :root[data-clarity="large"] .feats li { font-size: 16px; }
@media (max-width: 860px) {
  :root[data-clarity="large"] .p-name { font-size: 15px; }
  :root[data-clarity="large"] .msg { font-size: 15px; }
}
/* 공개방 대기 화면: 방장 시작 버튼 / 다른 방 찾기 */
.wait-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 18px; }
.wait-btn { margin-top: 18px; min-width: 220px; padding: 12px 26px; font-size: 1.05rem; }
.wait-actions .wait-btn { margin-top: 0; }
.wait-actions .wait-msg { font-weight: 800; opacity: .85; color: #fff; }
/* 휴대폰: 장식이 너무 빽빽하지 않게 일부만 */
@media (max-width: 600px) { .bg-deco span:nth-child(n+17) { display: none; } }
/* 홈 화면 접속자 수 */
.online-pill { display: flex; width: fit-content; align-items: center; gap: 8px; margin: 10px auto 0; padding: 5px 14px; border-radius: 999px; background: rgba(20, 16, 40, .55); color: #fff; font-weight: 700; font-size: .9rem; }
.online-pill i { width: 9px; height: 9px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 0 rgba(61, 220, 132, .7); animation: online-ping 2s infinite; }
@keyframes online-ping { 70% { box-shadow: 0 0 0 7px rgba(61, 220, 132, 0); } 100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); } }

/* ------------------------------------------------------------ 태블릿(아이패드)·PC: 한 화면에 맞춤 */
/* 캔버스 최대 너비는 app.js fitGame() 이 화면 높이로 계산 (--cv-max) */
/* (가로 모드 휴대폰은 위쪽 전용 규칙을 그대로 씀) */
@media (min-width: 1001px), (min-height: 501px), (orientation: portrait) {
  .canvas-wrap:not(.lobby-mode), .board .toolbar { width: 100%; max-width: var(--cv-max, none); margin-left: auto; margin-right: auto; box-sizing: border-box; }
  .canvas-wrap.lobby-mode { max-width: var(--cv-max, none); width: 100%; margin: 0 auto; }
}
/* 높이가 낮은 화면(아이패드 가로 등)은 위쪽 로고를 숨겨 그림판을 크게 */
@media (min-width: 861px) and (max-height: 860px) { .game-head { display: none; } }
/* 터치 기기: 두 번 탭 확대·길게 눌러 선택/메뉴·탭 하이라이트 없애기 (펜으로 그릴 때 방해되지 않게) */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
.canvas-wrap, .toolbar, .game-bar, .players { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button, .swatch, .tool, .size { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* 아이패드에선 도구 버튼을 손가락·펜으로 누르기 편하게 조금 크게 */
@media (pointer: coarse) and (min-width: 700px) {
  .swatch { width: 26px; height: 26px; }
  .palette { grid-template-columns: repeat(13, 26px); grid-auto-rows: 26px; gap: 3px; }
  .tool, .size { width: 46px; height: 46px; }
}
/* 아이패드 가로: 양옆(플레이어·채팅)을 조금 좁혀 그림판을 크게 */
@media (min-width: 861px) and (max-width: 1250px) and (orientation: landscape) and (min-height: 501px) {
  #game { padding: 6px 10px 10px; }
  .game-main { grid-template-columns: 178px minmax(0, 1fr) 240px; gap: 10px; }
  .game-bar { margin-bottom: 8px; }
  .player { grid-template-columns: 28px 1fr 42px; }
  .p-av, .p-av img { width: 42px; height: 42px; }
}
