:root {
  --ink: #30281f;
  --pencil: #8b8981;
  --tan: #a86c49;
  --paper: #fff8ea;
  --room: #f7ebd4;
  --yellow: #f2bd32;
  --orange: #e88724;
  --salmon: #e99579;
  --olive: #78805a;
  --line: rgba(48, 40, 31, 0.72);
  --soft-line: rgba(168, 108, 73, 0.26);
  --display: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", sans-serif;
  --body: "Zen Kaku Gothic New", "Hiragino Sans", sans-serif;
}

* { box-sizing: border-box; }

html {
  max-width: 100%;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--room);
  font-family: var(--body);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  overflow-x: clip;
  background:
    radial-gradient(circle at 20% 30%, rgba(168,108,73,.09) 0 1px, transparent 1.4px) 0 0 / 13px 13px,
    radial-gradient(circle at 70% 10%, rgba(48,40,31,.05) 0 .7px, transparent 1.2px) 0 0 / 9px 11px,
    var(--room);
}

body::after {
  position: fixed;
  z-index: 20;
  inset: 0;
  background: repeating-linear-gradient(5deg, transparent 0 3px, rgba(48,40,31,.015) 3px 4px);
  content: "";
  pointer-events: none;
}

button, input { font: inherit; }
button { color: inherit; }

.page-shell { width: min(1160px, calc(100% - 40px)); margin: 0 auto; }

.site-header {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px dashed rgba(168,108,73,.3);
}

.brand { display: flex; color: inherit; text-decoration: none; }
.brand > span { display: flex; flex-direction: column; align-items: flex-start; }
.asobi-logo { position: relative; font-family: var(--display); font-size: 24px; font-weight: 800; letter-spacing: .03em; line-height: 1; }
.asobi-logo i { position: absolute; top: -5px; right: 6px; color: var(--orange); font-size: 7px; font-style: normal; }
.brand small { margin-top: 3px; color: var(--tan); font-size: 10px; font-weight: 700; letter-spacing: .08em; }

.sound-tools { display: flex; gap: 8px; align-items: center; }

.sound-button {
  display: flex;
  gap: 7px;
  align-items: center;
  min-height: 34px;
  padding: 5px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 2px 3px 0 rgba(48,40,31,.18);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.sound-button span:first-child { color: var(--orange); font-size: 18px; }
.sound-button[aria-pressed="false"] { color: #8b8177; background: #eee2ce; box-shadow: inset 0 2px 0 rgba(48,40,31,.08); }

.volume-control {
  display: flex;
  min-height: 34px;
  gap: 7px;
  align-items: center;
  padding: 5px 10px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 2px 3px 0 rgba(48,40,31,.18);
  color: var(--tan);
  font-size: 10px;
  font-weight: 700;
}

.volume-control input {
  width: 92px;
  height: 18px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.volume-control input::-webkit-slider-runnable-track {
  height: 7px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: linear-gradient(to right, var(--orange) 0 var(--volume-fill, 70%), #eadcc3 var(--volume-fill, 70%) 100%);
}

.volume-control input::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  margin-top: -5px;
  appearance: none;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 1px 2px 0 rgba(48,40,31,.18);
}

.volume-control input::-moz-range-track {
  height: 5px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #eadcc3;
}

.volume-control input::-moz-range-progress { height: 5px; border-radius: 999px; background: var(--orange); }
.volume-control input::-moz-range-thumb { width: 13px; height: 13px; border: 2px solid var(--line); border-radius: 50%; background: var(--yellow); box-shadow: 1px 2px 0 rgba(48,40,31,.18); }
.volume-control input:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; border-radius: 999px; }
.volume-control output { min-width: 29px; color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }

.game-stage {
  display: grid;
  grid-template-columns: minmax(320px, .78fr) minmax(520px, 1.22fr);
  gap: clamp(48px, 6vw, 82px);
  align-items: center;
  padding: 46px 2vw 34px;
}

.intro { position: relative; }
.intro::before, .intro::after { position: absolute; color: var(--orange); font-family: var(--display); font-weight: 800; content: "〽"; }
.intro::before { top: -41px; left: 7px; font-size: 24px; transform: rotate(-19deg); }
.intro::after { right: 5px; bottom: -42px; font-size: 18px; transform: rotate(30deg); }

.category-label {
  display: inline-block;
  margin: 0 0 18px;
  padding-bottom: 5px;
  border-bottom: 4px solid rgba(233,149,121,.58);
  color: var(--tan);
  font-size: 12px;
  font-weight: 700;
  transform: rotate(-1deg);
}

.category-label span { color: var(--orange); }

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(38px, 3.7vw, 50px);
  font-weight: 800;
  letter-spacing: -.07em;
  line-height: 1.2;
  text-shadow: 1px 1px 0 rgba(48,40,31,.12);
}

h1 span { display: block; white-space: nowrap; }
.intro > p:not(.category-label) { margin: 18px 0 0; color: #65594e; font-size: 13px; line-height: 1.75; }

.level-picker { margin: 18px 0 0; padding: 0; border: 0; }
.level-picker legend { margin-bottom: 8px; color: var(--tan); font-size: 10px; font-weight: 700; }
.level-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.level-options label { position: relative; cursor: pointer; }
.level-options input { position: absolute; opacity: 0; pointer-events: none; }
.level-options span {
  display: flex;
  min-height: 47px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 2px 3px 0 rgba(48,40,31,.14);
  transition: transform 90ms ease, background 90ms ease;
}
.level-options b { font-family: var(--display); font-size: 12px; }
.level-options small { color: #76695d; font-size: 9px; }
.level-options input:checked + span { background: var(--yellow); box-shadow: inset 0 -3px 0 rgba(209,139,0,.3), 2px 3px 0 rgba(48,40,31,.2); transform: translateY(-2px); }
.level-options input:focus-visible + span { outline: 3px solid var(--orange); outline-offset: 2px; }
.level-picker:disabled { opacity: .46; }

.mini-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 11px 17px;
  margin-top: 20px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.mini-guide span { display: flex; align-items: center; gap: 6px; }
.mini-guide b {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--yellow);
  font-family: var(--display);
  font-size: 10px;
  box-shadow: 1px 2px 0 rgba(48,40,31,.2);
}

.type-machine {
  position: relative;
  width: min(100%, 610px);
  margin-top: 70px;
  padding: 18px 20px 20px;
  border: 2px solid var(--line);
  border-radius: 20px;
  background:
    radial-gradient(circle, rgba(168,108,73,.08) 0 1px, transparent 1.4px) 0 0 / 10px 10px,
    var(--paper);
  box-shadow: 5px 7px 0 rgba(48,40,31,.16);
  isolation: isolate;
}

.type-machine::before {
  position: absolute;
  z-index: -1;
  inset: 5px -5px -5px 5px;
  border: 1px solid rgba(48,40,31,.3);
  border-radius: 18px;
  content: "";
  transform: rotate(.25deg);
}

.typing-cats {
  position: absolute;
  z-index: 3;
  top: -153px;
  right: 24px;
  width: min(320px, 58%);
  height: auto;
  filter: drop-shadow(1px 3px 0 rgba(48,40,31,.12));
  pointer-events: none;
  user-select: none;
}

.score-row { position: relative; display: grid; z-index: 2; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.score-row > div {
  min-height: 56px;
  padding: 5px 9px;
  border: 2px solid var(--line);
  border-radius: 13px 15px 12px 14px;
  background: rgba(255,248,234,.88);
  box-shadow: inset 0 0 0 2px rgba(168,108,73,.08), 2px 3px 0 rgba(48,40,31,.12);
  text-align: center;
}

.score-row > div:nth-child(2) span { color: #d99200; }
.score-row > div:nth-child(3) span { color: #e36f42; }
.score-row span { display: block; color: var(--tan); font-size: 10px; font-weight: 700; }
.score-row .hud-paw { height: 14px; }
.hud-paw img { width: 15px; height: 15px; vertical-align: top; }
.score-row strong { font-family: var(--display); font-size: 21px; font-weight: 800; letter-spacing: -.03em; }
.score-row small { margin-left: 3px; color: #6e6258; font-size: 9px; }

.word-card {
  position: relative;
  min-height: 205px;
  margin-top: 10px;
  padding: 23px 26px 19px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 17px 15px 19px 14px;
  background:
    linear-gradient(rgba(168,108,73,.035) 1px, transparent 1px) 0 0 / 100% 23px,
    #fffaf0;
  box-shadow: inset 0 0 0 3px rgba(168,108,73,.08);
  text-align: center;
  transform: rotate(-.1deg);
}

.coat-swatch { position: absolute; top: -35px; right: -28px; width: 128px; height: 125px; border-radius: 47% 53% 65% 35%; background: var(--pencil); opacity: .24; transform: rotate(18deg); }
.coat-swatch.calico { background: conic-gradient(var(--orange) 0 28%, var(--ink) 28% 43%, #eed9b8 43% 72%, var(--orange) 72%); }
.coat-swatch.tabby { background: repeating-linear-gradient(115deg, #5f5c57 0 10px, #b7ad98 10px 23px); }
.coat-swatch.black { background: var(--ink); }
.coat-swatch.white { border: 2px solid rgba(48,40,31,.35); background: #fffaf0; }
.coat-swatch.point { background: radial-gradient(circle at 70% 25%, #4f4036 0 18%, #d7b985 19%); }

.word-kind { margin: 0; color: var(--orange); font-size: 11px; font-weight: 800; }
.japanese-word { margin: 8px 0 1px; font-family: var(--display); font-size: clamp(30px, 3.8vw, 43px); font-weight: 800; letter-spacing: -.035em; line-height: 1.25; }
.reading { min-height: 19px; margin: 0; color: #74695e; font-size: 12px; }
.romaji { margin: 14px 0 11px; font-family: var(--display); font-size: clamp(19px, 2.3vw, 25px); font-weight: 700; letter-spacing: .06em; overflow-wrap: anywhere; }
.romaji .typed { color: var(--orange); }
.romaji .remaining { color: rgba(48,40,31,.31); }

.tail-progress { width: 87%; height: 11px; margin: 0 auto; padding: 2px; overflow: hidden; border: 2px solid var(--line); border-radius: 999px; background: #ead9bd; transform: rotate(-.4deg); }
.tail-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--yellow); transition: width 90ms ease; }

.start-button {
  display: flex;
  width: 100%;
  min-height: 50px;
  margin-top: 10px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 2px solid var(--line);
  border-radius: 15px;
  background: var(--yellow);
  font-family: var(--display);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 -4px 0 rgba(209,139,0,.38), 3px 5px 0 rgba(48,40,31,.25);
  transition: transform 90ms ease, box-shadow 90ms ease;
}

.start-button:hover { background: #ffc944; }
.start-button:active { transform: translate(2px, 4px); box-shadow: inset 0 -2px 0 rgba(209,139,0,.3), 1px 1px 0 rgba(48,40,31,.2); }
.button-paw { display: block; width: 27px; height: 27px; padding: 4px; border: 2px solid var(--line); border-radius: 9px; background: var(--paper); }
.type-machine.is-playing .start-button { display: none; }
.type-machine.is-error .word-card { animation: wrong 160ms ease; }
.type-machine.is-correct .typing-cats { animation: cats-cheer 380ms ease; }

.paw-trail { position: absolute; right: -27px; bottom: -29px; display: flex; gap: 7px; transform: rotate(-15deg); }
.paw-trail img { width: 18px; height: 18px; opacity: .25; transform: scale(.72); }
.paw-trail img.is-lit { animation: paw-pop 360ms ease; opacity: 1; }

.cat-note {
  position: relative;
  margin: 8px 2vw 54px;
  padding: 20px 24px;
  border: 2px solid rgba(168,108,73,.45);
  border-radius: 15px 18px 14px 17px;
  background: rgba(255,248,234,.65);
  box-shadow: 3px 4px 0 rgba(168,108,73,.1);
  transform: rotate(.15deg);
}

.cat-note::before { position: absolute; top: -12px; left: 46%; width: 85px; height: 24px; background: rgba(232,135,36,.48); content: ""; transform: rotate(-2deg); }
.note-heading { display: flex; gap: 10px; align-items: center; padding-bottom: 14px; border-bottom: 2px dashed rgba(168,108,73,.25); }
.note-mark { display: grid; width: 42px; height: 42px; place-items: center; border: 2px solid var(--line); border-radius: 12px; background: var(--orange); color: var(--paper); font-family: var(--display); font-size: 15px; font-weight: 800; box-shadow: 2px 3px 0 rgba(48,40,31,.18); }
.note-heading small { color: var(--tan); font-size: 9px; font-weight: 700; }
.note-heading h2 { margin: 1px 0 0; font-family: var(--display); font-size: 16px; }
.memo-count { margin-left: auto; padding: 6px 11px; border: 2px solid var(--line); border-radius: 999px; background: var(--yellow); font-family: var(--display); font-size: 12px; box-shadow: 2px 2px 0 rgba(48,40,31,.15); }
.note-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 13px; }
.note-empty { grid-column: 1 / -1; margin: 0; padding: 14px; color: #76695d; font-size: 11px; text-align: center; }
.note-entry { position: relative; padding: 17px 18px 15px; border: 2px solid rgba(48,40,31,.45); border-radius: 11px 13px 10px 12px; background: #fffaf0; box-shadow: 2px 3px 0 rgba(48,40,31,.09); }
.note-entry:nth-child(3n + 1) { transform: rotate(-.25deg); }.note-entry:nth-child(3n + 2) { transform: rotate(.2deg); }
.note-entry header { display: flex; gap: 8px; align-items: baseline; }
.note-entry h3 { margin: 0; font-family: var(--display); font-size: 15px; }
.note-entry small { color: var(--orange); font-size: 9px; font-weight: 700; }
.note-entry p { margin: 9px 0 11px; color: #65594e; font-size: 11px; line-height: 1.7; }
.note-entry a { color: var(--ink); font-size: 10px; font-weight: 800; text-decoration-color: var(--orange); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.note-entry.is-loading { opacity: .62; }

footer { display: flex; justify-content: space-between; gap: 24px; padding: 25px 0 34px; border-top: 2px dashed rgba(168,108,73,.3); color: #73675c; font-size: 11px; line-height: 1.7; }
footer p { margin: 0; }
.api-note { flex-shrink: 0; max-width: none; text-align: right; white-space: nowrap; }

.result-dialog { width: min(510px, calc(100% - 34px)); max-height: calc(100svh - 28px); padding: 32px 37px; overflow-y: auto; border: 2px solid var(--line); border-radius: 18px; background: var(--paper); color: var(--ink); box-shadow: 7px 9px 0 rgba(48,40,31,.25); text-align: center; }
.result-dialog::backdrop { background: rgba(48,40,31,.5); }
.result-cat { display: grid; width: 103px; height: 77px; margin: 0 auto 15px; place-items: center; border: 2px solid var(--line); border-radius: 50% 50% 42% 42%; background: var(--orange); color: var(--paper); font-weight: 800; box-shadow: 3px 4px 0 rgba(48,40,31,.17); }
.result-kicker { margin: 0 0 8px; color: var(--tan); font-size: 11px; font-weight: 700; }
.result-dialog h2 { margin: 0; font-family: var(--display); font-size: 31px; line-height: 1.35; }
.result-dialog h2 strong { color: var(--orange); font-size: 49px; }
.result-dialog dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 25px 0; }
.result-dialog dl div { padding: 13px 6px; border: 2px solid var(--soft-line); border-radius: 12px; background: #f8e7ca; }
.result-dialog dt { color: #76695d; font-size: 9px; }.result-dialog dd { margin: 3px 0 0; font-family: var(--display); font-size: 20px; font-weight: 800; }
.share-panel { margin: -8px 0 18px; padding: 13px; border: 2px dashed rgba(168,108,73,.35); border-radius: 13px; background: rgba(242,189,50,.08); }
.share-panel > p:first-child { margin: 0 0 9px; color: var(--tan); font-size: 10px; font-weight: 800; }
.share-buttons { display: grid; grid-template-columns: 1.15fr .85fr; gap: 8px; }
.share-buttons button { display: inline-flex; min-height: 42px; gap: 7px; align-items: center; justify-content: center; padding: 8px 10px; border: 2px solid var(--line); border-radius: 11px; background: var(--orange); font-family: var(--display); font-size: 10px; font-weight: 800; box-shadow: 2px 3px 0 rgba(48,40,31,.15); cursor: pointer; }
.share-buttons button:last-child { background: var(--paper); }
.share-buttons button:disabled { opacity: .48; cursor: wait; box-shadow: none; }
.share-buttons button:not(:disabled):hover { transform: translateY(-1px); }
.share-buttons span { font-size: 15px; }
.share-status { margin: 8px 0 0; color: #76695d; font-size: 9px; line-height: 1.5; }
.result-actions { display: grid; grid-template-columns: 1.4fr .6fr; gap: 9px; }
.result-actions button { min-height: 48px; border: 2px solid var(--line); border-radius: 12px; background: var(--paper); font-family: var(--display); font-weight: 800; cursor: pointer; box-shadow: 2px 3px 0 rgba(48,40,31,.17); }
.result-actions button:first-child { background: var(--orange); }

button:focus-visible, a:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; }

@keyframes wrong { 35% { transform: translateX(-7px) rotate(-.1deg); } 70% { transform: translateX(7px) rotate(-.1deg); } }
@keyframes paw-pop { 50% { transform: translateY(-8px) scale(1.15); } }
@keyframes cats-cheer { 50% { transform: translateY(-8px) rotate(-1deg); } }

@media (max-width: 860px) {
  .game-stage { grid-template-columns: 1fr; gap: 72px; padding: 70px 0; }
  .intro { text-align: center; }.mini-guide { justify-content: center; }
  .type-machine { margin: 105px auto 0; }
  .cat-note { margin-inline: 0; }
}

@media (max-width: 540px) {
  .page-shell { width: min(100% - 24px, 1160px); }
  .site-header { min-height: 70px; }.asobi-logo { font-size: 23px; }
  .sound-tools { gap: 5px; }.sound-button { padding-inline: 10px; }.volume-control { padding-inline: 7px; }.volume-control > span, .volume-control output { display: none; }.volume-control input { width: 64px; }
  h1 { font-size: clamp(34px, 9.8vw, 49px); }
  .game-stage { padding-top: 54px; }.type-machine { margin-top: 83px; padding: 18px 13px 20px; border-radius: 17px; }
  .typing-cats { top: -134px; right: 5px; width: 280px; }
  .score-row { gap: 5px; }.score-row > div { min-height: 61px; padding-inline: 4px; }.score-row strong { font-size: 20px; }
  .word-card { min-height: 245px; padding: 31px 12px 22px; }.japanese-word { font-size: 33px; }.romaji { font-size: 20px; }
  .level-options { max-width: 360px; margin-inline: auto; }
  .cat-note { padding: 25px 16px; }.cat-note::before { left: calc(50% - 42px); }.note-list { grid-template-columns: 1fr; }
  .result-dialog { padding: 25px 17px; }.result-dialog dl { gap: 5px; }.share-buttons { grid-template-columns: 1fr; }
  footer { display: block; }.api-note { margin-top: 9px; text-align: left; white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
