:root {
  color-scheme: light;
  --ink: #17191d;
  --muted: #626872;
  --line: #d9dde3;
  --line-strong: #bfc5ce;
  --surface: #ffffff;
  --surface-subtle: #f5f6f8;
  --brand: #d71920;
  --brand-dark: #a90f15;
  --success: #087f5b;
  --success-bg: #e6f6ef;
  --warning: #9a5b00;
  --warning-bg: #fff3d6;
  --danger-bg: #fff0f0;
  --focus: #1565c0;
  --shadow: 0 10px 30px rgba(18, 20, 24, 0.08);
  font-family: "Segoe UI", "Yu Gothic UI", "Noto Sans JP", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--surface-subtle);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
input,
select,
textarea,
.button-link {
  border-radius: 6px;
}

button {
  min-height: 38px;
  border: 1px solid transparent;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.button-link:focus-visible {
  outline: 3px solid rgba(21, 101, 192, 0.22);
  outline-offset: 1px;
  border-color: var(--focus);
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
}

textarea {
  min-height: 82px;
  resize: vertical;
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--brand);
}

.hidden {
  display: none !important;
}

.copy-helper {
  position: fixed;
  left: 0;
  bottom: 0;
  opacity: 0;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  overflow: hidden;
  background: #111216;
  border-radius: 7px;
}

.brand-mark img {
  width: 38px;
  height: 38px;
}

.brand-name {
  margin: 0;
  font-size: 18px;
  font-weight: 750;
}

.brand-context {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.primary,
.secondary,
.danger,
.quiet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  white-space: nowrap;
}

.primary {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.primary:hover {
  background: var(--brand-dark);
}

.secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
}

.secondary:hover,
.quiet:hover {
  background: #eceff3;
}

.danger {
  color: #a20e14;
  background: var(--danger-bg);
  border-color: #efb9bc;
}

.quiet {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.small {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #3c424b;
  background: #e9ecf0;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status.active,
.status.redeemed,
.status.sent {
  color: var(--success);
  background: var(--success-bg);
}

.status.expired,
.status.processing,
.status.failed {
  color: var(--warning);
  background: var(--warning-bg);
}

.status.revoked,
.status.suspended {
  color: #a20e14;
  background: var(--danger-bg);
}

.field {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
}

.field > span,
.fieldset-title {
  font-size: 13px;
  font-weight: 700;
}

.hint,
.muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.required::after {
  margin-left: 4px;
  color: var(--brand);
  content: "必須";
  font-size: 10px;
  font-weight: 700;
}

.checkbox-row,
.game-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.checkbox-row > span,
.game-option > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.game-option {
  min-height: 42px;
  padding: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.game-option span {
  overflow-wrap: anywhere;
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: #a20e14;
  font-size: 13px;
}

.notice {
  padding: 12px 14px;
  color: #33404d;
  background: #eef5fb;
  border-left: 3px solid var(--focus);
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 36px));
}

.toast {
  padding: 12px 14px;
  color: #fff;
  background: #25282e;
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.toast.error {
  background: #9f171c;
}

/* Administrator */
.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

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

.login-panel h1 {
  margin: 28px 0 6px;
  font-size: 23px;
}

.login-panel form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 70px;
  padding: 12px max(20px, calc((100vw - 1440px) / 2));
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--line);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.app-tabs {
  display: flex;
  gap: 4px;
  padding: 0 max(20px, calc((100vw - 1440px) / 2));
  overflow-x: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.tab-button {
  min-width: 104px;
  padding: 13px 16px 11px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  font-weight: 700;
}

.tab-button[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--brand);
}

.admin-main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px 20px 52px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 24px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.metric {
  min-width: 0;
  padding: 15px 18px;
  background: var(--surface);
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 4px;
  font-size: 24px;
  font-weight: 750;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading h1,
.section-heading h2 {
  margin: 0;
  font-size: 21px;
}

.section-heading p {
  margin: 4px 0 0;
}

.admin-section {
  display: grid;
  gap: 24px;
}

.panel {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.panel-title {
  margin: 0 0 16px;
  font-size: 16px;
}

.invite-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.span-2 {
  grid-column: span 2;
}

.span-4 {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.invite-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.invite-result p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--success);
  font-weight: 700;
}

.table-tools {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.table-tools input {
  width: min(360px, 100%);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

th {
  position: sticky;
  top: 0;
  color: #464c55;
  background: #f0f2f5;
  font-size: 12px;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

td {
  font-size: 13px;
}

.cell-title {
  display: block;
  margin-bottom: 3px;
  font-weight: 700;
}

.cell-subtitle {
  display: block;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 170px;
}

.empty {
  padding: 28px !important;
  color: var(--muted);
  text-align: center;
}

/* Recipient */
.invite-page {
  background: #eceff2;
}

.invite-header {
  display: flex;
  align-items: center;
  min-height: 72px;
  padding: 12px max(20px, calc((100vw - 980px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.invite-main {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 32px 20px 54px;
}

.invite-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(360px, 1.2fr);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.invite-summary {
  min-width: 0;
  padding: 28px;
  color: #f7f8fa;
  background: #181a1f;
}

.invite-summary h1 {
  margin: 0 0 10px;
  font-size: 24px;
}

.invite-summary .muted {
  color: #b9bec7;
}

.invite-summary dl {
  display: grid;
  gap: 15px;
  margin: 26px 0 0;
}

.invite-summary dt {
  color: #aeb4be;
  font-size: 12px;
}

.invite-summary dd {
  margin: 4px 0 0;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.invite-form-panel {
  min-width: 0;
  padding: 28px;
}

.invite-form-panel h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.recipient-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.recipient-form .primary {
  width: 100%;
  min-height: 44px;
}

.state-panel {
  min-height: 330px;
  padding: 40px 28px;
  text-align: center;
}

.state-symbol {
  display: grid;
  width: 54px;
  height: 54px;
  margin: 0 auto 18px;
  place-items: center;
  color: #fff;
  background: var(--success);
  border-radius: 50%;
  font-size: 26px;
  font-weight: 800;
}

.state-panel.error .state-symbol {
  background: var(--brand);
}

.state-panel h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.state-panel p {
  max-width: 560px;
  margin: 8px auto;
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 980px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .invite-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .span-4 {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .app-header {
    align-items: flex-start;
    padding: 10px 14px;
  }

  .brand-context,
  .header-actions .secondary span {
    display: none;
  }

  .app-tabs {
    padding: 0 10px;
  }

  .admin-main {
    padding: 18px 12px 40px;
  }

  .invite-form-grid,
  .invite-layout {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-4 {
    grid-column: 1;
  }

  .game-options {
    grid-template-columns: 1fr;
  }

  .invite-result {
    grid-template-columns: 1fr;
  }

  .invite-result p {
    grid-column: 1;
  }

  .form-actions,
  .section-heading,
  .table-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .form-actions button,
  .table-tools input {
    width: 100%;
  }

  .invite-main {
    padding: 18px 10px 36px;
  }

  .invite-summary,
  .invite-form-panel {
    padding: 22px 18px;
  }
}
