:root {
  --bg: #f3f7fb;
  --ink: #2b2b3a;
  --main: #e8394d;
  --main-dark: #b8202f;
  --sub: #2b6fd6;
  --green: #4cbf6b;
  --card: #ffffff;
  --muted: #7a7a8c;
  --radius: 16px;
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", "Meiryo", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.8;
}
a { color: var(--sub); }
img { max-width: 100%; }

/* ---------- header / footer ---------- */
.site-header {
  background: linear-gradient(90deg, #1f7a4d, #2b6fd6);
  color: #fff;
  box-shadow: 0 3px 0 rgba(0,0,0,.08);
}
.site-header .inner {
  max-width: 1080px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.logo { color: #fff; text-decoration: none; font-weight: 900; font-size: 1.35rem; letter-spacing: .03em; }
.logo span { font-size: .8rem; display: block; font-weight: 700; opacity: .9; line-height: 1.2; }
.site-nav a { color: #fff; text-decoration: none; font-weight: 700; margin-left: 14px; font-size: .95rem; }
.site-nav a:hover { text-decoration: underline; }

.site-footer {
  margin-top: 48px; padding: 24px 16px; background: #2b2b3a; color: #ddd; text-align: center; font-size: .85rem;
}
.site-footer a { color: #fff; margin: 0 8px; }

main { max-width: 1080px; margin: 0 auto; padding: 16px; }

/* ---------- game ---------- */
.game-wrap { position: relative; max-width: 960px; margin: 8px auto 0; }
#game {
  width: 100%; aspect-ratio: 2 / 1; display: block;
  border-radius: var(--radius);
  box-shadow: 0 6px 0 #d9c9a3, 0 10px 24px rgba(0,0,0,.12);
  background: #7fd3ff;
  touch-action: manipulation;
}
.overlay {
  position: absolute; inset: 0; border-radius: var(--radius);
  display: none; align-items: center; justify-content: center; flex-direction: column;
  background: rgba(20, 24, 50, .72); color: #fff; text-align: center; padding: 16px;
}
.overlay.show { display: flex; }
.overlay h1, .overlay h2 { margin: 0 0 6px; line-height: 1.3; text-shadow: 0 3px 0 rgba(0,0,0,.3); }
.overlay h1 { font-size: clamp(1.4rem, 4.2vw, 2.6rem); }
.overlay h2 { font-size: clamp(1.2rem, 3.5vw, 2rem); }
.overlay p { margin: 4px 0; font-size: clamp(.8rem, 1.8vw, 1rem); }
.select-row { display: flex; gap: 8px; margin: 6px 0; flex-wrap: wrap; justify-content: center; }
.select-row .label { align-self: center; font-weight: 700; margin-right: 4px; font-size: .9rem; }
.chip {
  border: 3px solid #fff; background: transparent; color: #fff; font-family: inherit;
  font-weight: 800; font-size: clamp(.8rem, 1.8vw, 1rem);
  padding: 4px 14px; border-radius: 999px; cursor: pointer;
}
.chip.on { background: #fff; color: var(--ink); }
.btn {
  display: inline-block; border: none; cursor: pointer; font-family: inherit; font-weight: 900;
  background: var(--main); color: #fff; font-size: clamp(1rem, 2.4vw, 1.4rem);
  padding: 8px 32px; border-radius: 999px; margin: 8px 6px 0;
  box-shadow: 0 5px 0 var(--main-dark); text-decoration: none;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--main-dark); }
.btn.sub { background: var(--sub); box-shadow: 0 5px 0 #237fc4; }
.btn.x { background: #111; box-shadow: 0 5px 0 #000; font-size: clamp(.8rem, 1.8vw, 1rem); padding: 6px 18px; }
.best { font-size: .85rem; opacity: .9; }
.result-grid {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 20px; max-width: 600px; margin: 6px 0;
  font-size: clamp(.8rem, 1.8vw, 1.05rem);
}
.result-grid b { font-size: 1.25em; color: #ffe066; }
.rank { font-size: clamp(1rem, 2.6vw, 1.5rem); color: #ffe066; font-weight: 900; }
.newrecord { color: #ff6b9d; font-weight: 900; animation: blink .6s infinite alternate; }
@keyframes blink { from { opacity: 1; } to { opacity: .4; } }

.toolbar { max-width: 960px; margin: 10px auto 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .9rem; }
.toolbar button { font-family: inherit; border: 2px solid #ccb98a; background: #fff; border-radius: 999px; padding: 2px 14px; cursor: pointer; font-weight: 700; }



.ad-slot { max-width: 970px; margin: 40px auto; text-align: center; min-height: 0; }
.ad-slot .ad-label { font-size: .7rem; color: var(--muted); display: block; }

/* ---------- content / article ---------- */
.content { max-width: 820px; margin: 0 auto; }
.card { background: var(--card); border-radius: var(--radius); padding: 22px 26px; margin: 22px 0; box-shadow: 0 3px 0 #eadfc4; }
.card h2, .article h2 {
  font-size: 1.35rem; margin: 0 0 12px; padding: 4px 0 4px 14px; border-left: 8px solid var(--main); line-height: 1.5;
}
.article h3 { font-size: 1.15rem; margin: 26px 0 8px; border-bottom: 3px dotted #f3c79f; padding-bottom: 2px; }
.article h1 { font-size: clamp(1.4rem, 4vw, 2rem); line-height: 1.45; margin: 10px 0 6px; }
.meta { color: var(--muted); font-size: .85rem; }
.pr-label { display: inline-block; background: #eee; color: #555; font-size: .75rem; padding: 0 8px; border-radius: 4px; margin-right: 6px; }
.toc { background: #fffdf5; border: 2px solid #f3e2b6; border-radius: 12px; padding: 12px 20px; }
.toc ol { margin: 4px 0; }
.point { background: #fff3e6; border-radius: 12px; padding: 12px 18px; margin: 14px 0; }
.point::before { content: "💡 ポイント"; display: block; font-weight: 900; color: var(--main-dark); }
.cta {
  text-align: center; background: linear-gradient(135deg, #ffefd9, #e3f4ff); border-radius: var(--radius); padding: 22px; margin: 28px 0;
}
.product {
  background: var(--card); border: 3px solid #f3e2b6; border-radius: var(--radius); padding: 18px 22px; margin: 18px 0;
}
.product .ptitle { font-size: 1.15rem; font-weight: 900; margin: 0 0 4px; }
.product .tag { display: inline-block; background: var(--green); color: #fff; font-size: .75rem; font-weight: 800; padding: 0 10px; border-radius: 999px; margin-right: 6px; }
.product ul { margin: 6px 0; padding-left: 1.2em; }
.aff-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.aff { flex: 1 1 180px; text-align: center; text-decoration: none; color: #fff; font-weight: 900; padding: 10px; border-radius: 10px; }
.aff.amazon { background: #ff9900; box-shadow: 0 4px 0 #c77700; }
.aff.rakuten { background: #bf0000; box-shadow: 0 4px 0 #8a0000; }
table.compare { width: 100%; border-collapse: collapse; font-size: .9rem; background: #fff; }
table.compare th, table.compare td { border: 1px solid #e5dcc4; padding: 8px; text-align: center; }
table.compare th { background: #fff3e0; }
.table-scroll { overflow-x: auto; }
.faq dt { font-weight: 900; margin-top: 12px; }
.faq dt::before { content: "Q. "; color: var(--main); }
.faq dd { margin: 4px 0 0 0; }
.faq dd::before { content: "A. "; color: var(--sub); font-weight: 900; }

@media (max-width: 640px) {
  .site-nav a { margin-left: 8px; font-size: .85rem; }
  .numpad { grid-template-columns: repeat(4, 54px); grid-template-rows: repeat(5, 50px); }
  .card { padding: 18px; }
}


.overlay { overflow-y: auto; }

/* ---------- 漢字特急 ---------- */
#game { background: #9fdcff; box-shadow: 0 6px 0 #c9d6e3, 0 10px 24px rgba(0,0,0,.12); }
.card { box-shadow: 0 3px 0 #dbe4ee; }
.card h2, .article h2 { border-left-color: #1f7a4d; }
.chip small { font-size: .7em; margin-left: 4px; opacity: .8; }
.chip:disabled { opacity: .35; cursor: not-allowed; }
.level-note { font-size: clamp(.7rem, 1.5vw, .85rem) !important; opacity: .85; }
.answer-row { display: none; max-width: 960px; margin: 10px auto 0; gap: 8px; align-items: center; }
#kana-input {
  flex: 1; font-family: inherit; font-size: 1.4rem; font-weight: 800; padding: 8px 14px;
  border: 3px solid #1f7a4d; border-radius: 12px; min-width: 0; background: #fff;
}
#kana-input.bad { border-color: #e8394d; background: #fff1f3; }
.answer-row button, .toolbar button { font-family: inherit; }
.answer-row button { border: none; border-radius: 12px; background: #ffd166; font-weight: 900; font-size: 1rem; padding: 10px 14px; box-shadow: 0 4px 0 #d9a93a; cursor: pointer; }
.keys-help { max-width: 960px; margin: 12px auto 0; background: #fff; border-radius: var(--radius); padding: 10px 18px; font-size: .9rem; box-shadow: 0 3px 0 #dbe4ee; }
.keys-help kbd { display: inline-block; min-width: 1.8em; text-align: center; background: #f0f0f5; border: 1px solid #ccc; border-bottom-width: 3px; border-radius: 6px; padding: 0 6px; font-family: inherit; font-weight: 800; }
.missed { max-width: 560px; width: 100%; margin: 6px auto; background: rgba(255,255,255,.12); border-radius: 12px; padding: 6px 12px; }
.missed p { margin: 0 0 4px !important; font-weight: 800; color: #ffd166; }
.missed ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: center; }
.missed li b { font-size: 1.15em; margin-right: 4px; }
.missed li span { opacity: .85; font-size: .9em; }
.r-where { font-size: clamp(1rem, 2.6vw, 1.5rem); color: #ffe066; font-weight: 900; }
table.wordlist { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.wordlist th, table.wordlist td { border-bottom: 1px solid #e3e9f0; padding: 4px 8px; text-align: left; }
table.wordlist th { background: #eef5ee; }

/* ---------- name / ranking ---------- */
.overlay { overflow-y: auto; }
.name-row input {
  font-family: inherit; font-size: clamp(.9rem, 2vw, 1.1rem); font-weight: 800; width: 11em;
  border: 3px solid #fff; border-radius: 999px; padding: 3px 14px; text-align: center; color: var(--ink);
}
.name-row input.bad { border-color: #ff6b9d; }
.name-note { font-size: clamp(.7rem, 1.5vw, .85rem) !important; opacity: .9; }
.name-note.err { color: #ffb3c9; font-weight: 800; opacity: 1; }
.r-ranking { font-weight: 800; color: #9ff0b5; font-size: clamp(.8rem, 1.9vw, 1.05rem); min-height: 1.4em; }
.ranking { max-width: 960px; margin: 14px auto 0; background: var(--card); border-radius: var(--radius); padding: 12px 20px; box-shadow: 0 3px 0 #eadfc4; }
.ranking-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.ranking h2 { font-size: 1.15rem; margin: 0; }
.ranking h2 small { font-size: .8rem; color: var(--muted); font-weight: 700; }
.ranking-tabs button { font-family: inherit; font-weight: 800; border: 2px solid var(--main); background: #fff; color: var(--main-dark); border-radius: 999px; padding: 2px 16px; cursor: pointer; margin-left: 4px; }
.ranking-tabs button.on { background: var(--main); color: #fff; }
.ranking-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .95rem; }
.ranking-table th { background: #fff3e0; font-size: .8rem; padding: 4px 8px; border-bottom: 2px solid #f3c79f; white-space: nowrap; }
.ranking-table td { padding: 5px 8px; border-bottom: 1px solid #f0e6cc; text-align: center; }
.ranking-table tbody tr:nth-child(even) td { background: #fffaf0; }
.ranking-table td.no { width: 4.5em; font-weight: 900; color: var(--muted); }
.ranking-table tr:nth-child(-n+3) td.no { color: var(--main-dark); font-size: 1.1em; }
.ranking-table td.nm { text-align: left; font-weight: 800; max-width: 12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-table td.sc { text-align: right; font-weight: 900; white-space: nowrap; }
.ranking-table td.st { width: 5em; color: var(--muted); }
.ranking-table tr.me td { background: #fff3c4; }
.ranking-table tr.empty td { color: var(--muted); text-align: center; background: none; padding: 12px 8px; }
.ranking-note { font-size: .75rem; color: var(--muted); margin: 6px 0 0; }
.spec th { width: 34%; white-space: nowrap; } .spec td { text-align: left; }
.ranking-table th:nth-child(2) { text-align: left; } .ranking-table th:nth-child(3) { text-align: right; }


.ranking-tabs button { border-color: #1f7a4d; color: #1f7a4d; }
.ranking-tabs button.on { background: #1f7a4d; color: #fff; }
.ranking-table th { background: #eef5ee; border-bottom-color: #9fd3b3; }
.r-calc { font-size: clamp(.7rem, 1.5vw, .85rem) !important; opacity: .85; }
main > .ranking { order: 4; }

/* タッチ端末：かなで こたえる らん を出す */
@media (hover: none) and (pointer: coarse) {
  .answer-row { display: flex; }
  .keys-help { display: none; }
}
@media (max-width: 700px), (hover: none) and (pointer: coarse) {
  main { display: flex; flex-direction: column; }
  main > * { order: 9; }
  main > .game-wrap { order: 1; scroll-margin-top: 4px; width: 100%; }
  main > .answer-row { order: 2; }
  main > .toolbar { order: 3; justify-content: center; }
  .toolbar .tip { display: none; }
}
@media (max-width: 700px) {
  main { padding: 8px; }
  .answer-row { display: flex; }
  .game-wrap.menu #game { display: none; }
  .game-wrap.menu .overlay.show {
    position: relative; inset: auto; min-height: 300px; padding: 18px 12px;
    background: linear-gradient(160deg, #1f5a7a, #14183a); overflow: visible;
  }
  .overlay h1 { font-size: 1.6rem; }
  .overlay p, .chip, .select-row .label { font-size: .9rem; }
  .btn { font-size: 1.15rem; }
}
