* {
  box-sizing: border-box;
}

:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d8e0ec;
  --blue: #1358c8;
  --blue-soft: #eef5ff;
  --gold: #f6c84c;
  --green: #138f5a;
  --red: #d94932;
  --shadow: 0 14px 34px rgba(23, 32, 51, 0.1);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", "Meiryo", system-ui, sans-serif;
}

a,
button {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  border: 0;
}

.shell {
  width: min(100%, 960px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px;
}

.home-stage,
.quiz-stage {
  width: 100%;
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 0 8px;
}

.account-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
}

.brand-link,
.nav-button,
.ghost-button,
.primary-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 900;
}

.brand-link,
.nav-button,
.ghost-button {
  padding: 8px 13px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--blue);
}

.brand-link {
  color: var(--ink);
}

.nav-button {
  min-height: 38px;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}

.login-button {
  background: #ffffff;
  color: var(--blue);
}

.register-button,
.logout-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.logout-button {
  cursor: pointer;
}

.ghost-button {
  cursor: pointer;
}

.primary-button {
  min-width: 150px;
  padding: 10px 18px;
  background: var(--blue);
  color: #ffffff;
  cursor: pointer;
}

.home-screen {
  display: grid;
  align-content: start;
  gap: 18px;
  justify-items: center;
}

.logo-frame {
  width: min(100%, 760px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  box-shadow: var(--shadow);
}

.logo-frame img {
  display: block;
  width: 100%;
  aspect-ratio: 1536 / 1024;
  object-fit: cover;
}

.menu-panel {
  width: min(100%, 720px);
  display: grid;
  gap: 10px;
}

.login-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.start-button,
.level-button {
  width: 100%;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(23, 32, 51, 0.08);
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.start-button {
  min-height: 56px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 10px 16px;
  border-color: rgba(246, 200, 76, 0.72);
  background: linear-gradient(180deg, #fff8d9, var(--gold));
}

.start-button span,
.level-button span {
  color: var(--ink);
  font-size: clamp(20px, 3.2vw, 28px);
  font-weight: 950;
  line-height: 1.1;
}

.start-button strong,
.level-button strong {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.level-button {
  min-height: 72px;
  align-content: center;
  padding: 10px 14px;
}

.level-button.beginner {
  border-top: 4px solid var(--green);
}

.level-button.beginner span {
  color: var(--green);
}

.level-button.intermediate {
  border-top: 4px solid var(--blue);
}

.level-button.intermediate span {
  color: var(--blue);
}

.level-button.advanced {
  border-top: 4px solid var(--red);
}

.level-button.advanced span {
  color: var(--red);
}

.start-button:hover,
.level-button:hover,
.primary-button:hover,
.ghost-button:hover,
.brand-link:hover,
.nav-button:hover {
  transform: translateY(-1px);
  border-color: var(--blue);
  box-shadow: 0 12px 26px rgba(23, 32, 51, 0.12);
}

.screen {
  width: min(100%, 760px);
  margin: 0 auto;
}

.hidden {
  display: none;
}

.quiz-head {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.quiz-head div,
.result-summary > div,
.review-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.quiz-head div {
  min-height: 62px;
  display: grid;
  place-items: center;
  padding: 8px;
}

.quiz-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.quiz-head strong {
  font-size: 22px;
}

.quiz-head strong span {
  font: inherit;
}

.timer {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.timer div {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--gold), var(--red));
  transition: width 0.2s linear;
}

.word-card {
  position: relative;
  display: grid;
  min-height: 220px;
  place-items: center;
  align-content: center;
  margin: 18px 0;
  padding: 28px 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.word-card p {
  margin: 0 0 10px;
  color: var(--blue);
  font-weight: 900;
}

.word-card h1 {
  max-width: 100%;
  margin: 0;
  overflow-wrap: normal;
  word-break: keep-all;
  white-space: nowrap;
  font-size: clamp(30px, 6.8vw, 56px);
  line-height: 1;
  text-align: center;
}

.sound-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 22px;
  font-weight: 950;
  cursor: pointer;
}

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

.choice-button {
  min-height: 72px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: clamp(17px, 3.6vw, 22px);
  font-weight: 900;
  line-height: 1.3;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(23, 32, 51, 0.08);
}

@media (hover: hover) and (pointer: fine) {
  .choice-button:hover:not(:disabled) {
    border-color: var(--blue);
    background: var(--blue-soft);
  }
}

.choice-button:focus {
  outline: none;
}

.choice-button:focus-visible {
  outline: 3px solid rgba(19, 88, 200, 0.18);
  outline-offset: 2px;
}

.choice-button.correct {
  border-color: rgba(19, 143, 90, 0.45);
  background: #e9f9f1;
  color: #09603a;
}

.choice-button.wrong {
  border-color: rgba(217, 73, 50, 0.45);
  background: #fff0ec;
  color: #932717;
}

.choice-button:disabled {
  cursor: default;
}

.feedback {
  min-height: 28px;
  margin: 14px 0 8px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 950;
  text-align: center;
}

.feedback.good {
  color: var(--green);
}

.feedback.bad {
  color: var(--red);
}

.result-screen {
  text-align: center;
}

.audio-start-screen {
  text-align: center;
}

.audio-start-card {
  display: grid;
  gap: 14px;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.audio-start-card h1 {
  margin: 0;
  font-size: clamp(28px, 7vw, 44px);
}

.audio-start-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 900;
  line-height: 1.7;
}

.result-kicker {
  margin: 0 0 8px;
  color: var(--blue);
  font-weight: 950;
}

.result-screen h1 {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: clamp(30px, 6vw, 52px);
}

.score-ring {
  width: min(52vw, 190px);
  height: min(52vw, 190px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  margin: 0 auto 16px;
  border: 10px solid #eef2f7;
  border-top-color: var(--blue);
  border-right-color: var(--gold);
  border-bottom-color: var(--green);
  border-radius: 50%;
  background: #ffffff;
}

.score-ring strong {
  font-size: 28px;
}

.score-ring span {
  color: var(--muted);
  font-weight: 900;
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.result-summary > div {
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px;
}

.result-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.result-summary strong {
  font-size: 18px;
}

.review-list {
  display: grid;
  gap: 7px;
  max-height: 170px;
  overflow-y: auto;
  margin-bottom: 16px;
  text-align: left;
}

.review-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
}

.review-item strong {
  color: var(--blue);
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-stage {
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
}

.auth-card {
  width: min(100%, 520px);
  display: grid;
  gap: 14px;
  margin: 0 auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0 0 4px;
  font-size: clamp(28px, 5vw, 42px);
}

.auth-card label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 900;
}

.auth-card input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.auth-card input:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(19, 88, 200, 0.14);
}

.auth-help,
.auth-message,
.save-status,
.user-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.auth-message {
  min-height: 20px;
}

.auth-message.success,
.save-status.success {
  color: var(--green);
}

.auth-message.error,
.save-status.error {
  color: var(--red);
}

.wide-button {
  width: 100%;
}

.save-status {
  margin: -2px auto 12px;
  text-align: center;
}

.user-status {
  max-width: 46vw;
  overflow: hidden;
  padding: 4px 0;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-footer {
  padding: 8px 0 0;
  text-align: center;
}

.site-footer a {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--blue);
}

@media (max-width: 680px) {
  .shell {
    padding: 12px;
  }

  .home-stage,
  .quiz-stage,
  .auth-stage {
    min-height: calc(100vh - 24px);
  }

  .level-grid,
  .choices,
  .result-summary {
    grid-template-columns: 1fr;
  }

  .start-button {
    grid-template-columns: 1fr;
  }

  .level-button {
    min-height: 58px;
  }

  .quiz-head {
    gap: 6px;
  }

  .topbar {
    gap: 8px;
  }

  .account-actions {
    flex: 0 0 auto;
  }

  .nav-button,
  .ghost-button {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 12px;
  }

  .user-status {
    max-width: 38vw;
    font-size: 13px;
  }

  .quiz-head div {
    min-height: 52px;
    padding: 6px;
  }

  .quiz-head strong {
    font-size: 17px;
  }

  .quiz-head strong span {
    font: inherit;
  }

  .word-card {
    min-height: 154px;
    padding: 22px 52px 22px 18px;
  }

  .word-card h1 {
    font-size: clamp(28px, 8vw, 40px);
  }

  .choice-button {
    min-height: 58px;
  }
}
