:root {
  --ink: #2b2b33;
  --paper: #fffdf6;
  --blue: #1f6feb;
  --yellow: #ffd23f;
  --red: #ff5a5a;
  --muted: #4f5462;
  /* 본문: 작은 크기에서도 또렷한 글꼴 / 제목·버튼: 둥글고 귀여운 글꼴 */
  --font: 'Noto Sans KR', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
  --display: 'Jua', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #fbf6ea;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--display); font-weight: 400; letter-spacing: 0.01em; }

#table {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

[hidden] { display: none !important; }

/* 손으로 그린 테두리 */
.sketch {
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  box-shadow: 3px 4px 0 rgb(43 43 51 / 85%);
}

.btn {
  font-family: var(--display);
  font-weight: 400;
  font-size: 18px;
  line-height: 1.3;
  color: var(--ink);
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 15px 225px 15px 255px / 255px 15px 225px 15px;
  box-shadow: 2px 3px 0 var(--ink);
  padding: 6px 16px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn:hover:not(:disabled) { transform: translate(-1px, -1px) rotate(-1deg); box-shadow: 3px 4px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translate(2px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--yellow); }
.btn.big { font-size: 22px; padding: 8px 22px; }
.btn.small { font-size: 16px; padding: 3px 12px; }
.btn small { font-family: var(--font); font-size: 13px; font-weight: 500; opacity: 0.8; }

.sub { font-size: 14px; color: var(--muted); }
.wait { font-size: 15px; color: var(--muted); margin-top: 6px; }

/* ---- 화면 위에 붙는 것들 ---- */
.hud { position: fixed; z-index: 10; }

.corner { top: 12px; right: 12px; z-index: 40; display: flex; gap: 8px; }

.status { top: 10px; left: 10px; padding: 6px 14px 6px; }
.status-top { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.swatch { width: 18px; height: 18px; border: 2px solid var(--ink); border-radius: 50%; display: inline-block; flex: none; }
.track { display: flex; align-items: center; gap: 2px; }
.track-label { font-size: 15px; color: #6b6f7d; margin-right: 2px; }
.track-label.gap { margin-left: 10px; }
.track-icon { width: 30px; height: 24px; }

.action {
  right: 14px;
  bottom: 14px;
  width: min(360px, 30vw);
  padding: 12px 18px 14px;
  text-align: center;
}
.action.my-turn { background: #fff5c7; animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 0%, 100% { box-shadow: 3px 4px 0 rgb(43 43 51 / 85%), 0 0 0 0 rgb(255 207 51 / 0%); } 50% { box-shadow: 3px 4px 0 rgb(43 43 51 / 85%), 0 0 0 8px rgb(255 207 51 / 55%); } }
.turn-line { font-size: 20px; font-weight: 700; line-height: 1.3; }
.hand-line { margin: 6px 0 8px; font-size: 19px; color: var(--blue); font-weight: 700; }
#passBtn { width: 100%; }

.left-stack {
  left: 14px;
  bottom: 14px;
  width: min(300px, 26vw);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.log {
  padding: 8px 14px;
  font-size: 15px;
  max-height: 30vh;
  overflow: hidden;
}
.notes {
  padding: 6px 14px;
  font-size: 15px;
  background: #eef6ff;
  max-height: 24vh;
  overflow-y: auto;
}
.notes ul { margin: 0; padding-left: 16px; }
.notes li { line-height: 1.35; font-weight: 700; color: #1d4f9c; }
.log ul { list-style: none; margin: 0; padding: 0; }
.log li { line-height: 1.35; }
.log .log-round, .log .log-heist { color: #6b6f7d; font-weight: 700; }
.log .log-steal { color: #c2410c; font-weight: 700; }
.log .log-success { color: #2f9e44; font-weight: 700; }
.log .log-alarm { color: #e03131; font-weight: 700; }

.result {
  right: 14px;
  bottom: 14px;
  width: min(360px, 30vw);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 10px 14px 12px;
  background: #eafbe7;
}
.result.fail { background: #ffe8e8; }
.result h3 { margin: 0 0 2px; font-size: 22px; line-height: 1.15; }
.result ol { list-style: none; padding: 0; margin: 6px 0; }
.result li { display: flex; align-items: center; gap: 6px; padding: 3px 2px; border-bottom: 2px dashed rgb(43 43 51 / 18%); }
.result li.bad { background: rgb(255 90 90 / 15%); }
.row-cat { width: 30px; height: 30px; flex: none; }
.row-info { flex: 1; display: flex; flex-wrap: wrap; gap: 0 6px; align-items: baseline; font-size: 17px; line-height: 1.2; }
.hand-name { color: var(--blue); font-weight: 700; }
.row-cards { width: 100%; display: flex; gap: 2px; }
.mini-card { background: #fff; border: 1.5px solid var(--ink); border-radius: 4px; padding: 0 3px; font-size: 13px; font-weight: 700; font-family: system-ui, sans-serif; }
.mini-card.red { color: #e0444b; }
.chip-badge { flex: none; border: 2px solid var(--ink); border-radius: 50%; width: 32px; height: 32px; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.mark { font-size: 22px; font-weight: 700; width: 20px; text-align: center; }
li.good .mark { color: #2f9e44; }
li.bad .mark { color: #e03131; }
#nextBtn { width: 100%; margin-top: 8px; }

.toasts {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 225px 15px 255px 15px / 15px 255px 15px 225px;
  box-shadow: 2px 3px 0 var(--ink);
  padding: 6px 18px;
  font-size: 20px;
  font-weight: 700;
  animation: pop 0.2s ease-out;
  transition: opacity 0.35s;
}
.toast.round { background: #e7f0ff; }
.toast.steal { background: #fff0db; }
.toast.alert { background: #ffd9d9; }
.toast.out { opacity: 0; }
@keyframes pop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.tip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 17px;
}

/* ---- 메인 화면과 로비 ---- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgb(251 246 234 / 72%);
  overflow-y: auto;
}
.menu-box { text-align: center; padding: 20px; }
.menu-box h1 { font-size: 92px; margin: 0; line-height: 1; letter-spacing: 2px; transform: rotate(-2deg); text-shadow: 4px 4px 0 var(--yellow); }
.subtitle { font-size: 22px; margin: 10px 0 26px; }
.menu-cats { display: flex; justify-content: center; gap: 4px; margin-bottom: 8px; }
.menu-cat { width: 72px; height: 72px; }
.menu-cat:nth-child(odd) { transform: rotate(-6deg); }
.menu-cat:nth-child(even) { transform: rotate(5deg) translateY(4px); }
.menu-buttons { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.menu-buttons .btn { width: 300px; }

.panel { padding: 18px 26px 22px; }
.lobby-box { width: min(640px, 94vw); text-align: center; }
.lobby-box h2 { margin: 0 0 6px; font-size: 34px; }
.room-code { display: flex; gap: 10px; align-items: center; justify-content: center; font-size: 24px; }
.seats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.seat { border: 2px dashed #a5acbb; border-radius: 14px; padding: 6px; }
.seat img { width: 64px; height: 64px; }
.seat.you { border: 2.5px solid var(--blue); background: #e7f0ff; }
.seat.out { opacity: 0.35; }
.seat-name { font-weight: 700; font-size: 20px; }
.seat-tag { font-size: 15px; color: #6b6f7d; }
.seat-tag.on { color: #2f9e44; font-weight: 700; }
.label { font-weight: 700; font-size: 20px; margin: 10px 0 6px; }
.count-row { display: flex; gap: 10px; justify-content: center; }
.btn.count { width: 54px; }
.btn.count.on { background: var(--yellow); transform: rotate(-3deg); }
.lobby-box .btn.big { margin-top: 10px; min-width: 240px; }
.error { color: #e03131; font-weight: 700; }
.error-detail { white-space: pre-wrap; text-align: left; font-size: 13px; user-select: text; }

/* ---- 규칙 창 ---- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 45%);
}
.overlay[hidden] { display: none; }
.rules-box { max-width: 620px; max-height: 84vh; overflow-y: auto; line-height: 1.55; }
.rules-box h2 { margin-top: 0; }
.rules-box li { margin-bottom: 4px; }

/* ---- 특수 카드 ---- */
.pills { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; max-width: 300px; }
.pills[hidden] { display: none; }
.btn.pill { font-size: 14px; padding: 1px 10px; box-shadow: 1px 2px 0 var(--ink); }
.btn.pill.challenge { background: #ffd9d9; }
.btn.pill.specialist { background: #d9f5dc; }

.choice-row { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin: 6px 0; }
.choice-row:empty { display: none; }
.btn.choice { font-size: 16px; padding: 2px 9px; min-width: 38px; box-shadow: 1px 2px 0 var(--ink); }
.btn.choice.red { color: #e0444b; }
.btn.choice.on { background: var(--yellow); transform: rotate(-3deg); }
.special-btn { width: 100%; margin-bottom: 6px; background: #d9f5dc; }

.brief-box { max-width: 520px; text-align: center; }
.brief-box h2 { margin: 0 0 4px; }
.brief-card { text-align: left; border: 2px dashed #a5acbb; border-radius: 12px; padding: 6px 12px; margin: 10px 0; }
.brief-card.challenge { background: #fff0f0; }
.brief-card.specialist { background: #effbf0; }
.brief-card h3 { margin: 0; font-size: 22px; }
.brief-card p { margin: 2px 0 0; }
.brief-tag { font-size: 14px; color: #6b6f7d; font-weight: 700; }

.special-box { max-width: 480px; text-align: center; }
.special-box h2 { margin: 0; }
.dialog-buttons { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }

.muscle-tag { background: #ffd23f; border: 1.5px solid var(--ink); border-radius: 8px; padding: 0 6px; font-size: 13px; font-weight: 700; }
.mini-card.wild { color: #7b4fd6; background: #f1e9ff; }
.btn.mode { min-width: 86px; }
.btn.mode.on { background: var(--yellow); transform: rotate(-2deg); }
.mode-desc { min-height: 1.4em; }

/* ---- 튜토리얼 ---- */
.coach {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: min(600px, 44vw);
  z-index: 25;
  padding: 10px 16px 12px;
  background: #fffbe8;
}
.coach-head { display: flex; align-items: center; gap: 10px; }
.coach-head > div { flex: 1; }
.coach-cat { width: 52px; height: 52px; flex: none; }
.coach-title { font-weight: 700; font-size: 17px; color: #6b6f7d; }
.coach-text { font-size: 20px; line-height: 1.45; margin: 6px 2px; }
.coach-text p { margin: 0 0 4px; }
.coach-hint { background: #ffe1d6; border: 2px dashed #ff7a59; border-radius: 10px; padding: 3px 10px; font-weight: 700; margin: 4px 0; }
.coach-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }
.coach-actions .sub { margin-right: auto; font-weight: 700; color: #ff7a59; }
.coach-actions .btn.quiz { flex: 1 1 40%; }
.coach-actions .btn.quiz.right { background: #c9f2cf; }
.coach-actions .btn.quiz.wrong { background: #ffd2d2; }
.coach-explain { background: #e6f7e8; border-radius: 10px; padding: 4px 10px; margin: 4px 0; font-weight: 700; }
body.tutorial .toasts { top: auto; bottom: 230px; }

.tut-focus { outline: 4px solid #ff7a59 !important; outline-offset: 4px; animation: tutglow 1s ease-in-out infinite; }
@keyframes tutglow { 0%, 100% { outline-color: #ff7a59; } 50% { outline-color: #ffd23f; } }


.btn.quiz.right:disabled { opacity: 1; }
.btn.quiz:disabled:not(.right) { opacity: 0.4; }

/* ---- 읽기 편하게: 글꼴과 크기 정리 ---- */
.status-top { font-family: var(--display); font-size: 18px; }
.status-top b { font-weight: 400; }
.track-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.turn-line { font-family: var(--display); font-weight: 400; font-size: 19px; line-height: 1.35; }
.hand-line { font-size: 15px; font-weight: 700; }
.log { font-size: 13.5px; line-height: 1.5; }
.log .log-round, .log .log-heist, .log .log-steal, .log .log-success, .log .log-alarm { font-weight: 700; }
.notes { font-size: 13.5px; }
.notes li { font-weight: 500; }
.result h3 { font-size: 22px; }
.row-info { font-size: 14px; line-height: 1.35; }
.row-info b { font-weight: 700; }
.mini-card { font-size: 12.5px; padding: 0 4px; }
.chip-badge { font-family: var(--display); font-weight: 400; font-size: 15px; }
.mark { font-family: var(--display); font-weight: 400; }

.toast { font-family: var(--display); font-weight: 400; font-size: 18px; }
.tip { font-size: 14px; font-weight: 500; padding: 4px 10px; }

.menu-box h1 { font-family: var(--display); font-size: 88px; letter-spacing: 4px; }
.subtitle { font-size: 17px; font-weight: 500; color: var(--muted); }
.room-code { font-family: var(--display); font-size: 22px; }
.room-code b { font-weight: 400; letter-spacing: 2px; }
.seat-name { font-family: var(--display); font-weight: 400; font-size: 19px; }
.seat-tag { font-size: 13px; font-weight: 500; }
.label { font-family: var(--display); font-weight: 400; font-size: 18px; }
.lobby-box .sub { line-height: 1.6; }

.brief-card h3 { font-size: 22px; }
.brief-card p { font-size: 15px; line-height: 1.6; }
.brief-tag { font-size: 12px; font-weight: 700; letter-spacing: 0.05em; }
.special-box p { font-size: 15px; line-height: 1.6; }
.btn.pill { font-size: 14px; }
.btn.choice { font-size: 15px; }
.rules-box { font-size: 15px; line-height: 1.75; }
.rules-box b { font-weight: 700; }

.coach-title { font-family: var(--display); font-weight: 400; font-size: 16px; color: var(--muted); }
.coach-bar { height: 8px; margin-top: 5px; border: 1.5px solid var(--ink); border-radius: 6px; background: #fff; overflow: hidden; }
.coach-bar span { display: block; height: 100%; width: 0; background: var(--yellow); transition: width 0.3s; }
.coach-text { font-size: 16.5px; line-height: 1.65; }
.coach-text p { margin: 0 0 6px; }
.coach-hint { font-size: 15px; }
.coach-actions .sub { font-family: var(--display); font-weight: 400; font-size: 16px; }
.coach-explain { font-size: 15px; font-weight: 500; line-height: 1.55; }
