:root {
  --ink: #172b57;
  --muted: #64748b;
  --bg: #f2f5fc;
  --white: #fff;
  --gold: #ffd266;
  --blue: #245bd5;
  --line: #dde5f3;
  --green: #087f5b;
  --red: #b53c3c;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Sans",
    "Yu Gothic",
    sans-serif;
  font-weight: 600;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #faab32;
  outline-offset: 2px;
}
button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}
header {
  background: #172b57;
  color: white;
  padding: 22px 20px 30px;
}
header .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.wrap {
  max-width: 1000px;
  margin: auto;
}
.brand {
  font-size: clamp(24px, 4vw, 38px);
  font-weight: 950;
  letter-spacing: -0.04em;
}
.tag {
  font-size: 13px;
  color: #d9e5ff;
  margin-top: 4px;
}
.rank {
  min-width: 130px;
  text-align: right;
  font-size: 13px;
}
.rank strong {
  color: var(--gold);
  font-size: 20px;
  display: block;
}
.meter {
  background: #ffffff35;
  height: 7px;
  border-radius: 20px;
  margin-top: 7px;
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  background: var(--gold);
  border-radius: 20px;
}
main {
  padding: 0 16px 45px;
  max-width: 1032px;
  margin: auto;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: white;
  border-radius: 18px;
  padding: 6px;
  margin: -14px 0 22px;
  box-shadow: 0 5px 20px #172b5711;
  position: relative;
}
.tabs button {
  border: 0;
  background: white;
  color: var(--muted);
  padding: 13px 6px;
  border-radius: 12px;
  font-size: clamp(12px, 2.5vw, 16px);
  font-weight: 850;
}
.tabs button.active {
  background: var(--ink);
  color: white;
}
.panel[hidden] {
  display: none;
}
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: 0 3px 12px #172b5708;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: clamp(23px, 4vw, 32px);
  font-weight: 950;
}
h2 {
  font-size: 21px;
  font-weight: 900;
}
h3 {
  font-size: 17px;
}
p.sub {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
  margin-top: 6px;
}
.sectionlabel {
  display: block;
  font-size: 13px;
  font-weight: 850;
  margin: 20px 0 9px;
  color: var(--muted);
}
.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.choice {
  background: #f5f7fc;
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 11px;
  color: var(--ink);
  font-weight: 800;
}
.choice.selected {
  background: #e5edff;
  border: 2px solid var(--blue);
  padding: 9px 13px;
  color: #1647ac;
}
.levels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}
.level {
  background: white;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  padding: 13px 10px;
  text-align: left;
  min-height: 84px;
}
.level b {
  display: block;
  font-size: 15px;
}
.level small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  margin-top: 3px;
}
.level.selected {
  background: #eaf0ff;
  border: 2px solid var(--blue);
  padding: 12px 9px;
}
.primary,
.secondary {
  border: 0;
  border-radius: 12px;
  padding: 13px 20px;
  font-weight: 850;
}
.primary {
  background: var(--blue);
  color: white;
  box-shadow: 0 3px 0 #163e99;
}
.secondary {
  background: #edf2fc;
  color: var(--ink);
  border: 1px solid var(--line);
}
.wide {
  width: 100%;
  margin-top: 18px;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.between {
  justify-content: space-between;
}
.pill {
  font-size: 13px;
  background: #edf2fc;
  padding: 6px 11px;
  border-radius: 20px;
  color: var(--ink);
}
.track {
  height: 9px;
  border-radius: 10px;
  background: #e9eef7;
  overflow: hidden;
  margin: 13px 0;
}
.track i {
  display: block;
  height: 100%;
  background: var(--blue);
  transition: width 0.2s;
}
.question {
  text-align: center;
  font-size: clamp(34px, 8vw, 72px);
  font-weight: 950;
  margin: 23px 0 20px;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}
.answer {
  display: block;
  width: 100%;
  max-width: 390px;
  margin: 0 auto;
  text-align: center;
  border: 2px solid #c4d1ec;
  border-radius: 15px;
  font-size: 35px;
  padding: 9px 12px;
  color: var(--ink);
  background: #f8faff;
  min-height: 64px;
}
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 390px;
  margin: 12px auto;
}
.keypad button {
  height: 50px;
  border: 1px solid var(--line);
  background: #f0f4fc;
  border-radius: 11px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 850;
}
.keypad .enter {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
.feedback {
  min-height: 35px;
  text-align: center;
  font-weight: 850;
  font-size: 17px;
  padding: 8px 0;
}
.good {
  color: var(--green);
}
.bad {
  color: var(--red);
}
.center {
  text-align: center;
}
.resultnum {
  font-size: 64px;
  font-weight: 950;
  color: var(--blue);
  line-height: 1.2;
}
.resultgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin: 20px 0;
}
.stat {
  background: #f0f4fc;
  border-radius: 13px;
  padding: 13px 4px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.stat b {
  display: block;
  color: var(--ink);
  font-size: 25px;
}
.tablewrap {
  overflow: auto;
  max-height: 65vh;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 14px;
  background: #f0f4fc;
}
table {
  border-collapse: separate;
  border-spacing: 3px;
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
}
th {
  background: #172b57;
  color: white;
  position: sticky;
  top: 0;
  z-index: 2;
  min-width: 43px;
  height: 39px;
  font-size: 13px;
  border-radius: 5px;
}
th:first-child {
  left: 0;
  z-index: 3;
}
tbody th {
  z-index: 1;
  left: 0;
  top: auto;
}
td {
  padding: 0;
}
td button {
  width: 100%;
  min-width: 43px;
  height: 43px;
  border: 1px solid #dbe4f4;
  border-radius: 6px;
  background: white;
  color: #9aabc7;
  font-size: 15px;
  font-weight: 850;
  display: block;
}
td button.revealed {
  background: #fff2c8;
  color: #624000;
  border-color: #eac45d;
}
td button.mastered {
  background: #d8f4e7;
  color: #075b41;
  border-color: #9bdabb;
}
.field {
  flex: 1;
  min-width: 125px;
}
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}
.field select {
  width: 100%;
  padding: 11px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: white;
}
.audio-display {
  background: #eff3fc;
  border-radius: 16px;
  text-align: center;
  padding: 25px 10px;
  margin: 20px 0;
}
.audio-display .question {
  margin: 10px 0;
  font-size: clamp(28px, 6vw, 48px);
}
.audio-answer {
  font-size: 26px;
  font-weight: 900;
  color: var(--blue);
  min-height: 38px;
}
.note {
  font-size: 12px;
  line-height: 1.65;
  color: var(--muted);
  margin-top: 10px;
}
.history {
  padding: 0;
  list-style: none;
  margin: 12px 0 0;
}
.history li {
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
footer {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 20px;
}
.hide {
  display: none !important;
}
@media (max-width: 520px) {
  header {
    padding: 17px 15px 26px;
  }
  .rank {
    min-width: 96px;
  }
  .rank strong {
    font-size: 15px;
  }
  .tag {
    font-size: 11px;
  }
  .card {
    padding: 16px;
    border-radius: 16px;
  }
  .levels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .choice {
    padding: 9px 11px;
  }
  .choice.selected {
    padding: 8px 10px;
  }
  .tabs {
    margin-bottom: 15px;
  }
  .question {
    margin: 15px 0;
  }
  .keypad button {
    height: 47px;
  }
  main {
    padding: 0 10px 32px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

.tips-intro {
  background: linear-gradient(120deg, #172b57, #245bd5);
  color: white;
}
.tips-intro .sub {
  color: #e4edff;
}
.tips-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.tips-menu {
  display: grid;
  gap: 8px;
}
.tips-menu button {
  text-align: left;
  font-size: 16px;
}
.tips-menu .completed::after {
  content: " ✓";
  color: var(--green);
}
.tips-copy {
  line-height: 1.8;
  font-size: 16px;
  margin: 12px 0;
}
.tips-steps {
  padding-left: 24px;
  line-height: 1.9;
  font-size: 18px;
  overflow-wrap: anywhere;
}
.tips-box {
  padding: 16px;
  background: #eff3fc;
  border-radius: 14px;
  margin: 16px 0;
}
.tips-box summary {
  cursor: pointer;
  font-size: 16px;
}
.tips-equation {
  font-size: clamp(20px, 4vw, 30px);
  font-weight: 850;
  overflow-wrap: anywhere;
  margin: 12px 0;
}
.tips-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.tips-form input {
  width: 130px;
  max-width: 100%;
  padding: 10px;
  border: 2px solid #c4d1ec;
  border-radius: 10px;
  font-size: 22px;
}
.tips-message {
  min-height: 28px;
  margin: 12px 0;
  line-height: 1.6;
}
.square-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.square-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #f5f7fc;
}
.square-flip {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 16px 4px;
  background: #fff;
  color: var(--ink);
  font-size: 23px;
  min-height: 105px;
}
.square-flip span {
  display: block;
  color: var(--blue);
  margin-top: 8px;
}
.square-card label {
  display: block;
  font-size: 14px;
  margin-top: 12px;
}
.tips-sources {
  line-height: 1.8;
  font-size: 14px;
}
.tips-sources a {
  color: var(--blue);
}
@media (max-width: 650px) {
  .tips-layout {
    grid-template-columns: 1fr;
  }
  .tips-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tabs {
    grid-template-columns: repeat(2, 1fr);
  }
  .square-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.danger {
  color: var(--red);
  border-color: var(--red);
  background: #fff;
}

ruby {
  ruby-align: center;
}
rt {
  font-size: 0.58em;
  font-weight: 500;
  line-height: 1;
}
button:has(ruby),
.tips-copy:has(ruby),
.note:has(ruby) {
  line-height: 2;
}
.reading-controls {
  margin: 0 0 20px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}
.reading-controls select {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: white;
  font: inherit;
}
[data-explanation] {
  margin: 8px 6px 8px 0;
}

.explore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.explore-topic {
  padding: 18px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: #f5f7fc;
}
.explore-topic:hover {
  background: #e5edff;
}
.explore-title {
  display: block;
  font-size: 18px;
  font-weight: 850;
}
.explore-topic .note {
  display: block;
}
.explore-choices {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}
.explore-choices button {
  min-height: 54px;
  text-align: left;
  font-size: 18px;
}
#explorereflection {
  display: block;
  width: 100%;
  font: inherit;
  padding: 12px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
}
.explore-picture {
  display: flex;
  justify-content: center;
  padding: 20px 8px;
  background: #f0f4fc;
  border-radius: 16px;
  margin: 16px 0;
}
.learn-clock {
  position: relative;
  width: 200px;
  height: 200px;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: white;
}
.clock-number {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 18px;
}
.clock-hand {
  position: absolute;
  bottom: 50%;
  left: calc(50% - 3px);
  width: 6px;
  border-radius: 4px;
  transform-origin: 50% 100%;
}
.clock-hand.hour {
  height: 48px;
  background: var(--ink);
}
.clock-hand.minute {
  height: 70px;
  background: var(--blue);
  width: 4px;
  left: calc(50% - 2px);
}
.fraction-strip {
  display: flex;
  width: 100%;
  max-width: 320px;
}
.fraction-strip span {
  flex: 1;
  height: 65px;
  display: grid;
  place-items: center;
  background: white;
  border: 2px solid var(--ink);
  color: var(--muted);
}
.fraction-strip .filled {
  background: var(--blue);
  color: white;
}
.learn-shape.triangle {
  width: 130px;
  height: 120px;
  background: var(--blue);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.learn-shape.square {
  width: 90px;
  height: 90px;
  background: var(--blue);
  transform: rotate(30deg);
  margin: 20px;
}
.block-row {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.learn-block {
  width: 44px;
  height: 44px;
  border: 3px solid var(--ink);
  background: var(--gold);
}
.learn-graph {
  max-width: 100%;
}
.graph-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.graph-row > span:first-child {
  width: 64px;
  flex-shrink: 0;
}
.graph-bars {
  display: flex;
  width: 120px;
  gap: 2px;
}
.graph-unit {
  width: 27px;
  height: 28px;
  background: var(--blue);
  border: 1px solid var(--ink);
}
@media (max-width: 380px) {
  .explore-grid {
    grid-template-columns: 1fr;
  }
  .graph-bars {
    width: 96px;
  }
  .graph-unit {
    width: 22px;
  }
  .graph-row {
    gap: 4px;
  }
}
