:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1f2528;
  --muted: #667175;
  --line: #d8dddc;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --danger: #b42318;
  --soft: #eef4f2;
  --shadow: 0 18px 48px rgba(31, 37, 40, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
}

a {
  color: var(--accent-dark);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 0.6rem 0.95rem;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 0.55rem 0.7rem;
}

textarea {
  resize: vertical;
}

label span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.86rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.75rem;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 650;
  white-space: nowrap;
}

code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.86em;
}

.kicker {
  margin: 0 0 0.25rem;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.paper-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.paper-page.narrow {
  place-items: center;
}

.display-panel {
  width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: clamp(24px, 5vw, 56px);
  box-shadow: var(--shadow);
}

.display-panel h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.08;
}

.topic-text {
  margin: 1.5rem 0 0;
  font-size: clamp(2rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1.16;
}

.number-text {
  margin: 0.5rem 0 0;
  font-size: clamp(7rem, 28vw, 18rem);
  font-weight: 900;
  line-height: 0.95;
  color: var(--accent-dark);
  text-align: center;
}

.card-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vw, 28px);
  background: #141414;
}

.ito-card {
  position: relative;
  width: min(92vw, 560px, calc((100vh - 72px) * 0.748));
  aspect-ratio: 766 / 1024;
  filter: drop-shadow(0 20px 42px rgba(0, 0, 0, 0.38));
  outline: none;
  transition: transform 120ms ease, filter 120ms ease;
}

.ito-card[role="button"] {
  cursor: pointer;
  touch-action: manipulation;
}

.ito-card[role="button"]:focus-visible {
  filter: drop-shadow(0 20px 42px rgba(0, 0, 0, 0.38)) drop-shadow(0 0 0.75rem rgba(255, 255, 255, 0.7));
}

.ito-card[role="button"]:active,
.ito-card.is-drawing {
  transform: scale(0.985);
}

.ito-card-base {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}

.number-card-value {
  position: absolute;
  inset: 14% 9% 26% 9%;
  display: grid;
  place-items: center;
  color: #181c1f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(7.5rem, 28vw, 14rem);
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.number-card-value.is-updated {
  animation: number-pop 180ms ease-out;
}

.number-card-value.is-one-digit {
  font-size: clamp(9rem, 34vw, 17rem);
}

.number-card-value.is-three-digits {
  font-size: clamp(5.4rem, 22vw, 10.5rem);
}

@keyframes number-pop {
  0% {
    transform: scale(0.96);
    opacity: 0.74;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.topic-card-text {
  position: absolute;
  inset: 17% 12% 19% 12%;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-size: clamp(1.35rem, 5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.18;
  text-align: center;
  text-wrap: balance;
}

.paper-image {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  border-radius: 6px;
  background: var(--soft);
}

.rulebook-body {
  font-size: 1.08rem;
}

.message-text {
  color: var(--muted);
  font-size: 1.2rem;
}

.public-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.public-links a {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.55rem 0.8rem;
  background: var(--soft);
  text-decoration: none;
}

.admin-login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 32px;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0 0 1.5rem;
}

.login-panel button {
  width: 100%;
  margin-top: 1rem;
}

.form-error,
.notice {
  border: 1px solid #f1b8b2;
  border-radius: 6px;
  background: #fff4f2;
  color: var(--danger);
  padding: 0.7rem 0.85rem;
}

.admin-body {
  min-height: 100vh;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 24px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: white;
}

.admin-header h1 {
  margin: 0;
  font-size: 1.6rem;
}

.ghost-button {
  border-color: var(--line);
  background: white;
  color: var(--ink);
}

.ghost-button:hover {
  background: var(--soft);
  color: var(--ink);
}

.admin-shell {
  width: min(1180px, calc(100% - 36px));
  margin: 28px auto 56px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  border-color: var(--line);
  background: white;
  color: var(--ink);
}

.tab.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.notice-list {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab-panel {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: clamp(18px, 3vw, 28px);
  box-shadow: 0 10px 30px rgba(31, 37, 40, 0.08);
}

.tab-panel.is-active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.2rem;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(120px, 180px) minmax(260px, 2fr) auto;
  gap: 0.8rem;
  align-items: end;
  margin-bottom: 1.25rem;
}

.compact-form {
  grid-template-columns: minmax(220px, 1fr) minmax(130px, 180px) auto;
}

.wide-field {
  min-width: 0;
}

.stack-form {
  display: grid;
  gap: 1rem;
}

.stack-form button {
  justify-self: start;
}

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

.thumb {
  width: 72px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--soft);
}

.inline-input {
  min-width: 220px;
  border-color: transparent;
  background: #f7f9f8;
}

.code-input {
  min-width: 120px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.actions button,
.actions a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 0.35rem 0.6rem;
  text-decoration: none;
}

.actions button:hover,
.actions a:hover {
  background: var(--soft);
}

.is-muted {
  color: var(--muted);
  opacity: 0.72;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.issued-url {
  display: grid;
  gap: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  padding: 0.85rem;
  margin-bottom: 1rem;
}

.link-list {
  display: grid;
  gap: 0.75rem;
}

.link-row {
  display: grid;
  gap: 0.15rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.75rem;
}

@media (max-width: 800px) {
  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .editor-grid,
  .compact-form {
    grid-template-columns: 1fr;
  }

  .tab-panel {
    padding: 16px;
  }

  .display-panel {
    padding: 24px;
  }
}
