* {
  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;
}

.auth-shell {
  width: min(100%, 560px);
}

.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;
  flex-wrap: wrap;
  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,
.account-button,
.admin-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

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

.admin-button {
  border-color: var(--gold);
  background: var(--gold);
  color: #473400;
}

.logout-button {
  cursor: pointer;
}

.ghost-button {
  cursor: pointer;
}

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

.danger-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--red);
  color: #ffffff;
  font-weight: 950;
  cursor: pointer;
}

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

.logo-frame {
  width: min(100%, 760px);
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  box-shadow: var(--shadow);
}

.logo-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

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

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

.section-label {
  width: 100%;
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 950;
  letter-spacing: 0.02em;
  text-align: left;
}

.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: 50px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 9px 15px;
  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(18px, 2.7vw, 24px);
  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(4, minmax(0, 1fr));
  gap: 10px;
}

.level-button {
  min-height: 62px;
  align-content: center;
  padding: 8px 12px;
}

.level-button.master {
  border-top: 4px solid #1f2937;
}

.level-button.master span {
  color: #1f2937;
}

.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);
}

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

.class-rankings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.ranking-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(23, 32, 51, 0.06);
}

.ranking-card h2 {
  margin: 0;
  padding: 10px 12px 8px;
  border-bottom: 1px solid #eef2f7;
  color: var(--ink);
  font-size: 14px;
  font-weight: 950;
}

.ranking-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 8px 0;
  border-bottom: 1px solid #eef2f7;
}

.ranking-card-head h2 {
  padding: 0;
  border-bottom: 0;
}

.ranking-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
}

.ranking-tab {
  min-height: 26px;
  padding: 4px 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 950;
  cursor: pointer;
}

.ranking-tab.active {
  background: var(--blue);
  color: #ffffff;
}

.ranking-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ranking-list li {
  min-height: 36px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid #f1f4f8;
}

.ranking-list li:last-child {
  border-bottom: 0;
}

.ranking-rank {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 950;
}

.ranking-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-score {
  color: var(--ink);
  font-size: 13px;
  font-weight: 950;
  white-space: nowrap;
}

.ranking-empty {
  display: block !important;
  min-height: 36px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.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 5px;
  color: var(--blue);
  font-weight: 950;
}

.result-screen h1 {
  margin: 0 0 9px;
  color: var(--ink);
  font-size: clamp(28px, 5vw, 44px);
}

.score-ring {
  width: min(44vw, 160px);
  height: min(44vw, 160px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  margin: 0 auto 10px;
  border: 8px 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: 25px;
}

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

.rank-badge {
  width: min(100%, 360px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -3px auto 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(23, 32, 51, 0.06);
}

.rank-badge span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 950;
}

.rank-badge strong {
  color: var(--blue);
  font-size: 18px;
  font-weight: 950;
}

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

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

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

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

.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;
  margin-top: 4px;
}

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

.manage-screen {
  width: min(100%, 760px);
  display: grid;
  gap: 12px;
  margin: 0 auto;
}

.admin-shell .manage-screen {
  width: min(100%, 1080px);
}

.manage-heading h1 {
  margin: 0;
  font-size: clamp(28px, 6vw, 42px);
  line-height: 1.05;
}

.manage-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(23, 32, 51, 0.06);
}

.manage-card h2 {
  margin: 0;
  font-size: 18px;
}

.manage-card label {
  display: grid;
  gap: 5px;
  font-size: 13px;
  font-weight: 900;
}

.manage-card small,
.auth-card small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.manage-card input {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
}

.profile-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.profile-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eef2f7;
}

.profile-list dt {
  color: var(--muted);
  font-weight: 900;
}

.profile-list dd {
  margin: 0;
  font-weight: 950;
}

.danger-card {
  border-color: rgba(217, 73, 50, 0.28);
  background: #fffafa;
}

.danger-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 900;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  padding: 9px 8px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-weight: 950;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.mini-button {
  min-height: 30px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 950;
  cursor: pointer;
}

.danger-mini {
  background: #fff0ec;
  color: var(--red);
}

.admin-detail-title {
  margin: 0;
  font-weight: 950;
}

.session-list {
  display: grid;
  gap: 7px;
}

.session-item {
  padding: 8px 10px;
  border: 1px solid #eef2f7;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 900;
}

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

.compact-auth-stage {
  min-height: calc(100svh - 36px);
  grid-template-rows: auto auto auto;
  align-content: center;
  gap: 12px;
}

.compact-auth-stage .topbar {
  min-height: 36px;
  padding-bottom: 0;
}

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

.login-card {
  width: min(100%, 380px);
  gap: 8px;
  padding: 16px;
  border-color: #e6edf6;
  box-shadow: 0 10px 26px rgba(23, 32, 51, 0.09);
}

.login-card .result-kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.auth-card h1 {
  margin: -3px 0 2px;
  font-size: clamp(24px, 5vw, 34px);
  line-height: 1.05;
}

.login-card h1 {
  margin: -2px 0 4px;
  font-size: clamp(24px, 7vw, 30px);
}

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

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

.login-card label {
  gap: 4px;
  font-size: 12px;
}

.login-card input {
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 7px;
}

.login-card .auth-message {
  min-height: 15px;
  font-size: 12px;
}

.login-card .primary-button {
  min-height: 39px;
  padding: 8px 14px;
  margin-top: 1px;
}

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

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

.auth-rule {
  font-size: 11px;
}

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

.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: min(62vw, 360px);
  display: grid;
  gap: 2px;
  overflow: visible;
  padding: 4px 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
}

.user-status strong,
.user-status span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-status span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.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,
  .account-stage {
    min-height: calc(100vh - 24px);
  }

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

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

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

  .ranking-card h2 {
    padding: 9px 11px 7px;
  }

  .ranking-card-head {
    flex-wrap: wrap;
    padding: 9px 11px 8px 0;
  }

  .ranking-list li {
    min-height: 34px;
    padding: 6px 11px;
  }

  .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: 58vw;
    font-size: 12px;
  }

  .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;
  }

  .result-kicker {
    margin-bottom: 3px;
    font-size: 12px;
  }

  .result-screen h1 {
    margin-bottom: 6px;
    font-size: 26px;
  }

  .score-ring {
    width: min(38vw, 132px);
    height: min(38vw, 132px);
    gap: 2px;
    margin-bottom: 7px;
    border-width: 7px;
  }

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

  .score-ring span {
    font-size: 12px;
  }

  .rank-badge {
    margin-bottom: 7px;
    padding: 7px 10px;
  }

  .rank-badge strong {
    font-size: 16px;
  }

  .result-summary {
    gap: 6px;
    margin-bottom: 6px;
  }

  .result-summary > div {
    min-height: 42px;
    gap: 2px;
    padding: 6px;
  }

  .result-summary span {
    font-size: 11px;
  }

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

  .save-status {
    margin-bottom: 7px;
    font-size: 11px;
  }

  .result-actions .primary-button,
  .result-actions .ghost-button {
    min-height: 34px;
    padding: 7px 12px;
    font-size: 12px;
  }

  .auth-card {
    gap: 9px;
    padding: 15px;
  }

  .auth-card input {
    min-height: 40px;
  }

  .compact-auth-stage {
    min-height: calc(100svh - 24px);
    align-content: start;
    gap: 10px;
  }

  .login-card {
    width: min(100%, 360px);
    gap: 7px;
    padding: 14px;
  }

  .login-card input {
    min-height: 37px;
  }

  .login-card .primary-button {
    min-height: 38px;
  }

  .manage-card {
    padding: 13px;
  }

  .admin-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}
