:root {
  --paper: #faf9f6;
  --ink: #1c1c1c;
  --line: #2b2b2b;
  --gray: #6b6b6b;
  --gray-light: #dedad2;
  --bg: #ececea;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100svh;
  padding: 28px 18px 40px;
  display: flex;
  flex-direction: column;
}

.app-header {
  text-align: center;
  margin-bottom: 28px;
}

.app-title {
  font-size: 22px;
  line-height: 1.4;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
}

.sp-only { display: none; }
@media (max-width: 360px) {
  .sp-only { display: inline; }
}

.app-sub {
  font-size: 13px;
  color: var(--gray);
  margin: 0;
  letter-spacing: 0.03em;
}

.hidden { display: none !important; }

/* 入力画面 */
#form-screen {
  background: var(--paper);
  border: 1px solid var(--gray-light);
  border-radius: 4px;
  padding: 28px 20px;
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--gray);
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}

.name-input {
  width: 100%;
  font-size: 16px;
  font-family: inherit;
  padding: 12px 10px;
  border: none;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  margin-bottom: 24px;
  border-radius: 0;
}
.name-input:focus { outline: none; border-bottom: 2px solid var(--ink); }

.primary-btn {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-family: inherit;
  letter-spacing: 0.1em;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 2px;
  cursor: pointer;
}
.primary-btn:disabled {
  background: var(--gray-light);
  border-color: var(--gray-light);
  color: #9c9890;
  cursor: not-allowed;
}

/* 発行演出 */
#issuing-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
}
.issuing-box { text-align: center; }

.stamp-anim {
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  transform: scale(2.6) rotate(-14deg);
  opacity: 0;
  animation: stampDown 0.55s cubic-bezier(.2,.9,.3,1) forwards;
}
@keyframes stampDown {
  0%   { transform: scale(2.6) rotate(-14deg); opacity: 0; }
  60%  { transform: scale(0.92) rotate(-14deg); opacity: 1; }
  80%  { transform: scale(1.08) rotate(-14deg); }
  100% { transform: scale(1) rotate(-14deg); opacity: 1; }
}

.issuing-text {
  font-size: 13px;
  color: var(--gray);
  letter-spacing: 0.1em;
}

/* 許可証 */
.certificate {
  position: relative;
  background: var(--paper);
  border: 2px solid var(--ink);
  padding: 30px 20px 24px;
  margin-top: 4px;
}

.cert-corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid var(--ink);
}
.cert-corner.tl { top: 6px; left: 6px; border-right: none; border-bottom: none; }
.cert-corner.tr { top: 6px; right: 6px; border-left: none; border-bottom: none; }
.cert-corner.bl { bottom: 6px; left: 6px; border-right: none; border-top: none; }
.cert-corner.br { bottom: 6px; right: 6px; border-left: none; border-top: none; }

.cert-org {
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--gray);
  margin: 0 0 6px;
}

.cert-title {
  text-align: center;
  font-size: 21px;
  letter-spacing: 0.12em;
  margin: 0 0 10px;
  font-weight: 700;
}

.cert-rule {
  width: 56px;
  height: 2px;
  background: var(--ink);
  margin: 0 auto 16px;
}

.cert-number {
  text-align: right;
  font-size: 11px;
  color: var(--gray);
  letter-spacing: 0.03em;
  margin: 0 0 18px;
  font-family: "Courier New", monospace;
}

.cert-name {
  font-size: 16px;
  margin: 0 0 18px;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--gray-light);
  padding-bottom: 10px;
}
#cert-name { font-weight: 700; padding: 0 2px; border-bottom: 1px solid var(--ink); }

.cert-body {
  font-size: 14px;
  line-height: 2;
  margin: 0 0 14px;
  text-align: justify;
}

.cert-note {
  font-size: 13px;
  line-height: 1.9;
  color: #333;
  margin: 0 0 20px;
  text-align: justify;
}

.cert-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-bottom: 22px;
}
.cert-table th, .cert-table td {
  border-top: 1px solid var(--gray-light);
  padding: 8px 4px;
  text-align: left;
  font-weight: normal;
}
.cert-table th {
  width: 92px;
  color: var(--gray);
  letter-spacing: 0.05em;
}
.cert-table tr:last-child th, .cert-table tr:last-child td {
  border-bottom: 1px solid var(--gray-light);
}

.cert-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.cert-footer-text p { margin: 0; }
#cert-org2 {
  font-size: 12px;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.cert-disclaimer {
  font-size: 10px;
  color: #9c9890;
}

.cert-seal {
  flex-shrink: 0;
  width: 58px;
  height: 58px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-9deg);
  opacity: 0.85;
}
.cert-seal span {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.cert-credit {
  text-align: center;
  font-size: 9px;
  color: #b3afa6;
  letter-spacing: 0.1em;
  margin: 18px 0 0;
}

/* 結果画面のボタン */
.result-actions {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.secondary-btn {
  width: 100%;
  padding: 13px;
  font-size: 14px;
  font-family: inherit;
  letter-spacing: 0.08em;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 2px;
  cursor: pointer;
}

.text-btn {
  width: 100%;
  padding: 10px;
  font-size: 13px;
  font-family: inherit;
  letter-spacing: 0.05em;
  background: none;
  color: var(--gray);
  border: none;
  text-decoration: underline;
  cursor: pointer;
}

.save-hint {
  margin: -2px 0 0;
  font-size: 11px;
  color: var(--gray);
  text-align: center;
  letter-spacing: 0.02em;
}

.share-status {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ink);
  text-align: center;
  letter-spacing: 0.02em;
}

.caption-fallback {
  width: 100%;
  margin: 2px 0 0;
  padding: 10px;
  font-size: 12.5px;
  font-family: inherit;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--gray-light);
  border-radius: 2px;
  resize: none;
}

.hidden-canvas {
  position: absolute;
  left: -9999px;
  top: -9999px;
}
