/* 위키게임 — 원고지 */

:root {
  --paper: #f6f4ee;
  --paper-deep: #efece3;
  --ink: #1c2420;
  --ink-soft: #62695f;
  --ink-faint: #9aa196;
  --line: #d8d2c2;
  --line-soft: #e7e2d5;
  --card: #fffdf8;
  --race: #2a4b8d;
  --race-deep: #1c3564;
  --race-tint: #e9eef8;
  --chain: #0f6e5c;
  --chain-deep: #0a4f42;
  --chain-tint: #e6f2ee;
  --gold: #b8862f;
  --warn: #9a3b28;
  --warn-tint: #fbeae6;
  --accent: var(--ink);
  --accent-tint: var(--paper-deep);
  --cell: 46px;
  --measure: 68ch;
  --radius: 3px;
  --shadow-1: 0 1px 2px rgba(28, 36, 32, 0.06);
  --shadow-2: 0 4px 16px rgba(28, 36, 32, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(28,36,32,0.05) 1px, transparent 0);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: "IBM Plex Sans KR", system-ui, "Apple SD Gothic Neo",
               "Malgun Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

h1, h2, h3 {
  font-family: "Nanum Myeongjo", "Apple SD Gothic Neo", serif;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
}

h1 { font-size: 2.1rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

p { max-width: var(--measure); }

a { color: var(--race); text-decoration-color: rgba(42,75,141,0.35); }
a:hover { text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.wrap { max-width: 1020px; margin: 0 auto; padding: 0 20px; }

/* ---------------------------------------------------------- 머리·바닥글 */

.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky; top: 0; z-index: 20;
}
.masthead .wrap {
  display: flex; align-items: center; gap: 22px;
  min-height: 60px; flex-wrap: wrap;
}
.brand {
  font-family: "Nanum Myeongjo", serif;
  font-weight: 700; font-size: 1.2rem;
  color: var(--ink); text-decoration: none;
  letter-spacing: 0.1em;
  display: flex; align-items: center; gap: 8px;
}
.brand::before {
  content: "";
  width: 9px; height: 9px;
  background: linear-gradient(135deg, var(--race), var(--chain));
  display: inline-block; border-radius: 1px;
}
.masthead nav { display: flex; gap: 18px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.masthead nav a {
  color: var(--ink-soft); text-decoration: none; font-size: 0.92rem;
  padding: 4px 2px; border-bottom: 2px solid transparent;
}
.masthead nav a:hover { color: var(--ink); }
.masthead nav a[aria-current] { color: var(--ink); border-bottom-color: var(--ink); }
.who { font-size: 0.88rem; color: var(--ink-soft); }
.who b { font-weight: 600; color: var(--ink); }

footer.foot {
  margin-top: 72px; padding: 30px 0 56px;
  border-top: 1px solid var(--line);
  font-size: 0.85rem; color: var(--ink-soft);
}
footer.foot a { color: var(--ink-soft); }

/* ------------------------------------------------------------- 원고지 칸 */

.wongo { display: flex; flex-wrap: wrap; gap: 0; }
.wongo .cell {
  width: var(--cell); height: var(--cell);
  border: 1px solid var(--line);
  margin: -1px 0 0 -1px;
  display: grid; place-items: center;
  font-family: "Nanum Myeongjo", serif;
  font-size: calc(var(--cell) * 0.56);
  background: var(--card);
  position: relative;
}
.wongo .cell.empty { background: transparent; border-style: dashed; }
.wongo .cell.empty::after {
  content: ""; width: 3px; height: 3px; border-radius: 50%;
  background: var(--ink-faint); position: absolute;
}
.wongo .cell.mark { color: var(--accent); }
.wongo .cell.race { color: var(--race); }
.wongo .cell.chain { color: var(--chain); }

/* -------------------------------------------------------------- 첫 화면 */

.hero { padding: 60px 0 12px; }
.hero .wongo { --cell: 60px; margin-bottom: 26px; }
.hero p.lede {
  font-size: 1.06rem; max-width: 48ch; color: var(--ink-soft);
}

.games { display: grid; gap: 22px; grid-template-columns: 1fr 1fr; margin: 44px 0 0; }
.game {
  position: relative;
  border: 1px solid var(--line); background: var(--card);
  padding: 26px 26px 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition: box-shadow 160ms ease, transform 160ms ease, border-color 160ms ease;
  overflow: hidden;
}
.game::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: var(--accent);
}
.game:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); border-color: var(--line); }
.game h2 { color: var(--accent); margin-bottom: 6px; }
.game p.desc { color: var(--ink-soft); font-size: 0.94rem; margin: 0 0 16px; }
.game .meta { font-size: 0.83rem; color: var(--ink-faint); border-top: 1px solid var(--line-soft); padding-top: 12px; }
.game .links { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.game--race { --accent: var(--race); }
.game--chain { --accent: var(--chain); }

.note-card {
  border: 1px solid var(--line); background: var(--card);
  border-radius: var(--radius); padding: 18px 22px;
  margin-top: 22px; font-size: 0.93rem; color: var(--ink-soft);
  box-shadow: var(--shadow-1);
}

/* --------------------------------------------------------------- 공통부 */

.page { padding: 36px 0 0; }
.page-head { border-bottom: 1px solid var(--line); padding-bottom: 18px; margin-bottom: 30px; }
.page-head h1 { color: var(--accent); margin-bottom: 4px; }
.page-head .sub { color: var(--ink-soft); font-size: 0.94rem; margin: 0; }

.btn {
  font: inherit; font-size: 0.95rem;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  padding: 10px 22px; border-radius: var(--radius); cursor: pointer;
  text-decoration: none; display: inline-block;
  transition: filter 120ms ease, transform 120ms ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-tint); }
.btn.quiet { background: var(--card); color: var(--ink-soft); border-color: var(--line); }
.btn.quiet:hover { color: var(--ink); border-color: var(--ink-faint); }
.btn.danger { border-color: var(--warn); background: var(--warn); }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; transform: none; }

.notice {
  border: 1px solid var(--line-soft); border-left: 3px solid var(--accent);
  background: var(--card); border-radius: var(--radius);
  padding: 13px 18px; margin: 16px 0; max-width: var(--measure);
}
.notice.warn { border-left-color: var(--warn); background: var(--warn-tint); }
.notice p { margin: 0; }

table.board { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
table.board th, table.board td {
  text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-soft);
}
table.board th { font-weight: 600; color: var(--ink-soft); font-size: 0.85rem; }
table.board tr.me { background: var(--accent-tint); }
table.board tr:hover { background: var(--paper-deep); }
table.board td.rank { width: 3em; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
table.board td.num { font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.76rem; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink-soft); background: var(--card);
}
.badge.on { color: var(--chain-deep); border-color: var(--chain); background: var(--chain-tint); }
.badge.wait { color: var(--gold); border-color: var(--gold); background: #faf1de; }
.badge.playing { color: var(--race-deep); border-color: var(--race); background: var(--race-tint); }
.badge.done { color: var(--ink-faint); }

/* ---------------------------------------------------------- 위키 경주 */

.page--race { --accent: var(--race); }

.race-cards { display: grid; grid-template-columns: 1fr auto 1fr; gap: 20px; align-items: stretch; }
.race-card { border: 1px solid var(--line); background: var(--card); padding: 20px 22px; border-radius: var(--radius); box-shadow: var(--shadow-1); }
.race-card .role { font-size: 0.82rem; color: var(--ink-soft); margin: 0 0 2px; }
.race-card h2 { font-size: 1.25rem; margin: 0 0 8px; }
.race-card p.ex { font-size: 0.88rem; color: var(--ink-soft); margin: 0; }
.race-card img { float: right; margin: 0 0 8px 12px; max-width: 92px; border: 1px solid var(--line-soft); border-radius: 2px; }
.race-arrow { display: grid; place-items: center; color: var(--line); font-size: 1.6rem; }

.race-bar {
  position: sticky; top: 60px; z-index: 5;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--race);
  padding: 11px 18px; margin-bottom: 0; border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-1);
}
.race-bar .stat { font-size: 0.9rem; color: var(--ink-soft); }
.race-bar .stat b { font-size: 1.15rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.race-bar .goal { margin-left: auto; font-size: 0.9rem; }
.race-bar .goal b { color: var(--race); }

.breadcrumb { font-size: 0.85rem; color: var(--ink-soft); padding: 8px 0; word-break: keep-all; }
.breadcrumb .sep { color: var(--line); margin: 0 6px; }

#article {
  border: 1px solid var(--line); border-top: none; background: var(--card);
  padding: 26px 30px; max-height: 68vh; overflow-y: auto;
  border-radius: 0 0 var(--radius) var(--radius);
}
#article h1, #article h2, #article h3 { font-family: "Nanum Myeongjo", serif; }
#article table { max-width: 100%; }
#article img { max-width: 100%; height: auto; }
#article .wr-link { color: var(--race); text-decoration: none; border-bottom: 1px solid #b7c4de; cursor: pointer; }
#article .wr-link:hover { background: var(--race-tint); }
#article .wr-blocked { color: var(--ink-faint); cursor: not-allowed; text-decoration: none; pointer-events: none; }
#article .navbox, #article .metadata, #article .noprint { font-size: 0.88em; }

.result { border: 1px solid var(--race); background: var(--card); padding: 26px 30px; border-radius: var(--radius); box-shadow: var(--shadow-2); }
.result h2 { color: var(--race); }
.result .path { font-size: 0.92rem; word-break: keep-all; }

/* ---------------------------------------------------------- 끝말잇기 공통 */

.page--chain { --accent: var(--chain); }

.mode-picker { display: grid; gap: 20px; grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.mode-card {
  border: 1px solid var(--line); background: var(--card); border-radius: var(--radius);
  padding: 22px 24px; text-decoration: none; color: inherit;
  box-shadow: var(--shadow-1); transition: box-shadow 160ms ease, transform 160ms ease;
}
.mode-card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.mode-card h3 { margin-bottom: 6px; color: var(--chain); }
.mode-card p { color: var(--ink-soft); font-size: 0.9rem; margin: 0; }

.setup { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-end;
         border: 1px solid var(--line); background: var(--card); padding: 22px 24px;
         border-radius: var(--radius); box-shadow: var(--shadow-1); }
.setup fieldset { border: none; margin: 0; padding: 0; }
.setup legend { font-size: 0.82rem; color: var(--ink-soft); padding: 0 0 8px; }
.setup label { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; font-size: 0.94rem; }

.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type=range] {
  width: 180px; accent-color: var(--chain);
}
.slider-row .val {
  font-family: "Nanum Myeongjo", serif; font-size: 1.3rem; min-width: 3.4em;
  text-align: center; color: var(--chain);
}
.slider-row.disabled { opacity: 0.4; }

.turn-flag { font-size: 0.9rem; color: var(--ink-soft); margin: 26px 0 8px; }
.turn-flag b { color: var(--chain); }

.timer-ring {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.6em; height: 2.6em; border-radius: 50%;
  border: 3px solid var(--chain); font-variant-numeric: tabular-nums;
  font-family: "Nanum Myeongjo", serif; font-size: 1.1rem; color: var(--chain);
  margin-left: 10px; transition: border-color 200ms ease, color 200ms ease;
}
.timer-ring.low { border-color: var(--warn); color: var(--warn); }

.entry { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.entry input[type=text] {
  font: inherit; font-family: "Nanum Myeongjo", serif; font-size: 1.4rem;
  padding: 9px 16px; width: 260px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: var(--radius);
}
.entry input[type=text]:focus { border-color: var(--chain); }
.heads { font-size: 0.9rem; color: var(--ink-soft); }
.heads b { font-family: "Nanum Myeongjo", serif; font-size: 1.1rem; color: var(--chain); }

.chain-list { list-style: none; padding: 0; margin: 26px 0 0; }
.chain-list li {
  border-left: 3px solid var(--line); padding: 13px 0 13px 16px; margin-bottom: 4px;
  background: transparent;
}
.chain-list li.by-bot { border-left-color: var(--chain); background: var(--chain-tint); border-radius: 0 var(--radius) var(--radius) 0; }
.chain-list .w { font-family: "Nanum Myeongjo", serif; font-size: 1.3rem; }
.chain-list .by { font-size: 0.78rem; color: var(--ink-soft); margin-left: 8px; }
.chain-list .pos { font-size: 0.8rem; color: var(--ink-soft); margin-left: 6px; }
.chain-list .sense { font-size: 0.9rem; color: var(--ink-soft); margin: 4px 0 0; max-width: var(--measure); }
.chain-list a.src { font-size: 0.8rem; color: var(--ink-soft); }

.msg { margin: 14px 0; padding: 13px 18px; background: var(--card);
       border: 1px solid var(--line-soft); border-left: 3px solid var(--warn);
       border-radius: var(--radius); max-width: var(--measure); }
.msg.good { border-left-color: var(--chain); }
.msg.info { border-left-color: var(--race); }
.msg p { margin: 0; }

.reveal { animation: rise 260ms ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .reveal { animation: none; } }

p.hint { font-size: 0.86rem; color: var(--ink-soft); margin: 10px 0 0; }

/* --------------------------------------------------------------- 방 목록 */

.room-list { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.room-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  border: 1px solid var(--line); background: var(--card); border-radius: var(--radius);
  padding: 14px 20px; box-shadow: var(--shadow-1);
}
.room-row .code {
  font-family: "Nanum Myeongjo", serif; font-size: 1.3rem; letter-spacing: 0.08em;
  color: var(--chain); min-width: 5.5ch;
}
.room-row .info { color: var(--ink-soft); font-size: 0.88rem; }
.room-row .info b { color: var(--ink); font-weight: 500; }
.room-row .grow { flex: 1 1 auto; }

.create-box {
  border: 1px solid var(--line); background: var(--card); border-radius: var(--radius);
  padding: 22px 24px; box-shadow: var(--shadow-1); margin-bottom: 32px;
}

/* ----------------------------------------------------------- 방 안 화면 */

.room-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.room-head .code-big {
  font-family: "Nanum Myeongjo", serif; font-size: 2rem; letter-spacing: 0.1em; color: var(--chain);
}
.room-cols { display: grid; grid-template-columns: 1fr 260px; gap: 24px; align-items: start; }

.player-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line);
              background: var(--card); border-radius: var(--radius); overflow: hidden; }
.player-list li {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft); font-size: 0.92rem;
}
.player-list li:last-child { border-bottom: none; }
.player-list li.turn { background: var(--chain-tint); font-weight: 600; }
.player-list li.out { color: var(--ink-faint); text-decoration: line-through; }
.player-list .rank { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--gold); font-weight: 600; }
.player-list .host-tag { font-size: 0.72rem; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; }

.ranking { list-style: none; margin: 0; padding: 0; }
.ranking li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}
.ranking li:first-child { background: #fbf6e8; }
.ranking .n {
  font-family: "Nanum Myeongjo", serif; font-size: 1.2rem; color: var(--gold);
  min-width: 2ch;
}

@media (max-width: 760px) {
  .room-cols { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ 반응 */

@media (max-width: 720px) {
  .games { grid-template-columns: 1fr; }
  .mode-picker { grid-template-columns: 1fr; }
  .race-cards { grid-template-columns: 1fr; }
  .race-arrow { transform: rotate(90deg); }
  .hero .wongo { --cell: 48px; }
  #article { padding: 18px 16px; max-height: none; }
  .entry input[type=text] { width: 100%; }
  .race-bar { top: 0; }
}

/* ------------------------------------------------------------ 버블팝·타자 */

.page--arcade { --accent: #6b3fa0; }
:root { --arcade: #6b3fa0; --arcade-tint: #f0eaf8; }

.arcade-bar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  border: 1px solid var(--line); background: var(--card);
  border-left: 3px solid var(--accent);
  padding: 12px 18px; border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.arcade-bar .stat { font-size: 0.88rem; color: var(--ink-soft); }
.arcade-bar .stat b {
  font-family: "Nanum Myeongjo", serif; font-size: 1.3rem; color: var(--ink);
  font-variant-numeric: tabular-nums; margin-left: 4px;
}
.arcade-bar .target { margin-left: auto; font-size: 0.95rem; }
.arcade-bar .target b {
  font-family: "Nanum Myeongjo", serif; font-size: 1.4rem; color: var(--accent);
}

.stage {
  position: relative; overflow: hidden;
  height: 440px; margin-top: 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card);
  background-image: radial-gradient(circle at 1px 1px, rgba(28,36,32,0.045) 1px, transparent 0);
  background-size: 26px 26px;
  touch-action: manipulation;
}

.bubble {
  position: absolute; transform: translate(-50%, -50%);
  display: grid; place-items: center; text-align: center;
  padding: 0 12px; border-radius: 50%;
  border: 1.5px solid var(--arcade); background: var(--arcade-tint);
  color: #3f2463; cursor: pointer; user-select: none;
  font-size: 0.82rem; line-height: 1.25; word-break: keep-all;
  transition: transform 90ms ease;
}
.bubble:hover { transform: translate(-50%, -50%) scale(1.06); }
.bubble.pop-ok, .bubble.pop-no {
  pointer-events: none;
  animation: pop 260ms ease-out forwards;
}
.bubble.pop-ok { border-color: var(--chain); background: var(--chain-tint); }
.bubble.pop-no { border-color: var(--warn); background: var(--warn-tint); }
@keyframes pop {
  to { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

.floater {
  position: absolute; pointer-events: none;
  font-family: "Nanum Myeongjo", serif; font-size: 1.1rem; font-weight: 700;
  animation: floatup 700ms ease-out forwards;
}
.floater.plus { color: var(--chain); }
.floater.minus { color: var(--warn); }
@keyframes floatup {
  to { transform: translate(-50%, -60px); opacity: 0; }
}

.falling {
  position: absolute; left: 50%; transform: translateX(-50%);
  max-width: 92%; text-align: center;
  padding: 8px 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--paper-deep);
  font-family: "Nanum Myeongjo", serif; font-size: 1.05rem;
  word-break: keep-all; line-height: 1.5;
}
.falling.danger { border-color: var(--warn); background: var(--warn-tint); }
.falling.cleared { animation: pop 220ms ease-out forwards; }

.type-input {
  width: 100%; margin-top: 14px;
  font: inherit; font-family: "Nanum Myeongjo", serif; font-size: 1.25rem;
  padding: 12px 16px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: var(--radius);
}
.type-input:focus { border-color: var(--arcade); }

.lives { letter-spacing: 3px; color: var(--warn); font-size: 1.1rem; }

.mystats {
  display: flex; gap: 26px; flex-wrap: wrap; align-items: baseline;
  border: 1px solid var(--line); background: var(--card);
  border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow-1);
}
.mystats .big {
  font-family: "Nanum Myeongjo", serif; font-size: 2rem; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.mystats .lbl { font-size: 0.82rem; color: var(--ink-soft); display: block; }

.history { list-style: none; margin: 16px 0 0; padding: 0; font-size: 0.9rem; }
.history li {
  display: flex; gap: 14px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--line-soft);
}
.history .s { font-variant-numeric: tabular-nums; font-weight: 500; min-width: 4em; }
.history .when { color: var(--ink-faint); margin-left: auto; font-size: 0.82rem; }
.history .meta { color: var(--ink-soft); font-size: 0.85rem; }

.game--arcade { --accent: var(--arcade); }

/* 키보드 사용자를 위한 본문 건너뛰기 링크 */
.skip {
  position: absolute; left: -9999px;
  background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: var(--radius); z-index: 100;
}
.skip:focus { left: 12px; top: 12px; }
