/* がんばり賞状メーカー（sup/award。旧 sup/certificate） */
:root {
  --teal: #0c8599;
  --teal-dark: #08606e;
  --font-ui: 'M PLUS Rounded 1c', 'Gowun Dodum', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'BIZ UDPGothic', 'Meiryo', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  /* 鳳凰・オリジナル枠：明朝体（端末の明朝 → 教科書体 → 総称） */
  --font-mincho: 'Hiragino Mincho ProN', 'Yu Mincho', 'YuMincho', 'BIZ UDPMincho', 'Noto Serif JP', 'Noto Serif CJK JP', 'MS PMincho', 'Klee One', serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background-color: #f4f4f4;
  font-family: var(--font-ui);
  color: #333;
  padding: calc(76px + env(safe-area-inset-top, 0px)) 16px calc(30px + env(safe-area-inset-bottom, 0px));
  position: relative;
}

/* UI要塞化（スクロールする ページなので 高さも 0 に） */
.hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
  z-index: -1 !important;
  position: absolute !important;
  max-height: 0 !important; max-width: 0 !important;
  overflow: hidden !important;
}

.lang-slot {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: calc(10px + env(safe-area-inset-right, 0px));
  z-index: 100;
}

/* ---------- 操作パネル ---------- */
#control-panel {
  background: #fff;
  max-width: 820px;
  margin: 0 auto 30px;
  padding: 30px 34px;
  border-radius: 20px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  border: 4px solid #66d9e8;
  position: relative;
}
.panel-title { text-align: center; color: var(--teal); font-size: 1.7rem; margin: 0 0 18px; font-weight: 800; }
.security-info {
  background: #f8f9fa; border: 2px solid #ddd; border-radius: 10px;
  padding: 12px 16px; margin-bottom: 24px; font-size: 0.92rem; line-height: 1.7;
}
.security-info p { margin: 0 0 4px; }
.security-badge { display: inline-block; background: var(--teal); color: #fff; padding: 1px 8px; border-radius: 4px; font-size: 0.8rem; }
.security-alert { color: #c2255c; font-weight: 700; font-size: 0.85rem; }
.form-group { margin-bottom: 22px; }
.form-group > label { display: block; font-weight: 800; margin-bottom: 8px; font-size: 1.1rem; color: #444; }
.small-label { font-weight: 700; font-size: 0.95rem; }
.theme-box { background: #e0f7fa; padding: 14px; border-radius: 10px; }
select, input[type="text"], textarea, input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  min-height: 48px;
  border: 2px solid #ddd;
  border-radius: 10px;
  font-size: 1rem;
  font-family: var(--font-ui);
  background: #fff;
  color: #333;
}
input[type="text"] + input[type="text"] { margin-top: 6px; }
select:focus, input:focus, textarea:focus { border-color: #66d9e8; background: #f0fbff; outline: none; }
textarea { height: 180px; line-height: 1.6; resize: vertical; }
textarea.short { height: 110px; }
.help-box {
  background: #eef; padding: 12px 16px; border-radius: 10px;
  border-left: 5px solid #66d9e8; font-size: 0.9rem; line-height: 1.7; margin-bottom: 8px;
}
.help-box strong { color: var(--teal); }
.help-box ul { margin: 4px 0 0; padding-left: 1.2em; }
.hint { font-size: 0.85rem; color: #666; margin: 0 0 6px; }
.custom-frame-area { background: #fff3cd; padding: 12px; border-radius: 10px; border: 2px solid #ffeeba; margin-top: 10px; }
.inline-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.inline-row select { width: auto; min-width: 140px; }
.btn-area { text-align: center; margin-top: 30px; }
.main-btn {
  background-color: var(--teal); color: #fff; border: none; padding: 14px 40px; min-height: 60px;
  font-size: 1.25rem; border-radius: 50px; cursor: pointer; font-weight: 800; font-family: var(--font-ui);
  box-shadow: 0 5px 0 var(--teal-dark);
}
.main-btn:active { transform: translateY(5px); box-shadow: none; }
.main-btn:focus-visible { outline: 3px solid var(--teal-dark); outline-offset: 3px; }

.preview-msg {
  text-align: center; margin: 0 auto 10px; font-weight: 700; color: #c2255c;
  background: #fff; padding: 14px; max-width: 820px; border-radius: 12px; position: relative;
}
.preview-msg p { margin: 0 0 10px; }

/* 画面での見本：はばが たりないときは 横にスクロール */
.preview-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- 賞状 ---------- */
.sheet {
  width: 297mm; height: 209mm;
  background: #fff;
  position: relative;
  overflow: hidden;
  margin: 30px auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  display: flex; justify-content: center; align-items: center;
  padding: 15mm;
  page-break-after: always;
  break-after: page;
}
.outer-frame { width: 100%; height: 100%; position: relative; display: flex; justify-content: center; align-items: center; }
.inner-frame {
  width: calc(100% - 20px); height: calc(100% - 20px);
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 5;
}

/* テーマA：鳳凰 */
.theme-phoenix { font-family: var(--font-mincho); }
.theme-phoenix .outer-frame {
  border: 10px solid #b8860b;
  border-image: linear-gradient(45deg, #bf953f, #fcf6ba, #b38728, #fbf5b7, #aa771c) 1;
}
.theme-phoenix .inner-frame { border: 2px solid #b38728; outline: 1px solid #b38728; outline-offset: -6px; }
.theme-phoenix .corner { position: absolute; width: 70px; height: 70px; border: 4px solid #b38728; background: #fff; z-index: 10; }
.theme-phoenix .corner.tl { top: -5px; left: -5px; border-right: none; border-bottom: none; border-radius: 10px 0 0 0; }
.theme-phoenix .corner.tr { top: -5px; right: -5px; border-left: none; border-bottom: none; border-radius: 0 10px 0 0; }
.theme-phoenix .corner.bl { bottom: -5px; left: -5px; border-right: none; border-top: none; border-radius: 0 0 0 10px; }
.theme-phoenix .corner.br { bottom: -5px; right: -5px; border-left: none; border-top: none; border-radius: 0 0 10px 0; }
.theme-phoenix .corner::after { content: "❀"; position: absolute; color: #d4af37; font-size: 30px; line-height: 1; }
.theme-phoenix .corner.tl::after { top: 8px; left: 8px; }
.theme-phoenix .corner.tr::after { top: 8px; right: 8px; }
.theme-phoenix .corner.bl::after { bottom: 8px; left: 8px; }
.theme-phoenix .corner.br::after { bottom: 8px; right: 8px; }
.phoenix-container {
  position: absolute; top: -70px; left: 50%; transform: translateX(-50%);
  width: 350px; height: 160px; z-index: 20;
  display: flex; justify-content: center; align-items: center;
}
.phoenix-img {
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff) drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff);
}

/* テーマB：パステルリボン */
.theme-ribbon { font-family: var(--font-ui); color: #444; }
.theme-ribbon .outer-frame { border: 8px solid #ff99cc; border-radius: 20px; background: #fff; }
.theme-ribbon .inner-frame { width: calc(100% - 24px); height: calc(100% - 24px); border: 3px dashed #666; border-radius: 12px; }
.ribbon-container {
  position: absolute; top: -65px; left: 50%; transform: translateX(-50%);
  width: 400px; height: 130px; z-index: 20;
  display: flex; justify-content: center; align-items: center;
}
.ribbon-img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.15)); }
.pastel-corner { position: absolute; width: 30px; height: 30px; background: #ffcc00; border: 2px solid #444; border-radius: 50%; z-index: 10; }
.pastel-corner.tl { top: 12px; left: 12px; }
.pastel-corner.tr { top: 12px; right: 12px; }
.pastel-corner.bl { bottom: 12px; left: 12px; }
.pastel-corner.br { bottom: 12px; right: 12px; }

/* テーマC：オリジナル枠 */
.theme-custom { font-family: var(--font-mincho); }
.custom-frame-bg { position: absolute; inset: 0; z-index: 0; }
.custom-frame-bg img { width: 100%; height: 100%; object-fit: fill; }

/* 中身 */
.content-area {
  margin-top: 70px; text-align: center; width: 92%;
  flex-grow: 1; display: flex; flex-direction: column; align-items: center;
  position: relative; z-index: 10;
}
.custom-watermark {
  position: absolute; top: 250px; bottom: 50px; left: 10%; right: 10%;
  opacity: 0.15; pointer-events: none; z-index: -1;
  display: flex; justify-content: center; align-items: center;
}
.custom-watermark img { width: 100%; height: 100%; object-fit: contain; }
.award-title { font-size: 60px; margin: 0 0 20px; letter-spacing: 5px; font-weight: 700; line-height: 1.1; }
.award-name-box { margin-bottom: 25px; border-bottom: 2px solid #aaa; padding: 0 20px 5px; min-width: 400px; display: inline-block; }
.award-name { font-size: 52px; font-weight: 700; }
.name-suffix { font-size: 32px; margin-left: 15px; }
.award-text { font-size: 30px; line-height: 2.0; margin-bottom: auto; white-space: pre-wrap; width: 100%; }
.footer { display: flex; justify-content: space-between; align-items: flex-end; width: 95%; margin: 0 auto 30px; }
.date { font-size: 26px; }
.sender { text-align: left; font-size: 26px; }
.sender-name { font-size: 38px; margin-top: 10px; display: block; }

@page { size: A4 landscape; margin: 0; }

@media (max-width: 700px) {
  body { padding-top: calc(120px + env(safe-area-inset-top, 0px)); padding-left: 8px; padding-right: 8px; }
  .lang-slot { top: calc(66px + env(safe-area-inset-top, 0px)); }
  #control-panel { padding: 20px 16px; }
}

@media print {
  html, body {
    height: auto !important; overflow: visible !important; margin: 0; padding: 0 !important; background: none;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  #control-panel, .preview-msg, .lang-slot { display: none !important; }
  .preview-scroll { overflow: visible !important; }
  #preview-container { display: block !important; width: 100%; margin: 0; padding: 0; overflow: visible !important; }
  .sheet { margin: 0 auto; box-shadow: none; border: none; overflow: visible !important; }
  .sheet:last-child { page-break-after: auto; break-after: auto; }
}
