@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');
@import url('https://fonts.googleapis.com/css2?family=Gowun+Batang:wght@400;700&display=swap');
/* 오징어 타자 — 0단계 기준: 색·글꼴 */
:root {
  --squid: #f6aa9c;        /* 오징어 몸 */
  --squid-deep: #e98a7a;
  --line: #6e3b26;         /* 갈색 외곽선 */
  --cream: #fdebc4;        /* 말풍선·강조 크림색 */
  --kb-bg: #fdebc4;        /* 자판 배경 */
  --key-bg: #fffaf0;       /* 키캡 */
  --key-ink: #3a2418;      /* 키캡 글자 */
  --ink-faint: #b9a596;    /* 아직 안 친 글자 */
  --bg-image: linear-gradient(transparent, transparent);
  --char-filter: none;
  --bg: #fff8ef;
  --card: #ffffff;
  --ink: #3a2418;
  --ink-soft: #8a6a58;
  --ok: #2f9e6a;
  --bad: #e0503c;
  /* 손가락 색 = 오징어 다리 색 (양손 같은 손가락은 같은 색) */
  --f-pinky: #9cc8ff;
  --f-ring: #c6b0ff;
  --f-middle: #8fdcb3;
  --f-index: #ffc978;
  --f-thumb: #e6d6cc;
  --radius: 18px;
  --font-body: 'Pretendard Variable', Pretendard, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --font-fun: var(--font-body); /* 제목용: 프리텐다드 굵게 */
  --font-text: 'Gowun Batang', 'Batang', serif; /* 설명·서술용 */
  --type-size: 56px;
}
.mode-senior {
  --bg: #ffffff;
  --ink: #111111;
  --ink-soft: #444444;
  --line: #3b2014;
  --key-ink: #111111;
  --ink-faint: #777777;
  --type-size: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg-image), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.5;
  min-height: 100vh;
}
.mode-senior body, body.mode-senior { font-size: 22px; }
button { font: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

/* ── 첫 화면 ───────────────────────── */
.home {
  max-width: 1040px;
  margin: 0 auto;
  padding: 40px 16px 64px;
  text-align: center;
}
.home__hero { width: 220px; margin: 0 auto 8px; }
.home__logo { display: block; width: auto; height: 160px; margin: 0 auto 14px; }
@media (max-width: 640px) { .home__logo { height: 120px; } }
.home__title {
  font-family: var(--font-fun);
  font-size: 56px;
  font-weight: 800;
  margin: 0;
  color: var(--line);
  letter-spacing: -1px;
}
.home__sub { margin: 8px 0 36px; color: var(--ink-soft); font-size: 20px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.mode-card {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 32px 24px;
  border: 3px solid var(--line);
  border-radius: 28px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 6px 0 var(--line);
  transition: transform .12s, box-shadow .12s;
}
.mode-card:hover, .mode-card:focus-visible { transform: translateY(-3px); box-shadow: 0 9px 0 var(--line); outline: none; }
.mode-card:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--line); }
.mode-card--kid { background: #ffe9e3; }
.mode-card--senior { background: #fff6dc; }
.mode-card__img { width: 160px; height: 160px; object-fit: contain; }
.mode-card__name { font-family: var(--font-fun); font-weight: 800; font-size: 40px; color: var(--line); line-height: 1.2; }
.mode-card--senior .mode-card__name { font-family: var(--font-body); font-weight: 800; }
.mode-card__desc { font-size: 19px; color: var(--ink-soft); margin: 0; }
.mode-card--senior .mode-card__desc { font-size: 22px; color: #333; }
.home__note { margin-top: 28px; color: var(--ink-soft); font-size: 15px; }

/* ── 연습 화면 ─────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1100px; margin: 0 auto; padding: 16px;
}
.topbar__logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--line); font-family: var(--font-fun); font-weight: 800; font-size: 26px; }
.topbar__logo img { width: auto; height: 56px; }
.topbar__right { display: flex; gap: 8px; align-items: center; }
.topbar__left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar__mode { font-family: var(--font-body); font-weight: 800; font-size: 24px; color: var(--line); white-space: nowrap; }
.topbar__info { color: var(--ink-soft); font-weight: 700; }
.btn { font-family: var(--font-body); }
.btn {
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 12px; padding: 8px 16px; font-weight: 700;
}
.btn:hover { background: var(--cream); }
.btn--big { font-size: 24px; padding: 14px 32px; border-width: 3px; border-radius: 16px; box-shadow: 0 4px 0 var(--line); }
.btn--primary { background: var(--squid); }
.btn--primary:hover { background: var(--squid-deep); }
/* 테마 버튼: 눈에 띄게 — 파스텔 무지개 + 팔레트 아이콘 */
.btn--theme { display: inline-flex; align-items: center; gap: 6px; color: var(--line); font-weight: 800;
  background: linear-gradient(120deg, #ffc2b6, #ffe08a 35%, #b8eccf 65%, #b9d8ff); box-shadow: 0 3px 0 var(--line); }
.btn--theme:hover { background: linear-gradient(120deg, #ffb0a1, #ffd765 35%, #9fe4be 65%, #a3caff); transform: translateY(-1px); }
.btn--theme svg { width: 22px; height: 22px; flex: none; }

/* 진행줄·글자창·자판 판의 가로를 자판 폭에 맞춤 (자판이 폭을 정하고, 글자창은 폭에 영향 안 줌) */
.practice { width: fit-content; max-width: 1100px; margin: 0 auto; padding: 0 16px 40px; }
.practice > .stage { contain: inline-size; }
.progress { height: 18px; background: color-mix(in srgb, var(--line) 10%, var(--card)); border-radius: 99px; overflow: hidden; border: 2px solid var(--line); }
.progress__bar { height: 100%; width: 0; background: var(--bar, var(--squid)); border-radius: 99px; transition: width .3s; }
.stage { margin: 14px 0; }
.buddy { position: relative; }
.buddy img { width: 150px; height: 150px; object-fit: contain; transition: transform .15s; }
.buddy.is-bad img { animation: wobble .3s; }
.buddy.is-good img { animation: hop .3s; }
@keyframes wobble { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes hop { 50% { transform: translateY(-8px); } }

.board {
  background: var(--card); border: 3px solid var(--line); border-radius: 28px;
  padding: 16px 28px 16px 16px; min-height: 180px;
  display: grid; grid-template-columns: auto 2px minmax(0, 1fr); gap: 0 22px; align-items: center;
}
.bubble {
  display: inline-block; align-self: flex-start;
  background: var(--cream); border: 2px solid var(--line); border-radius: 14px;
  padding: 6px 14px; font-size: 18px; margin-bottom: 16px; min-height: 40px;
}
.mode-senior .bubble { font-size: 24px; }
.target {
  font-size: var(--type-size); font-weight: 700; line-height: 1.35;
  letter-spacing: 2px; word-break: keep-all; min-height: 1.35em;
}
.target .typed { color: var(--ok); }
.target .current {
  color: #3a2418; background: #ffe3dc; border-radius: 8px;
  box-shadow: inset 0 -5px 0 var(--squid-deep);
}
.target .current.is-space { padding: 0 .25em; }
.target .rest { color: var(--ink-faint); }
.board.is-bad .target .current { background: #ffd0c8; animation: shake .25s; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.next-line { margin-top: 12px; color: var(--ink-soft); font-size: 20px; min-height: 30px; }

.board__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; }
.board__head .bubble { margin-bottom: 0; }
.stats { display: flex; gap: 20px; justify-content: flex-end; color: var(--ink-soft); font-size: 18px; white-space: nowrap; }
.stats b { color: var(--ink); font-size: 22px; }
.mode-senior .stats { font-size: 22px; }

/* 화면 자판 */
.kb {
  background: var(--kb-bg); border: 3px solid var(--line); border-radius: 24px;
  padding: 16px; display: flex; flex-direction: column; gap: 8px; align-items: center;
  user-select: none;
  --k0: clamp(36px, calc((100vw - 140px) / 14.6), 60px);
  --k: calc(var(--k0) - var(--k-cut, 0px)); /* 판 그림 스킨은 판 여백만큼 키를 줄여 바깥 폭을 기본과 같게 */
}
.kb__row { display: flex; gap: 8px; }
.kb__row--2 { margin-left: calc(var(--k) * .45); }
.kb__row--3 { margin-left: 0; }
.key {
  --f: var(--f-thumb);
  width: var(--k); height: var(--k); border-radius: calc(var(--k) * .19);
  border: 2px solid var(--line); background: var(--key-bg);
  box-shadow: inset 0 -6px 0 var(--f);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  font-size: calc(var(--k) * .38); font-weight: 700; color: var(--key-ink); position: relative; flex: none;
  transition: transform .08s, background .08s;
}
.key small { font-size: 12px; color: var(--key-ink); opacity: .6; position: absolute; top: 3px; left: 7px; font-weight: 600; }
.key--wide { width: calc(var(--k) * 1.55); font-size: calc(var(--k) * .25); }
.key--space { width: calc(var(--k) * 6); font-size: calc(var(--k) * .25); }
.key.homekey::after { content: ''; position: absolute; bottom: 12px; width: 14px; height: 3px; border-radius: 2px; background: var(--line); }
.key[data-f="pinky"] { --f: var(--f-pinky); }
.key[data-f="ring"] { --f: var(--f-ring); }
.key[data-f="middle"] { --f: var(--f-middle); }
.key[data-f="index"] { --f: var(--f-index); }
.key.is-next { background: var(--f); color: #3a2418; transform: translateY(-3px); box-shadow: 0 0 0 4px var(--line); }
.key.is-down { transform: translateY(2px); }
.key.is-wrong { background: #ffb3a6; }
.mode-senior .kb { --k0: clamp(40px, calc((100vw - 140px) / 14.6), 66px); }

.legend { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 8px; font-size: 15px; color: var(--ink-soft); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--line); vertical-align: -2px; margin-right: 4px; }
.mode-senior .legend { font-size: 19px; }

/* 결과 */
.result[hidden] { display: none; }
.result {
  position: fixed; inset: 0; background: rgba(58, 36, 24, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10;
}
.result__card {
  background: var(--card); border: 3px solid var(--line); border-radius: 28px;
  padding: 32px; width: min(600px, 100%); text-align: center;
}
.result__card img { width: 160px; height: 160px; object-fit: contain; margin: 0 auto; }
.result__title { font-family: var(--font-fun); font-size: 40px; color: var(--line); margin: 8px 0; font-weight: 800; }
.mode-senior .result__title { font-family: var(--font-body); font-weight: 800; }
.result__stars { font-size: 44px; letter-spacing: 6px; color: #f3b520; min-height: 1em; }
.result__nums { display: flex; justify-content: center; gap: 32px; margin: 16px 0; }
.result__nums div { font-size: 16px; color: var(--ink-soft); }
.result__nums b { display: block; font-size: 32px; color: var(--ink); }
.result__weak { font-size: 18px; margin-bottom: 20px; min-height: 1.5em; }
.result__btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.result__btns .btn--big { padding: 12px 22px; font-size: 21px; }

.no-keyboard { display: none; }

@media (max-width: 860px) {
  .buddy, .board__div { display: none; }
  .board { grid-template-columns: 1fr; }
  .kb { transform-origin: top center; }
}
@media (max-width: 640px) {
  .modes { grid-template-columns: 1fr; }
  .home__title { font-size: 42px; }
  .kb { display: none; }
  .legend { display: none; }
  .no-keyboard { display: block; margin-top: 16px; padding: 12px; border: 2px dashed var(--line); border-radius: 12px; text-align: center; }
}

/* ── 희미한 손 안내 ─────────────────── */
.kb { position: relative; }
.hands { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .5s; z-index: 2; }
.hands.is-on { opacity: 1; }            /* 손 그림 자체가 약 50% 반투명 */
.hands.is-gone { opacity: 0; transition: opacity 1.3s ease-out; }
.hands__img { position: absolute; max-width: none; }
.hands__dot { position: absolute; border-radius: 50%; border: 2px solid rgba(255,255,255,.9); box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.bubble__tip { display: block; font-weight: 700; color: var(--line); margin-bottom: 2px; }

/* ── 연습 고르기 ───────────────────── */
.learn { max-width: 1100px; margin: 0 auto; padding: 8px 16px 48px; }
.learn__free {
  display: grid; grid-template-columns: 120px 1fr auto; gap: 24px; align-items: center;
  background: var(--cream); border: 3px solid var(--line); border-radius: 28px; padding: 20px 28px;
}
.learn__free img { width: 120px; height: 120px; object-fit: contain; }
.learn__free h2 { margin: 0; font-family: var(--font-fun); font-weight: 800; font-size: 36px; color: var(--line); }
.mode-senior .learn__free h2 { font-family: var(--font-body); font-weight: 800; }
.learn__free p { margin: 4px 0 0; color: var(--ink-soft); }
.learn__h { font-family: var(--font-fun); font-weight: 800; font-size: 32px; color: var(--line); margin: 36px 0 0; }
.mode-senior .learn__h { font-family: var(--font-body); font-weight: 800; }
.learn__p { margin: 4px 0 16px; color: var(--ink-soft); }
.stages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stage-card {
  display: grid; grid-template-columns: 52px 1fr; grid-template-rows: auto auto auto; column-gap: 14px;
  padding: 18px 20px; border: 3px solid var(--line); border-radius: 22px; background: var(--card);
  color: var(--ink); text-decoration: none; box-shadow: 0 5px 0 var(--line); transition: transform .12s, box-shadow .12s;
}
.stage-card:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--line); }
.stage-card__no {
  grid-row: 1 / 4; width: 52px; height: 52px; border-radius: 50%; background: var(--cream);
  border: 3px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-family: var(--font-fun); font-weight: 800; font-size: 26px; color: var(--line);
}
.stage-card__name { font-weight: 800; font-size: 20px; line-height: 1.3; }
.stage-card__keys { font-size: 22px; letter-spacing: 2px; color: var(--ink-soft); font-weight: 700; }
.stage-card__badge { font-size: 14px; font-weight: 800; color: var(--squid-deep); min-height: 1.4em; }
.stage-card.is-done .stage-card__no { background: var(--f-middle); }
.stage-card.is-done .stage-card__badge { color: var(--ok); }
.stage-card.is-next { background: var(--cream); }
.stage-card.is-next .stage-card__no { background: var(--squid); }
.mode-senior .stage-card__name { font-size: 24px; }
.mode-senior .stage-card__keys { font-size: 26px; }
.mode-senior .stage-card__badge { font-size: 18px; }

/* ── 광고 자리 (keybr 배치: 위 가로 · 왼쪽 세로 · 아래 고정) ── */
.ad { display: flex; justify-content: center; }
.ad--top { margin: 0 auto 12px; min-height: 90px; }
.ad--left { display: none; }
.ad--bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(255, 255, 255, .96); border-top: 1px solid #e5d6c8; padding: 6px 0;
}
body.has-anchor { padding-bottom: 104px; }
.ad__ph {
  display: flex; align-items: center; justify-content: center; max-width: calc(100vw - 32px);
  border: 2px dashed #d8c3b0; border-radius: 8px; color: #b39a85; font-size: 14px; background: #fbf4ec;
}
.ad__close {
  position: absolute; right: 12px; top: -14px; width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid #ccc; background: #fff; color: #666; font-size: 18px; line-height: 1;
}
/* 옆 광고: 1280px 이상이면 왼쪽에 고정. 1500px 미만에서는 본문을 오른쪽으로 비켜 줌 */
@media (min-width: 1280px) {
  .ad--left { display: block; position: fixed; left: 16px; top: 88px; }
}
@media (min-width: 1280px) and (max-width: 1499px) {
  .topbar, .practice, .learn { margin-left: 200px; margin-right: 16px; max-width: calc(100vw - 232px); }
}
@media (max-width: 860px) {
  .stages { grid-template-columns: 1fr 1fr; }
  .learn__free { grid-template-columns: 1fr; text-align: center; }
  .learn__free img { margin: 0 auto; }
}
@media (max-width: 560px) { .stages { grid-template-columns: 1fr; } }

/* 낮은 화면(노트북 768px 등): 아래 광고와 겹치지 않게 위쪽을 줄임 */
@media (max-height: 820px) {
  .topbar { padding-top: 8px; padding-bottom: 8px; }
  .topbar__logo img { height: 46px; }
  .stage { margin: 8px 0; }
  .board { min-height: 150px; padding: 14px 24px; }
  .buddy img { width: 120px; height: 120px; }
  .next-line { margin-top: 4px; }
  .kb, .mode-senior .kb { --k0: clamp(36px, calc((100vw - 140px) / 14.6), 56px); }
}

/* ── 스킨 ─────────────────────────── */
img[data-char] { filter: var(--char-filter); }
.skins-pop {
  position: fixed; right: 16px; top: 64px; z-index: 30; width: min(440px, calc(100vw - 32px));
  background: var(--card); color: var(--ink); border: 3px solid var(--line); border-radius: 20px;
  padding: 14px 16px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.18);
}
.skins-pop__title { margin: 0 0 10px; font-weight: 800; }
.skins-pop__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.skin-chip { border: 2px solid transparent; background: none; padding: 4px; border-radius: 14px; color: var(--ink); }
.skin-chip:hover { border-color: var(--squid); }
.skin-chip.is-on { border-color: var(--line); }
.skin-chip__view {
  display: block; position: relative; height: 84px; border-radius: 10px; overflow: hidden;
  background: var(--c-img), var(--c-bg); border: 2px solid var(--c-line);
}
.skin-chip__view.has-thumb { border-color: var(--c-line); }
.skin-chip__thumb { width: 100%; height: 100%; object-fit: cover; }
.skin-chip__view img:not(.skin-chip__thumb) { position: absolute; left: 50%; top: 4px; width: 50px; transform: translateX(-50%); }
.skin-chip__view i {
  position: absolute; left: 10px; right: 10px; bottom: 6px; height: 22px; border-radius: 6px;
  background: var(--c-kb); border: 2px solid var(--c-line);
  box-shadow: inset 0 0 0 4px var(--c-kb), inset 0 0 0 9px var(--c-key);
}
.skin-chip__name { display: block; font-size: 14px; font-weight: 700; margin-top: 4px; }

/* ── 목록: 더보기 카드 ─────────────── */
.learn__more { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 16px; }
.more-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 3px solid var(--line); border-radius: 20px;
  background: var(--card); color: var(--ink); text-decoration: none; box-shadow: 0 4px 0 var(--line);
}
.more-card:hover { transform: translateY(-2px); }
.more-card img { width: 64px; height: 64px; object-fit: contain; flex: none; }
.more-card b { display: block; font-size: 20px; }
.more-card small { color: var(--ink-soft); font-size: 15px; }
.mode-senior .more-card b { font-size: 24px; }
.mode-senior .more-card small { font-size: 18px; }

/* ── 내 기록 ───────────────────────── */
.panel { background: var(--card); border: 3px solid var(--line); border-radius: 24px; padding: 20px 24px; margin-top: 16px; }
.panel h3 { margin: 0 0 12px; }
.kb--heat { border: 0; padding: 4px; background: none; }
.key.heat { --f: transparent; background: color-mix(in srgb, #e0503c calc(var(--t) * 85%), var(--key-solid, var(--key-bg))); flex-direction: column; }
.heat__acc { position: static !important; font-size: 11px !important; opacity: .8; }
.heat-legend { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 14px; color: var(--ink-soft); margin-top: 8px; }
.heat-legend i { width: 140px; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--key-bg), #e0503c); border: 1px solid var(--line); }
.rec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.weak-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; min-height: 48px; }
.weak-chip { border: 2px solid var(--line); border-radius: 12px; padding: 4px 12px; background: var(--cream); font-size: 14px; }
.weak-chip b { font-size: 26px; margin-right: 6px; }
.chart { width: 100%; height: 160px; background: var(--cream); border-radius: 12px; }
.chart__l1, .chart__l2 { fill: none; stroke-width: 3; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart__l1 { stroke: var(--ok); }
.chart__l2 { stroke: var(--squid-deep); }
.chart__empty { fill: var(--ink-soft); font-size: 14px; }
.chart-legend { display: flex; gap: 16px; font-size: 14px; color: var(--ink-soft); margin-top: 6px; }
.chart-legend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }
.chart-legend .c1 { background: var(--ok); }
.chart-legend .c2 { background: var(--squid-deep); }

/* ── 물방울 게임 ───────────────────── */
.game-hud { display: flex; gap: 24px; align-items: center; font-size: 20px; margin: 8px 0; }
.game-hud b { font-size: 26px; }
.hearts { color: var(--bad); font-size: 26px; letter-spacing: 2px; margin-left: auto; }
.sea {
  position: relative; height: 360px; border: 3px solid var(--line); border-radius: 24px; overflow: hidden; margin-bottom: 12px;
  background: url(../img/sea.webp) center bottom / cover no-repeat, linear-gradient(#bfe7ff, #8fd0f0);
}
.sea__squid { position: absolute; right: 16px; bottom: 8px; width: 110px; opacity: .9; }
.sea__msg {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; background: rgba(255,255,255,.55); color: #3a2418; z-index: 3;
}
.sea__msg[hidden] { display: none; }
.sea__msg h2 { font-family: var(--font-fun); font-weight: 800; font-size: 40px; margin: 0; color: #6e3b26; }
.bubble-word {
  position: absolute; top: 0; padding: 14px 22px; border-radius: 999px; font-size: 28px; font-weight: 800;
  background: radial-gradient(circle at 30% 25%, #fff 0 12%, #ffffffcc 13%, #e8f7ffcc 60%, #c9ecffcc);
  border: 2px solid #ffffff; box-shadow: 0 4px 12px rgba(0,60,100,.15); color: #2a4a63; white-space: nowrap;
  transition: opacity .3s, scale .3s;
}
.bubble-word.is-active { border-color: #6e3b26; border-width: 3px; z-index: 2; }
.bubble-word .typed { color: var(--ok); }
.bubble-word .cur { color: #3a2418; background: #ffe3dc; border-radius: 6px; }
.bubble-word .rest { color: #2a4a63; }
.bubble-word.is-pop { opacity: 0; scale: 1.6; }
.bubble-word.is-miss { opacity: 0; }
.bubble-word.is-shake { animation: shake .25s; }

/* ── 대회 ──────────────────────────── */
.form { display: grid; gap: 12px; max-width: 640px; }
.form label { display: grid; gap: 4px; font-weight: 700; }
.form input, .form select, .contest-join input, .linkbox input {
  font: inherit; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: #222;
}
.form .btn { justify-self: start; }
.linkbox { display: flex; gap: 8px; }
.linkbox input { flex: 1; min-width: 0; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--danger { color: var(--bad); border-color: var(--bad); }
.btn--danger:hover { background: color-mix(in srgb, var(--bad) 10%, var(--card)); }
.form-err:empty { display: none; }
.form-err { color: var(--bad); font-weight: 700; margin: 0; min-height: 1.4em; font-family: var(--font-body); }
/* 대회 진행(선생님) */
.room { display: grid; gap: 18px; }
.room[hidden] { display: none; }
.room h3 { margin: 0; font-size: 26px; }
.room__label { display: block; font-weight: 700; font-size: 15px; color: var(--ink-soft); margin-bottom: 6px; }
.room__bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; background: var(--cream); border-radius: 16px; }
.room__status { margin: 0; font-family: var(--font-body); font-weight: 800; font-size: 22px; }
.room__foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 2px dashed color-mix(in srgb, var(--line) 25%, transparent); padding-top: 14px; }
.room__foot small { color: var(--ink-soft); font-size: 15px; font-family: var(--font-text); }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank li { display: grid; grid-template-columns: 48px 1fr auto auto auto; gap: 16px; align-items: center; padding: 10px 16px; border: 2px solid color-mix(in srgb, var(--line) 20%, transparent); border-radius: 14px; font-size: 18px; }
.rank li.is-wait { color: var(--ink-soft); }
.rank__no { font-weight: 800; font-size: 22px; text-align: center; }
.rank__nick { font-weight: 800; }
.rank__score { font-weight: 800; font-size: 22px; min-width: 80px; text-align: right; }
.rank__sub { color: var(--ink-soft); font-size: 15px; min-width: 64px; text-align: right; }
.rank li:nth-child(1).is-done .rank__no { color: #d9a400; }
.rank__empty { color: var(--ink-soft); padding: 12px 0; }
.mine { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.mine li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mine small { color: var(--ink-soft); }
.learn--contest { max-width: calc(800px + 32px); } /* 대회 화면: 800px 폭 가운데 정렬(제목·블록 같은 왼쪽 끝) */
.learn--contest > .panel, .learn--contest > .form { max-width: none; }
/* 대회 대기실(학생) */
.wait-dots::after { content: ''; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.countdown { font-size: 140px; font-weight: 800; color: var(--line); margin: 0; line-height: 1; }
@media (max-width: 720px) { .rank li { grid-template-columns: 36px 1fr auto; } .rank__sub { display: none; } }
.contest-join { display: grid; gap: 14px; }
.contest-join input { font-size: 24px; text-align: center; }
.contest-code b { font-size: 24px; letter-spacing: 3px; }
@media (max-width: 860px) { .rec-grid { grid-template-columns: 1fr; } }

/* 타이핑 중 통통 (그림 한 장짜리 스킨) */
img.is-tap { animation: tap .14s ease-out; }
@keyframes tap { 50% { transform: translateY(-4px) rotate(-1.5deg); } }

/* 스킨 자판 판 그림 (9조각: 원본 1200×400, 모서리 100px는 그대로, 가운데는 늘어남) */
body.has-plate .kb {
  width: fit-content; margin: 0 auto;   /* 키 크기에 맞춰 판을 줄여 덜 늘어나게 */
  background: none; border-radius: 0; padding: 38px 46px;  /* 판 장식(80px)이 키 바깥쪽에 살짝 겹쳐 들어옴 */
  border: 18px solid transparent;
  border-image: var(--kb-plate) 100 fill / 80px / 0 round;  /* 원본의 80%로 표시(덜 찌그러짐), 테두리 무늬는 반복 */
  --k-cut: 6.85px;  /* 좌우 여백이 기본보다 90px 많음 ÷ 키 너비 단위(약 13.1칸) */
}
/* 스킨 배경: 위쪽 기준으로 깔고, 바탕색을 70% 덮어 그림은 30%만 보이게(로고·글자가 잘 보이게) */
body[data-skin]:not([data-skin="basic"])::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}
body[data-skin]:not([data-skin="basic"]) { --bar: color-mix(in srgb, var(--line) 55%, var(--card)); }
/* 스킨 배경: 16:9보다 세로가 긴 창에서는 가로에 맞춰(덜 확대), 아래쪽 기준 */
@media (max-aspect-ratio: 16/9) {
  body[data-skin]:not([data-skin="basic"]) { background-size: 100% auto, auto; background-position: center top, 0 0; }
  /* 그림(높이 = 폭×9/16)이 끝나는 아래쪽을 바탕색으로 부드럽게 이어 경계선 없애기 */
  body[data-skin]:not([data-skin="basic"])::after {
    content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background: linear-gradient(to bottom, transparent calc(56.25vw * .55), var(--bg) calc(56.25vw - 2px));
  }
}

.board__div { align-self: stretch; margin: 8px 0; border-radius: 2px; background: color-mix(in srgb, var(--line) 25%, transparent); }
.board__main { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.kb { width: fit-content; margin: 0 auto; }
/* 낮은 화면에서 자판 판 스킨이 아래 광고와 겹치지 않게 */
@media (max-height: 820px) {
  body.has-plate .kb { padding: 24px 32px; border-width: 12px; border-image-width: 56px; --k-cut: 3.8px; }
  body.has-plate .legend { display: none; }
}

/* 연습 화면: 상단 로고·버튼도 진행줄·글자창·자판 판과 같은 가로 끝에 맞춤 (PC 기준) */
.practice-wrap { width: fit-content; max-width: 1100px; margin: 0 auto; }
.practice-wrap > .topbar { contain: inline-size; max-width: none; margin: 0; }
.practice-wrap > .practice { margin: 0; }
@media (min-width: 1280px) and (max-width: 1499px) {
  .practice-wrap { margin-left: 200px; margin-right: 16px; max-width: calc(100vw - 232px); }
  .practice-wrap > .topbar, .practice-wrap > .practice { margin: 0; max-width: none; }
}

/* ── 글꼴 나눔: 설명·서술은 고운바탕, 나머지는 프리텐다드 ── */
p, .more-card small { font-family: var(--font-text); }
.skins-pop__title, .no-keyboard, .room__status { font-family: var(--font-body); }

/* ── 하단 안내 링크 ───────────────── */
.site-foot { max-width: 1100px; margin: 8px auto 0; padding: 20px 16px 28px; text-align: center; color: var(--ink-soft); font-size: 15px; }
.site-foot nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 20px; margin-bottom: 6px; }
.site-foot a { color: var(--ink-soft); text-decoration: none; font-weight: 700; }
.site-foot a:hover { color: var(--line); text-decoration: underline; }
.site-foot p { margin: 0; font-family: var(--font-body); }
/* ── 문서(소개·약관·개인정보·문의) ───── */
.doc { max-width: calc(800px + 32px); }
.doc article { background: var(--card); border: 3px solid var(--line); border-radius: 24px; padding: 28px 36px; margin-top: 16px; line-height: 1.75; }
.doc h1 { font-size: 32px; color: var(--line); margin: 0 0 12px; }
.doc h2 { font-size: 21px; color: var(--line); margin: 28px 0 8px; }
.doc li, .doc td, .doc th { font-family: var(--font-text); }
.doc ul, .doc ol { padding-left: 22px; margin: 8px 0; }
.doc li { margin: 4px 0; }
.doc table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.doc th, .doc td { border: 1px solid color-mix(in srgb, var(--line) 25%, transparent); padding: 10px 12px; text-align: left; vertical-align: top; }
.doc th { width: 30%; background: var(--cream); font-weight: 700; }
.doc-lead { font-size: 18px; }
.doc-mail { font-size: 24px; font-family: var(--font-body) !important; font-weight: 800; }
.doc .note { color: var(--ink-soft); margin-top: 24px; }
@media (max-width: 640px) { .doc article { padding: 20px; } }
