:root {
  --site-yellow: #fff1a3;
  --site-green: #d2e4b9;
  --ink: #163b45;
  --teal: #397985;
  --teal-dark: #285b65;
  --paper: #fffef8;
  --shadow: 0 18px 50px rgb(27 71 78 / 18%);
  color-scheme: light;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--site-yellow); }
body {
  margin: 0;
  min-width: 280px;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--site-yellow);
  -webkit-tap-highlight-color: transparent;
}
button, a { font: inherit; }
button { touch-action: manipulation; }
img { max-width: 100%; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.screen-page {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  overflow: hidden;
  background: var(--site-yellow);
}
.screen-page.theme-green { background: var(--site-green); }
.screen-frame {
  position: relative;
  width: min(100vw, 56.25dvh);
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: inherit;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 2%);
  isolation: isolate;
}
.screen-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.screen-tap-target {
  position: absolute;
  z-index: 20;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.screen-tap-target:disabled { cursor: default; }
.screen-tap-target:focus-visible {
  outline: 5px solid #146b85;
  outline-offset: -8px;
}
.screen-action {
  position: absolute;
  z-index: 21;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  min-width: 11rem;
  padding: .78rem 1.35rem;
  transform: translateX(-50%);
  border: 3px solid var(--teal);
  border-radius: 999px;
  color: var(--teal-dark);
  background: rgb(255 255 247 / 94%);
  box-shadow: 0 8px 24px rgb(22 59 69 / 20%);
  font-weight: 800;
  text-align: center;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.screen-action.is-hidden {
  opacity: 0;
  transform: translate(-50%, .35rem);
}

.choice-layer { position: absolute; z-index: 10; inset: 0; }
.choice-button {
  position: absolute;
  left: calc(var(--x) * 100%);
  top: calc(var(--y) * 100%);
  width: calc(var(--w) * 100%);
  height: calc(var(--h) * 100%);
  border: 3px solid transparent;
  border-radius: 28%;
  color: transparent;
  background: rgb(255 255 255 / .001);
  cursor: pointer;
  transition: transform .08s ease, background-color .08s ease, border-color .08s ease;
}
.choice-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; }
.choice-button:active, .choice-button.is-selected {
  transform: scale(.97);
  background: rgb(255 255 255 / 22%);
  border-color: rgb(41 105 117 / 55%);
}
.choice-button:focus-visible {
  outline: 5px solid #146b85;
  outline-offset: 1px;
  border-color: #fff;
}
.choice-button:disabled { cursor: wait; }
.is-debug .choice-button {
  border-color: #e51f50;
  background: rgb(229 31 80 / 15%);
}
.is-debug .choice-button::after {
  content: attr(data-choice);
  position: absolute;
  inset: .35rem auto auto .35rem;
  display: grid;
  width: 1.7rem;
  height: 1.7rem;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #e51f50;
  font-weight: 900;
}

.guide-note {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  width: min(88%, 31rem);
  margin: 0;
  padding: .7rem 1rem;
  transform: translateX(-50%);
  border-radius: 999px;
  color: var(--teal-dark);
  background: rgb(255 255 247 / 92%);
  box-shadow: 0 7px 22px rgb(22 59 69 / 15%);
  font-size: clamp(.72rem, 2.9vw, 1rem);
  font-weight: 800;
  text-align: center;
}

.checking-progress {
  position: absolute;
  z-index: 8;
  left: 12%;
  right: 12%;
  bottom: 8%;
  height: .55rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgb(255 255 255 / 62%);
}
.checking-progress span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  animation: checking 1.1s ease-in-out infinite alternate;
}
@keyframes checking {
  from { transform: translateX(0); }
  to { transform: translateX(138%); }
}
@media (prefers-reduced-motion: reduce) {
  .checking-progress span { animation: none; width: 100%; }
  .screen-action, .choice-button { transition: none; }
}

.score-badge {
  position: absolute;
  z-index: 9;
  left: 50%;
  top: 58.2%;
  display: grid;
  gap: .16rem;
  min-width: 68%;
  padding: .65rem 1rem;
  transform: translateX(-50%);
  border: 3px solid var(--teal);
  border-radius: 999px;
  color: var(--teal-dark);
  background: rgb(255 253 226 / 96%);
  box-shadow: 0 7px 24px rgb(22 59 69 / 16%);
  text-align: center;
}
.score-badge strong { font-size: clamp(1rem, 5vw, 1.65rem); }
.score-badge span { font-size: clamp(.58rem, 2.3vw, .78rem); font-weight: 700; }

.manage-page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 80px;
}
.manage-header {
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid rgb(57 121 133 / 18%);
  border-radius: 28px;
  background: rgb(255 254 248 / 88%);
  box-shadow: var(--shadow);
}
.eyebrow {
  margin: 0 0 .4rem;
  color: var(--teal);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.manage-header h1 { margin: 0; font-size: clamp(2rem, 6vw, 4rem); line-height: 1.1; }
.manage-header > p:not(.eyebrow) { max-width: 48rem; margin: 1rem 0 0; line-height: 1.8; }
.summary-card {
  display: grid;
  grid-template-columns: repeat(6, max-content);
  align-items: baseline;
  gap: .35rem .55rem;
  width: fit-content;
  margin-top: 1.5rem;
  padding: .8rem 1rem;
  border-radius: 18px;
  color: #fff;
  background: var(--teal);
}
.summary-card strong { font-size: 1.55rem; }
.summary-card span { margin-right: .7rem; font-size: .78rem; font-weight: 800; }
.manage-section { margin-top: 42px; }
.manage-section > h2 { margin: 0 0 16px; font-size: 1.45rem; }
.manage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.compact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.manage-card {
  min-width: 0;
  padding: 22px;
  border: 1px solid rgb(57 121 133 / 18%);
  border-radius: 22px;
  background: rgb(255 254 248 / 94%);
  box-shadow: 0 10px 28px rgb(27 71 78 / 10%);
}
.manage-card h2, .manage-card h3, .manage-card h4 { margin: 0; color: #142f36; }
.manage-card h3 { font-size: 1.25rem; line-height: 1.45; }
.compact-card h4 { margin-bottom: .9rem; font-size: 1rem; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.answer-key { margin: 1rem 0 .75rem; font-weight: 800; }
.manage-card code {
  display: block;
  overflow: auto;
  padding: .75rem;
  border-radius: 12px;
  color: #203940;
  background: #eef3e9;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: .76rem;
  white-space: nowrap;
}
.card-actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 1rem; }
.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: .65rem .95rem;
  border: 2px solid var(--teal);
  border-radius: 999px;
  color: var(--teal-dark);
  background: #fff;
  font-size: .86rem;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { transform: translateY(-1px); }
.button:focus-visible { outline: 4px solid rgb(20 107 133 / 28%); outline-offset: 2px; }
.button.primary { color: #fff; background: var(--teal); }
.button.quiet { border-color: #a5b8bc; color: #49666d; }
.button.danger { border-color: #b23737; color: #922929; }
.status-chip {
  flex: 0 0 auto;
  padding: .35rem .65rem;
  border-radius: 999px;
  color: #53676b;
  background: #e9efec;
  font-size: .72rem;
  font-weight: 900;
}
.status-correct { color: #176237; background: #dff2e5; }
.status-incorrect { color: #8a4d16; background: #fff0d8; }
.admin-note {
  margin: 1rem 0 0;
  padding: .8rem .9rem;
  border-left: 4px solid #d58f1f;
  color: #604a20;
  background: #fff5dc;
  font-size: .8rem;
  line-height: 1.65;
}

.instance-section {
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid rgb(57 121 133 / 18%);
  border-radius: 28px;
  background: rgb(255 254 248 / 78%);
  box-shadow: var(--shadow);
}
.instance-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.instance-heading h2 { margin: 0; font-size: clamp(1.55rem, 4vw, 2.35rem); }
.instance-heading p:not(.eyebrow) { max-width: 48rem; margin: .65rem 0 0; line-height: 1.7; }
.instance-status { margin-top: .2rem; }
.status-active { color: #176237; background: #dff2e5; }
.status-draft { color: #785a18; background: #fff1c9; }
.status-archived { color: #5c6264; background: #e8ebec; }
.instance-summary { margin-top: 1.2rem; }
.instance-subsection { margin-top: 30px; }
.instance-subsection > h3 { margin: 0 0 14px; font-size: 1.18rem; }
.instance-operations { padding-top: 4px; }
.default-alias-note {
  margin: 1.1rem 0 0;
  padding: .85rem 1rem;
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  background: rgb(238 243 233 / 85%);
  line-height: 1.65;
}
.default-alias-note code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.empty-note { margin: 0; color: #53676b; }

.operations-card { max-width: 720px; }
.operations-card p { line-height: 1.7; }

.error-page {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
  background: var(--site-yellow);
}
.error-card {
  width: min(560px, 100%);
  padding: 32px;
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow);
}
.error-card h1 { margin: 0 0 1rem; }
.error-card p:last-child { line-height: 1.75; }

@media (max-width: 760px) {
  .manage-page { width: min(100% - 20px, 1120px); padding-top: 16px; }
  .manage-header, .instance-section { border-radius: 22px; }
  .instance-heading { display: grid; }
  .manage-grid, .compact-grid { grid-template-columns: 1fr; }
  .summary-card { grid-template-columns: repeat(3, max-content); }
  .summary-card span { margin-right: .3rem; }
}
