/* 유의어·반의어 퀴즈가 함께 쓰는 모양. 끝말잇기 화면을 그대로 따르고,
   입력칸 대신 무대 아래에 보기 네 개를 둔다. */
:root {
  --night: #131a36;
  --night-2: #1c2750;
  --sun: #d6432e;
  --gold: #cf9f3c;
  --gold-hi: #f0d07a;
  --ink: #f2eee3;
  --muted: #a7aec8;
  --paper: #f5efdf;
  --paper-ink: #1b2140;
  --good: #6fcf97;
  --bad: #ff7a6b;
  --line: rgba(242, 238, 227, 0.14);
  --font-display: "Song Myung", "Nanum Myeongjo", "Batang", serif;
  --font-body: "Gowun Dodum", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}
.app {
  min-height: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: max(14px, env(safe-area-inset-top, 0px));
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
header { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; }
h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(24px, 6vw, 34px); letter-spacing: 0.02em; text-wrap: balance; }
h1 .q { color: var(--gold-hi); }
.home { font-size: 12px; color: var(--muted); text-decoration: none; }
.home:hover { color: var(--ink); }
.mode { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.mode b { color: var(--gold-hi); font-weight: 400; }
.head-right { display: flex; align-items: center; gap: 10px; }
.sound-btn {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 400;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.sound-btn:hover { background: var(--night-2); color: var(--ink); }
.sound-btn[aria-pressed="false"] { color: var(--gold-hi); border-color: var(--gold-hi); }
/* 화면 언어 바꾸기(i18n.js가 단추를 채운다) */
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang-switch button { padding: 3px 9px; font-size: 12px; font-weight: 400; background: transparent; color: var(--muted); border: 0; border-radius: 0; }
.lang-switch button:hover { background: var(--night-2); color: var(--ink); }
.lang-switch button[aria-pressed="true"] { background: var(--gold); color: var(--paper-ink); }
.head-right { flex-wrap: wrap; }

.hud { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.hud > div { border-top: 1px solid var(--line); padding-top: 6px; min-width: 0; }
.hud .k { display: block; font-size: 11px; color: var(--muted); letter-spacing: 0.08em; }
.hud .v { font-family: var(--font-display); font-size: 22px; font-variant-numeric: tabular-nums; }
.hud .vs { font-size: 0.7em; color: var(--muted); }
.hearts { color: var(--sun); letter-spacing: 2px; }
.hearts .lost { color: rgba(242, 238, 227, 0.18); }

/* 무대: 광화문광장 밤 배경(1214×1295). 좌표는 그림 속 말풍선·입력판 자리를 백분율로 잰 값이다. */
.stage {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  aspect-ratio: 1214 / 1295;
  border-radius: 6px;
  overflow: hidden;
  background: var(--night-2) url("../assets/bg.webp") center / 100% 100% no-repeat;
  container-type: inline-size;
  isolation: isolate;
}
.bubble {
  position: absolute;
  left: 21%;
  top: 11.4%;
  width: 59.3%;
  height: 9.8%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--paper-ink);
  text-align: center;
  padding: 0 4%;
}
.bubble.pop { animation: pop 0.35s ease-out; }
@keyframes pop { 0% { transform: scale(0.96); opacity: 0.6; } 100% { transform: none; opacity: 1; } }
.cho {
  font-family: "Gowun Batang", var(--font-display);
  font-weight: 700;
  font-size: 6.4cqw;
  line-height: 1.05;
  letter-spacing: 0.12em;
  margin-right: -0.12em;
}
.say { font-size: max(11px, 2.9cqw); line-height: 1.25; max-width: 100%; overflow-wrap: anywhere; }

.geu {
  position: absolute;
  right: 2%;
  bottom: 17%;
  height: 24%;
  aspect-ratio: 260 / 230;
  background: url("../assets/geu.webp") 0 0 / 900% 300% no-repeat;
  pointer-events: none;
}
.geu-say {
  position: absolute;
  right: 3%;
  bottom: 41.5%;
  max-width: 44%;
  padding: 0.45em 0.9em;
  border-radius: 14px;
  background: var(--paper);
  color: var(--paper-ink);
  font-size: max(12px, 3.2cqw);
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}
.geu-say::after {
  content: "";
  position: absolute;
  right: 22%;
  bottom: -9px;
  border: 9px solid transparent;
  border-bottom: 0;
  border-top-color: var(--paper);
}
.geu-say strong { font-family: var(--font-display); font-weight: 400; font-size: 1.35em; }
.geu-say.pop { animation: pop 0.3s ease-out; }
.turn-tag {
  position: absolute;
  left: 4%;
  top: 76.5%;
  font-size: max(11px, 2.6cqw);
  padding: 0.2em 0.8em;
  border-radius: 999px;
  background: rgba(19, 26, 54, 0.8);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.turn-tag.me { border-color: var(--gold-hi); color: var(--gold-hi); }
.timer {
  position: absolute;
  left: 3.3%;
  top: 82.2%;
  width: 76.4%;
  height: 1.1%;
  border-radius: 4px;
  background: rgba(242, 238, 227, 0.18);
  overflow: hidden;
}
.timer i { display: block; height: 100%; width: 100%; background: var(--gold-hi); transform-origin: left center; }
.timer.hurry i { background: var(--sun); }
/* 그림 속 입력판에는 뜻풀이를 띄운다 */
.hint {
  position: absolute;
  left: 4.4%;
  top: 85.2%;
  width: 74.2%;
  height: 7.4%;
  display: flex;
  align-items: center;
  padding: 0 3%;
  font-size: max(11px, 2.7cqw);
  line-height: 1.25;
  color: var(--ink);
  overflow: hidden;
}
.hint span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* 보기 네 개 */
.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.choices button {
  position: relative;
  min-height: 56px;
  padding: 8px 10px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  background: var(--night-2);
  color: var(--ink);
  border: 1px solid var(--line);
}
.choices button:hover:not(:disabled) { background: #26346a; border-color: var(--gold-hi); }
.choices button:disabled { cursor: default; }
.choices button .no-k { position: absolute; left: 8px; top: 4px; font-family: var(--font-body); font-size: 11px; color: var(--muted); }
.choices button.ok { background: rgba(111, 207, 151, 0.22); border-color: var(--good); color: var(--good); }
.choices button.no { background: rgba(255, 122, 107, 0.2); border-color: var(--bad); color: var(--bad); }
.choices button.rival::after {
  content: attr(data-rival);
  position: absolute;
  right: 8px;
  top: 4px;
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--gold-hi);
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 6px;
  border: 0;
  padding: 10px 18px;
  background: var(--gold);
  color: var(--paper-ink);
  font-weight: 700;
}
button:hover { background: var(--gold-hi); }
button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.shake { animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.msg { min-height: 1.5em; font-size: 14px; color: var(--muted); }
.msg.good { color: var(--good); }
.msg.bad { color: var(--bad); }

.log { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.log li {
  display: grid;
  grid-template-columns: 1.6em minmax(0, auto) minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}
.log .mark { font-size: 14px; }
.log .mark.ok { color: var(--good); }
.log .mark.no { color: var(--bad); }
.log .w { font-family: var(--font-display); font-size: 18px; }
.log .def { font-size: 13px; color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.log-head { font-size: 12px; color: var(--muted); letter-spacing: 0.08em; margin: 4px 0 0; }

footer { font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
footer a { color: inherit; }
.ios-hint { margin: 0 0 6px; color: var(--gold-hi); }
.other-game { margin: 0 0 6px; }
.other-game a { color: var(--gold-hi); }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  background: rgba(19, 26, 54, 0.9);
  overflow-y: auto;
}
.overlay > :first-child { margin-top: auto; }
.overlay > :last-child { margin-bottom: auto; }
.overlay h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(24px, 7cqw, 38px); }
.overlay p { margin: 0; max-width: 34em; color: var(--muted); text-wrap: balance; }
.overlay .quote { font-family: var(--font-display); color: var(--ink); font-size: 16px; }
.overlay .quote cite { display: block; font-style: normal; font-family: var(--font-body); font-size: 12px; color: var(--muted); margin-top: 2px; }
.rules { font-size: 13px; }
.overlay .credit { font-size: 12px; line-height: 1.6; color: var(--gold-hi); }
.overlay .credit a { color: inherit; text-underline-offset: 2px; }
.overlay .credit .credit-note { color: var(--muted); }
.ov-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.ov-buttons .sub { background: transparent; color: var(--gold-hi); border: 1px solid var(--gold-hi); font-weight: 400; }
.ov-buttons .sub:hover { background: rgba(240, 208, 122, 0.12); }
.rank { width: min(100%, 340px); display: flex; flex-direction: column; gap: 8px; }
.rank h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 20px; color: var(--gold-hi); }
.rank ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.rank li {
  display: grid;
  grid-template-columns: 2em minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.rank li .n { color: var(--muted); }
.rank li .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank li .who small { color: var(--muted); font-size: 11px; margin-left: 4px; }
.rank li .pt { font-family: var(--font-display); }
.rank li:nth-child(-n+3) .n { color: var(--gold-hi); }
.rank li.me { background: rgba(240, 208, 122, 0.18); outline: 1px solid var(--gold-hi); }
.rank .empty { color: var(--muted); font-size: 13px; text-align: center; }
.rank form { display: flex; gap: 6px; }
.rank form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--gold-hi);
  background: var(--night-2);
  color: var(--ink);
}
.rank form button { padding: 8px 14px; }
.rank .rmsg { font-size: 12px; min-height: 1.2em; }
.rank .rmsg.bad { color: var(--bad); }
.rank .rmsg.good { color: var(--good); }

@media (prefers-reduced-motion: reduce) {
  .bubble.pop, .geu-say.pop, .shake { animation: none; }
}
@media (max-width: 420px) {
  .hud .v { font-size: 18px; }
  .choices button { font-size: 20px; min-height: 52px; }
}
