:root {
  color-scheme: light;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: #202a44;
  background: #f4f7ff;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --blue: #5368dd;
  --blue-dark: #3d50bd;
  --ink-soft: #6f7892;
  --panel: #fff;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding: 38px 20px 64px;
  background:
    radial-gradient(ellipse at 8% 5%, #e3eaff 0, transparent 32rem),
    radial-gradient(ellipse at 95% 25%, #e6f8f2 0, transparent 28rem),
    #f4f7ff;
}

.site-header {
  margin: 0 auto 26px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1 {
  margin: 0;
  color: #263455;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: 0.04em;
}

.subtitle {
  margin: 9px 0 0;
  color: var(--ink-soft);
}

main {
  width: min(100%, 1050px);
  margin: 0 auto;
}

.panel {
  padding: 22px;
  border: 1px solid #e7ebf6;
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 12px 35px #35436d12;
}

.controls {
  display: flex;
  align-items: end;
  gap: 14px;
}

.field {
  display: grid;
  flex: 1 1 0;
  gap: 7px;
  min-width: 0;
  color: #59637c;
  font-size: 0.88rem;
  font-weight: 700;
}

select,
input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #dce2f0;
  border-radius: 10px;
  background: #fbfcff;
  color: #283451;
  font: inherit;
  font-size: 0.95rem;
}

select:focus-visible,
input:focus-visible,
button:focus-visible {
  outline: 3px solid #8d9aff;
  outline-offset: 3px;
}

#singleLabel {
  flex: 0 0 105px;
}

#singleLabel[hidden] {
  display: none;
}

.start-button {
  min-height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 10px;
  background: var(--blue);
  color: white;
  font: inherit;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

.start-button:hover {
  transform: translateY(-1px);
  background: var(--blue-dark);
}

.stats {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.stat {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 8px 14px;
  border-radius: 11px;
  background: #f3f5fc;
}

.stat-label {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.stat strong {
  color: #3448b3;
  font-size: 1.08rem;
  font-variant-numeric: tabular-nums;
}

.stat-divider {
  color: #a0a8bc;
  font-weight: 500;
}

.message {
  display: flex;
  flex: 0 0 130px;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 8px;
  border: 1px solid #cdebdc;
  border-radius: 12px;
  background: #edfbf4;
  color: #216b4a;
  font-size: clamp(0.85rem, 2vw, 1.05rem);
  font-weight: 700;
  text-align: center;
}

.message[hidden] {
  display: none;
}

.question-prompt > .message[hidden] {
  display: flex;
  visibility: hidden;
}

.message.is-finish {
  width: min(100%, 520px);
  min-height: 100px;
  margin: 0 auto;
  padding: 20px;
  font-size: 1.1rem;
}

.quiz {
  margin-top: 24px;
}

.empty-state {
  margin: 0;
  padding: 50px 18px;
  border: 1px dashed #cdd5e8;
  border-radius: 16px;
  color: var(--ink-soft);
  text-align: center;
}

.question-prompt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 150px;
  min-height: 150px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid #e7ebf6;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 12px 35px #35436d12;
  color: #293654;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.formula {
  flex: 0 1 auto;
  white-space: nowrap;
  font-size: clamp(2rem, 7vw, 4.5rem);
}

.choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.answer-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 130px;
  padding: 14px;
  border: 2px solid #e3e8f5;
  border-radius: 16px;
  background: #fff;
  color: #293654;
  box-shadow: 0 6px 16px #34436e12;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.answer-card:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: #9aa7f1;
  background: #f8f9ff;
}

.answer-card:disabled {
  cursor: default;
}

.answer-card.is-correct {
  border-color: #82c9a2;
  background: #edfbf4;
  color: #216b4a;
}

.answer-card.is-wrong {
  border-color: #eaa2a2;
  background: #fff1f1;
  color: #9b3434;
}

.answer-number {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.answer-array {
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  gap: 2px;
  width: min(100%, 104px);
  aspect-ratio: 1;
  padding: 6px;
}

.array-dot {
  display: block;
  width: min(100%, 5px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #7182ef;
  place-self: center;
}

@media (max-width: 760px) {
  body {
    padding: 28px 14px 44px;
  }

  .controls {
    flex-wrap: wrap;
  }

  .field {
    flex-basis: calc(50% - 7px);
  }

  #singleLabel {
    flex: 1 1 calc(50% - 7px);
  }

  .start-button {
    flex: 1 1 calc(50% - 7px);
  }

  .choices {
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .panel {
    padding: 16px;
  }

  .stats {
    gap: 7px;
  }

  .stat {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    padding: 8px 10px;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .choices {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .answer-card {
    min-height: 105px;
  }

  .question-prompt {
    gap: 6px;
    padding: 8px;
  }

  .formula {
    font-size: clamp(1.65rem, 8vw, 2.3rem);
  }

  .message {
    flex-basis: 88px;
    min-height: 54px;
    padding: 4px;
    font-size: 0.8rem;
  }
}

@media (max-width: 1024px) and (min-height: 600px) {
  body {
    display: flex;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    flex-direction: column;
    padding: 10px 14px;
  }

  .site-header {
    flex: 0 0 auto;
    margin-bottom: 10px;
  }

  .eyebrow {
    margin-bottom: 0;
    font-size: 0.72rem;
  }

  h1 {
    font-size: clamp(1.45rem, 4vw, 2rem);
  }

  .subtitle {
    margin-top: 2px;
    font-size: 0.82rem;
  }

  main {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
  }

  .panel {
    flex: 0 0 auto;
    padding: 12px;
    border-radius: 14px;
  }

  .controls {
    gap: 8px;
  }

  .field {
    gap: 4px;
    font-size: 0.76rem;
  }

  select,
  input,
  .start-button {
    min-height: 38px;
  }

  select,
  input {
    padding: 0 8px;
    font-size: 0.82rem;
  }

  #singleLabel {
    flex-basis: 82px;
  }

  .start-button {
    padding: 0 14px;
    font-size: 0.86rem;
  }

  .stats {
    gap: 8px;
    margin-top: 9px;
  }

  .stat {
    min-height: 36px;
    padding: 5px 9px;
  }

  .stat-label {
    font-size: 0.72rem;
  }

  .stat strong {
    font-size: 0.95rem;
  }

  .quiz {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    margin-top: 10px;
  }

  .empty-state {
    margin: auto 0;
    padding: 20px 12px;
  }

  .question-prompt {
    flex: 0 0 clamp(90px, 23%, 140px);
    min-height: 0;
    height: auto;
    gap: 8px;
    padding: 8px;
    border-radius: 14px;
  }

  .formula {
    font-size: clamp(1.8rem, 6vw, 3.2rem);
  }

  .message {
    flex-basis: clamp(88px, 18vw, 130px);
    min-height: 0;
    padding: 5px;
    font-size: clamp(0.75rem, 1.8vw, 0.95rem);
  }

  .choices {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 10px;
    gap: 10px;
  }

  .answer-card {
    min-height: 0;
    height: 100%;
    padding: 8px;
    border-radius: 12px;
  }

  .answer-number {
    font-size: clamp(1.6rem, 4vw, 2.5rem);
  }

  .answer-array {
    width: min(100%, 88px);
  }

  .message.is-finish {
    flex: 0 0 auto;
    min-height: 80px;
  }
}

@media (max-width: 760px) and (min-height: 600px) {
  .controls {
    flex-wrap: wrap;
  }

  .field {
    flex-basis: calc(50% - 4px);
  }

  #singleLabel,
  .start-button {
    flex: 1 1 calc(50% - 4px);
  }
}

@media (max-height: 700px) and (min-width: 761px) {
  body {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .site-header {
    margin-bottom: 6px;
  }

  .eyebrow,
  .subtitle {
    display: none;
  }

  h1 {
    font-size: 1.5rem;
  }

  .panel {
    padding: 8px 12px;
  }

  .stats {
    margin-top: 6px;
  }

  .quiz {
    margin-top: 6px;
  }

  .question-prompt {
    flex-basis: 90px;
  }

  .choices {
    margin-top: 6px;
  }
}

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