/* Kana — a calligraphy practice sheet on an indigo night. */
.kn-table {
  --kn: min(58vw, 30vh, 280px);
  --kn-jp: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif CJK JP", "Noto Serif JP", "Hiragino Sans", "Yu Gothic", "Noto Sans CJK JP", "Noto Sans JP", Meiryo, serif;
  direction: ltr;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vh, 18px);
  width: min(100%, 440px);
  height: 100%;
  padding: 8px 16px;
}

.kn-top { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 26px; }
.kn-time { flex: 1 1 auto; height: 10px; border-radius: 999px; background: rgba(251, 243, 234, 0.12); overflow: hidden; }
.kn-time__fill {
  display: block; width: 100%; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--w-blossom), var(--gold-soft));
  transform-origin: 0 50%; transition: transform 0.12s linear;
}
.kn-time__fill.is-low { background: var(--w-torii); }
.kn-clock { min-width: 38px; font-weight: 800; font-size: 15px; color: var(--parchment); font-variant-numeric: tabular-nums; text-align: center; }
.kn-streak {
  min-width: 40px; padding: 3px 8px; border-radius: 999px; font-weight: 800; font-size: 14px; text-align: center;
  color: var(--w-ink); background: var(--w-blossom); opacity: 0; transform: scale(0.8); transition: opacity 0.15s, transform 0.15s;
}
.kn-streak.is-on { opacity: 1; transform: none; }

/* the sheet: one big model square and a practice row */
.kn-sheet {
  display: flex; flex-direction: column; gap: calc(var(--kn) * 0.05);
  padding: calc(var(--kn) * 0.07);
  border-radius: 8px;
  background: linear-gradient(180deg, #FFFAF3, var(--w-paper));
  box-shadow: 0 14px 30px rgba(10, 6, 22, 0.55), inset 0 0 0 1px rgba(46, 58, 124, 0.12);
  transform: rotate(-1deg);
}
.kn-big, .kn-cell {
  position: relative; display: flex; align-items: center; justify-content: center;
  border: 1.5px solid rgba(224, 69, 47, 0.55);
  background:
    linear-gradient(90deg, transparent calc(50% - 0.5px), rgba(224, 69, 47, 0.22) 0, rgba(224, 69, 47, 0.22) calc(50% + 0.5px), transparent 0),
    linear-gradient(0deg, transparent calc(50% - 0.5px), rgba(224, 69, 47, 0.22) 0, rgba(224, 69, 47, 0.22) calc(50% + 0.5px), transparent 0);
  color: var(--w-ink);
  font-family: var(--kn-jp);
}
.kn-big { width: var(--kn); height: var(--kn); }
.kn-glyph { font-size: calc(var(--kn) * 0.68); line-height: 1; font-weight: 600; }
.kn-note {
  position: absolute; right: 7%; bottom: 4%;
  font: italic 800 calc(var(--kn) * 0.13)/1 Georgia, serif; color: var(--w-torii); opacity: 0;
}
.kn-note.is-shown { opacity: 1; }
.kn-note.is-hint { opacity: 0.75; color: var(--w-indigo); animation: kn-pulse 1.1s ease-in-out infinite; }
.kn-stamp { position: absolute; left: 4%; top: 4%; width: 92%; height: 92%; pointer-events: none; opacity: 0; }
.kn-stamp svg { width: 100%; height: 100%; overflow: visible; }
.kn-stamp path, .kn-row__mark path { fill: none; stroke: var(--w-torii); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.kn-stamp path { stroke-dasharray: 1; stroke-dashoffset: 0; }
.kn-big.is-right .kn-stamp { opacity: 0.72; }
.kn-big.is-right .kn-stamp path { animation: kn-draw 0.36s ease-out both; }
.kn-big.is-wrong { animation: kn-shake 0.34s ease-in-out; }
.kn-big.is-wrong .kn-note { color: var(--w-indigo); }

.kn-strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; width: var(--kn); }
.kn-cell { aspect-ratio: 1; margin-left: -1.5px; font-size: calc(var(--kn) * 0.105); font-weight: 600; line-height: 1; }
.kn-cell:first-child { margin-left: 0; }
.kn-cell.is-done::after {
  content: ""; position: absolute; left: 8%; top: 8%; width: 84%; height: 84%;
  border: 2px solid var(--w-torii); border-radius: 50%; opacity: 0.8;
  animation: kn-stamp 0.26s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

/* the four sounds */
.kn-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.kn-choice {
  min-height: clamp(52px, 8.4vh, 72px);
  border: 2px solid var(--hairline); border-radius: 18px;
  background: var(--lapis-raise); color: var(--parchment);
  font-family: inherit; font-weight: 800; font-size: clamp(24px, 3.8vh, 30px); line-height: 1; letter-spacing: 0.02em;
  box-shadow: 0 4px 0 rgba(10, 6, 22, 0.45);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; cursor: pointer;
  transition: transform 0.08s, background 0.12s, border-color 0.12s;
}
.kn-choice:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(10, 6, 22, 0.45); }
.kn-choice:focus-visible { outline: 3px solid var(--gold-soft); outline-offset: 2px; }
.kn-choice.is-hint { border-color: var(--w-blossom); animation: kn-glow 1.1s ease-in-out infinite; }
.kn-choice.is-right { background: var(--w-matcha); border-color: var(--w-matcha); color: var(--w-ink); }
.kn-choice.is-wrong { border-color: var(--w-torii); color: var(--mist-dim); }
.kn-choice[disabled] { cursor: default; }

/* the chart */
.kn-chart { direction: ltr; display: flex; flex-direction: column; gap: 4px; width: 100%; max-width: 330px; margin: 0 auto; padding-left: 30px; }
.kn-row { display: grid; grid-template-columns: repeat(5, 1fr) 26px; gap: 4px; align-items: center; }
.kn-row.is-locked { opacity: 0.42; }
.kn-k {
  position: relative; display: flex; align-items: baseline; justify-content: center; gap: 4px;
  min-height: 30px; padding: 4px 2px 5px; border-radius: 7px; overflow: hidden;
  border: 1px solid var(--hairline); color: var(--mist);
}
.kn-k.is-gap { border-color: transparent; }
.kn-k__g { font: 600 17px/1.1 "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif CJK JP", "Hiragino Sans", "Yu Gothic", "Noto Sans CJK JP", Meiryo, serif; }
.kn-k__r { font-size: 10px; font-weight: 700; opacity: 0.8; }
.kn-k.is-m1, .kn-k.is-m2, .kn-k.is-m3 { background: var(--lapis-raise); color: var(--parchment); }
.kn-k.is-m1::after, .kn-k.is-m2::after, .kn-k.is-m3::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 8%; background: var(--w-blossom);
}
.kn-k.is-m2::after { width: 40%; }
.kn-k.is-m3::after { width: 72%; }
.kn-k.is-m4 { background: var(--w-paper); border-color: var(--w-paper); color: var(--w-ink); }
.kn-row__mark { width: 26px; height: 26px; }
.kn-row__mark svg { width: 100%; height: 100%; overflow: visible; }
.kn-row__mark path { stroke-width: 6; }

@keyframes kn-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes kn-stamp { from { transform: scale(1.9); opacity: 0; } to { transform: none; opacity: 0.8; } }
@keyframes kn-shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes kn-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.85; } }
@keyframes kn-glow { 0%, 100% { box-shadow: 0 4px 0 rgba(10, 6, 22, 0.45), 0 0 0 0 rgba(246, 166, 193, 0.5); } 50% { box-shadow: 0 4px 0 rgba(10, 6, 22, 0.45), 0 0 0 6px rgba(246, 166, 193, 0.18); } }

/* phones on their side: sheet on the left, sounds on the right */
@media (orientation: landscape) and (max-height: 520px) {
  .kn-table {
    --kn: min(40vh, 30vw);
    display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto 1fr;
    column-gap: 22px; row-gap: 6px; width: min(100%, 680px); padding: 4px 16px; align-items: center;
  }
  .kn-top { grid-column: 1 / -1; }
  .kn-choice { min-height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  .kn-big.is-right .kn-stamp path, .kn-cell.is-done::after, .kn-big.is-wrong, .kn-note.is-hint, .kn-choice.is-hint { animation: none; }
}
