/* 빈칸 타자 게임 — 공책 한 장 위에서 벌어지는 게임
   종이 · 괘선 하늘색 · 여백선 빨강 · 만년필 남색 · 형광펜 노랑 · 지우개 분홍 · 공책 표지 파랑 */

.drop {
  --paper: #ffffff;
  --rule: #bcd5ec;
  --margin: #e0706a;
  --ink: #142033;
  --ink-2: #4c5873;
  --hi: #ffe45c;
  --eraser: #f6c7cf;
  --eraser-ink: #c23a52;
  --cover: #2f5d8a;
  --good: #23805a;
  --type: "Courier Prime", "Courier New", ui-monospace, monospace;
  --rows: 6;
  --rowh: 64px;
  --head: 72px;
  --pad-l: 76px;
  max-width: 780px;
  color: var(--ink);
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- 공책 ---------- */
.notebook {
  position: relative;
  background: var(--paper);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1.5px var(--ink);
  overflow: hidden;
  /* 오른쪽 아래 모서리를 책벌레가 갉아먹었어요 */
  -webkit-mask: radial-gradient(circle at calc(100% + 6px) calc(100% + 6px), transparent 58px, #000 59px);
          mask: radial-gradient(circle at calc(100% + 6px) calc(100% + 6px), transparent 58px, #000 59px);
}
.nb-head {
  height: var(--head);
  display: flex; align-items: flex-end; gap: 22px;
  padding: 0 24px 12px var(--pad-l);
  border-bottom: 2px solid var(--rule);
  background: linear-gradient(90deg, transparent calc(var(--pad-l) - 16px), var(--margin) calc(var(--pad-l) - 16px), var(--margin) calc(var(--pad-l) - 14px), transparent calc(var(--pad-l) - 14px));
}
.field { display: flex; align-items: baseline; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.field b {
  min-width: 34px; padding: 0 4px 1px; border-bottom: 1px solid var(--ink-2);
  font-size: 20px; font-weight: 800; color: var(--ink); text-align: center;
  font-variant-numeric: tabular-nums;
}
.field.lives { margin-left: auto; }
.field.lives b { border: 0; display: inline-flex; gap: 5px; min-width: 0; }
.life { width: 4px; height: 20px; border-radius: 2px; background: var(--ink); transform: rotate(8deg); transition: background .3s, opacity .3s; }
.life.gone { background: var(--eraser); opacity: .9; }

.page {
  position: relative;
  height: calc(var(--rows) * var(--rowh) + 14px);
  background:
    linear-gradient(90deg, transparent calc(var(--pad-l) - 16px), var(--margin) calc(var(--pad-l) - 16px), var(--margin) calc(var(--pad-l) - 14px), transparent calc(var(--pad-l) - 14px)),
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--rowh) - 1px), var(--rule) calc(var(--rowh) - 1px) var(--rowh));
}
.danger {
  position: absolute; left: calc(var(--pad-l) - 14px); right: 0; bottom: 14px; height: calc(var(--rowh) - 1px);
  background: repeating-linear-gradient(135deg, rgba(224, 112, 106, .14) 0 6px, transparent 6px 13px);
  display: flex; align-items: center; padding-left: 14px;
}
.danger span { font-size: 12px; font-weight: 700; color: var(--margin); }

/* 떨어지는 문장 쪽지 */
.slip {
  position: absolute; left: calc(var(--pad-l) - 4px); right: 30px; top: 6px;
  min-height: calc(var(--rowh) - 12px);
  padding: 12px 18px 10px;
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(30, 43, 69, .06), 0 8px 18px -8px rgba(30, 43, 69, .4);
  rotate: -.6deg;
  transition: transform .5s cubic-bezier(.3, 1.35, .45, 1), box-shadow .3s;
}
.tape {
  position: absolute; top: -9px; left: 50%; width: 74px; height: 20px; translate: -50% 0; rotate: 3deg;
  background: rgba(255, 228, 92, .72);
  clip-path: polygon(3% 0, 97% 4%, 100% 30%, 96% 55%, 100% 80%, 96% 100%, 2% 96%, 0 70%, 4% 45%, 0 18%);
}
.slip.hit { animation: shake .38s; box-shadow: 0 0 0 2px var(--eraser), 0 8px 18px -8px rgba(194, 58, 82, .5); }
.slip.good { box-shadow: 0 0 0 2px var(--good), 0 8px 18px -8px rgba(35, 128, 90, .45); }
@keyframes shake { 20% { margin-left: -9px; } 45% { margin-left: 8px; } 70% { margin-left: -4px; } }
.sent { margin: 0; font-family: var(--type); font-size: clamp(17px, 2.5vw, 21px); line-height: 1.4; }
.blank {
  display: inline-block; min-width: 4.5em; padding: 0 .2em; text-align: center;
  border-bottom: 2px solid var(--ink); font-weight: 700;
}
.blank.filled { border-color: transparent; background: linear-gradient(transparent 38%, var(--hi) 38% 92%, transparent 92%); }
.ko { display: block; margin-top: 4px; font-family: var(--font); font-size: 13px; color: var(--ink-2); }
.tbar { height: 3px; margin-top: 8px; background: #eef2f7; border-radius: 3px; overflow: hidden; }
.tbar[hidden] { display: none; }
.tbar i { display: block; height: 100%; background: var(--ink); transform-origin: left; }

.worm {
  position: absolute; right: -6px; bottom: -4px; width: 116px; z-index: 2;
  pointer-events: none;
}
/* 마스크 밖으로 나오도록 공책 바깥 래퍼에 붙어요 */
.nb-wrap { position: relative; }

/* ---------- 표지 (시작 화면) ---------- */
.cover { position: absolute; inset: 0; z-index: 3; }
.report { position: fixed; inset: 0; z-index: 50; }
.cover, .report { display: grid; place-items: center; padding: 20px; overflow: auto; }
.cover[hidden], .report[hidden] { display: none; }
.cover {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .18) 0 14px, rgba(255, 255, 255, .06) 14px 16px, transparent 16px),
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, .08), transparent 50%),
    var(--cover);
}
.cover-label {
  width: min(460px, 100%);
  background: var(--paper); border-radius: 10px; padding: 26px 28px 24px;
  box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 4px var(--cover), 0 10px 24px rgba(0, 0, 0, .25);
  text-align: center;
}
.cover-label img { width: 92px; margin: -6px auto 2px; display: block; }
.cover-label h1 { margin: 4px 0 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.cover-label > p { margin: 8px 0 18px; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.opts { display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: center; margin: 0 0 6px; text-align: left; }
.opts dt { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.opts dd { margin: 0; }
.help { min-height: 20px; margin: 6px 0 16px; font-size: 12.5px; color: var(--ink-2); }

.btn-ink {
  font: inherit; font-weight: 800; font-size: 16px; color: #fff; cursor: pointer;
  background: var(--ink); border: 0; border-radius: 10px; padding: 12px 22px;
  box-shadow: 0 3px 0 #0e172b; transition: translate .08s, box-shadow .08s;
}
.btn-ink:active { translate: 0 2px; box-shadow: 0 1px 0 #0e172b; }
.btn-ink:disabled { opacity: .35; cursor: default; }
.cover .btn-ink { width: 100%; }

/* ---------- 성적표 (끝 화면) ---------- */
.report { background: rgba(30, 43, 69, .55); color: #142033; --paper: #ffffff; --ink: #142033; --ink-2: #4c5873; --hi: #ffe45c; --eraser-ink: #c23a52; --type: "Courier Prime", "Courier New", monospace; }
.drop.idle .keys, .drop.idle .typebar, .drop.idle .msg, .drop.idle .opts-row { display: none; }
.nowrap { white-space: nowrap; }
.report-paper {
  position: relative; width: min(480px, 100%);
  background: var(--paper); border-radius: 6px; padding: 26px 26px 22px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .3);
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, #e3ecf6 31px 32px);
}
.report-paper h2 { margin: 0 0 6px; font-size: 20px; font-weight: 800; padding-right: 96px; }
.report-paper { max-height: calc(100vh - 40px); overflow: auto; }
.final { margin: 0; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.final b { font-size: 44px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.final span { font-size: 14px; color: var(--ink-2); }
.final em { font-style: normal; font-weight: 800; color: var(--ink); }
.newbest { margin: 4px 0 0; display: inline-block; font-size: 13px; font-weight: 700; background: linear-gradient(transparent 45%, var(--hi) 45%); }
.newbest[hidden] { display: none; }
.stamp {
  position: absolute; top: 18px; right: 18px; width: 92px; height: 92px; border-radius: 50%;
  display: grid; place-items: center; text-align: center;
  color: #d43d3d; border: 3px solid currentColor; box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 5px currentColor;
  font-weight: 900; font-size: 15px; line-height: 1.15; letter-spacing: -.03em;
  rotate: -14deg; opacity: .9; mix-blend-mode: multiply;
}
.stamp span { width: 60px; }
.report:not([hidden]) .stamp { animation: stamp .5s .25s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes stamp { from { scale: 2.2; opacity: 0; } 60% { opacity: .95; } }
.review { margin-top: 16px; }
.review[hidden] { display: none; }
.review h3 { margin: 0 0 8px; font-size: 14px; font-weight: 800; }
.review ul { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; max-height: 190px; overflow: auto; }
.review li { font-size: 13.5px; line-height: 1.5; padding-left: 12px; border-left: 3px solid var(--hi); }
.review li b { font-family: var(--type); font-size: 15px; }
.review li s { font-family: var(--type); color: var(--eraser-ink); margin-left: 6px; }
.review li small { display: block; font-family: var(--type); font-size: 13px; color: var(--ink-2); }
.report-paper .btn-ink { width: 100%; margin-top: 6px; }

/* ---------- 보기 단어 (타자기 자판) ---------- */
.keys { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; min-height: 52px; margin: 26px 0 18px; }
.key {
  font-family: var(--type); font-weight: 700; font-size: 19px; color: #ffffff;
  padding: 10px 20px 11px; border-radius: 999px;
  background: radial-gradient(circle at 50% 30%, #34425f, var(--ink) 70%);
  box-shadow: inset 0 0 0 2px #8f9ab0, inset 0 0 0 4px var(--ink), 0 4px 0 #0e172b, 0 6px 10px -2px rgba(30, 43, 69, .4);
  transition: background .2s, color .2s;
}
.key.right { background: var(--hi); color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink), 0 4px 0 #b9a326; }
.key.wrong { background: var(--eraser); color: var(--eraser-ink); text-decoration: line-through 2px; box-shadow: inset 0 0 0 2px var(--eraser-ink), 0 4px 0 #d99aa8; }

/* ---------- 입력 줄 ---------- */
.typebar { display: flex; gap: 10px; align-items: stretch; }
.type-line { flex: 1; min-width: 0; display: flex; }
#typing {
  width: 100%; font-family: var(--type); font-size: 19px; color: var(--ink);
  padding: 13px 16px; background: #fff; border: 2px solid var(--ink); border-radius: 10px;
  box-shadow: 0 3px 0 var(--rule);
}
#typing::placeholder { font-family: var(--font); color: #a3abbb; font-size: 16px; }
#typing:focus { outline: none; box-shadow: 0 0 0 4px rgba(255, 228, 92, .8); }
#typing:disabled { border-color: #c9cfdb; background: #f7f8fa; }


.msg { min-height: 26px; margin: 12px 0 6px; text-align: center; font-weight: 600; line-height: 1.6; }
.msg.bad { color: var(--eraser-ink); }
.msg.good { color: var(--good); }
.msg .gain { font-weight: 800; background: linear-gradient(transparent 50%, var(--hi) 50%); color: var(--ink); padding: 0 2px; }
.msg .note { display: block; font-weight: 500; font-size: 14px; color: var(--ink-2); }
.diff { display: block; margin-top: 2px; font-family: var(--type); font-weight: 400; color: var(--ink); }
.diff s { text-decoration: none; color: var(--eraser-ink); background: var(--eraser); border-radius: 3px; padding: 0 3px; }

.opts-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink-2); }
.link-btn { font: inherit; font-size: 13px; color: var(--ink-2); background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn[hidden] { display: none; }

@media (max-width: 600px) {
  .drop { --rowh: 58px; --head: 92px; --pad-l: 34px; }
  .nb-head { flex-wrap: wrap; align-content: flex-end; gap: 8px 14px; padding: 0 14px 10px var(--pad-l); }
  .field b { font-size: 17px; min-width: 26px; }
  .field.lives { margin-left: 0; }
  .slip { right: 14px; padding: 11px 14px 9px; }
  .worm { width: 88px; }
  .notebook {
    -webkit-mask: radial-gradient(circle at calc(100% + 6px) calc(100% + 6px), transparent 44px, #000 45px);
            mask: radial-gradient(circle at calc(100% + 6px) calc(100% + 6px), transparent 44px, #000 45px);
  }
  .danger span { padding-right: 70px; }
  .cover-label { padding: 22px 14px 20px; }
  .seg button { padding: 6px 9px; font-size: 13px; }
  .opts { gap: 10px 8px; }
  .stamp { width: 76px; height: 76px; font-size: 13px; top: 14px; right: 14px; }
  .report-paper h2 { padding-right: 78px; }
  .key { font-size: 17px; padding: 9px 16px 10px; }
  #typing { font-size: 17px; }
  .typebar .btn-ink { padding: 12px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .slip { transition: none; }
  .slip.hit, .report:not([hidden]) .stamp { animation: none; }
}
