
:root {
  --cream: #fffaf0;
  --paper: #fffdf8;
  --ink: #35261d;
  --muted: #806f60;
  --line: #e6d2ad;
  --red: #d94436;
  --red-dark: #b93329;
  --gold: #efa928;
  --gold-deep: #b57a10;
  --shadow: 0 16px 40px rgba(76, 52, 29, 0.10);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  line-height: 1.8;
}
button, a { font: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  min-height: 72px; padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.97);
}
.brand { display: flex; align-items: center; min-width: 0; gap: 9px; }
.brand-bird { width: 42px; height: 42px; flex: 0 0 auto; }
.brand-copy { display: block; min-width: 0; writing-mode: horizontal-tb !important; text-orientation: mixed; }
.brand-copy strong, .brand-copy small {
  display: block; white-space: nowrap; word-break: keep-all; writing-mode: horizontal-tb !important;
}
.brand-copy strong { font-size: 16px; line-height: 1.25; letter-spacing: .04em; }
.brand-copy small { margin-top: 2px; color: var(--muted); font-size: 9px; line-height: 1.25; letter-spacing: .1em; }
.header-link { flex: 0 0 auto; color: var(--red-dark); font-size: 12px; font-weight: 800; white-space: nowrap; }

.work-main { padding: 22px 12px 60px; }
.work-shell, .personal-record { width: min(100%, 780px); margin-inline: auto; }

.job-tabs {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 14px;
}
.job-tab {
  min-height: 58px; padding: 7px 3px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--paper); color: var(--muted); font-size: 11px; font-weight: 800;
}
.job-tab.active { border-color: var(--red); background: #fff0ea; color: var(--red-dark); }
.job-tab:disabled { opacity: .62; }

.game-app {
  min-height: 610px; padding: 22px 16px; border: 1px solid var(--line);
  border-radius: 26px; background: var(--paper); box-shadow: var(--shadow);
}
.game-state { display: none; text-align: center; }
.game-state.active { display: block; }

.eyebrow {
  margin: 0 0 7px; color: var(--red-dark); font-size: 12px; font-weight: 900; letter-spacing: .15em;
}
h1, h2, h3 { line-height: 1.4; }
.game-state h1, .game-state h2 { margin: 0 0 16px; }

.ready-visual, .sleep-visual {
  width: min(100%, 540px); margin: 20px auto; overflow: hidden; border-radius: 24px;
  box-shadow: 0 12px 32px rgba(40, 28, 20, .13);
}
.ready-visual img, .sleep-visual img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }

.state-copy, .tap-guide, .sleep-copy { color: var(--muted); font-size: 13px; }

.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 54px;
  padding: 13px 24px; border: 0; border-radius: 999px; font-weight: 900; cursor: pointer; touch-action: manipulation;
}
.button-primary {
  background: linear-gradient(180deg, #e44f42, var(--red));
  color: white; box-shadow: 0 7px 0 var(--red-dark), 0 13px 26px rgba(185, 51, 41, .20);
}
.button-secondary { border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.button:active { transform: translateY(2px); }
.start-shift-button { width: min(100%, 320px); font-size: 18px; letter-spacing: .08em; }

.work-status {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px;
}
.status-card {
  padding: 14px 10px 12px; border: 1px solid var(--line); border-radius: 18px; background: #fff9ef;
}
.status-label {
  display: block; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .04em;
}
.status-main {
  display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin-top: 4px;
}
.status-main strong {
  display: block; font-size: clamp(42px, 9vw, 60px); line-height: .95; font-weight: 900; letter-spacing: -.02em;
}
.status-main small {
  display: block; color: var(--ink); font-size: clamp(18px, 4vw, 24px); line-height: 1.05; font-weight: 900;
}
.status-card-score .status-main strong { color: var(--red-dark); }

.progress-track {
  height: 10px; overflow: hidden; border-radius: 999px; background: #eadfce;
}
.progress-bar {
  width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--red));
  transition: width .16s ease;
}

.mine-stage {
  position: relative; display: block; width: min(100%, 660px); aspect-ratio: 4 / 3; margin: 18px auto 10px; padding: 0;
  overflow: hidden; border: 0; border-radius: 24px; background: #352a22;
  box-shadow: 0 13px 34px rgba(38, 26, 18, .18); cursor: pointer; touch-action: manipulation; user-select: none; -webkit-tap-highlight-color: transparent;
}
.mine-stage.is-cooling { cursor: default; }
.mine-frame {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none;
}
.mine-frame-hit { opacity: 0; transition: opacity 28ms linear; }
.impact-flash {
  position: absolute; left: 19.5%; top: 47%; width: 13%; aspect-ratio: 1; border-radius: 50%; opacity: 0;
  background: radial-gradient(circle, rgba(255,255,217,.92) 0 9%, rgba(255,202,67,.72) 10% 27%, transparent 60%);
  filter: blur(.5px); pointer-events: none;
}
.find-toast {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  max-width: calc(100% - 28px); padding: 4px 12px; border-radius: 999px;
  background: rgba(53, 38, 29, .72); color: #fffaf0; font-size: 12px; font-weight: 800; letter-spacing: .04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; pointer-events: none;
}
.find-toast.show { animation: toastInOut 620ms ease; }
.mine-stage.is-hitting { animation: mineShake 145ms ease-out; }
.mine-stage.is-hitting .mine-frame-hit { opacity: 1; }
.mine-stage.is-hitting .impact-flash { animation: impactFlash 150ms ease-out; }

@keyframes mineShake {
  0%   { transform: translate(0, 0) rotate(0); }
  25%  { transform: translate(-2px, 1px) rotate(-.15deg); }
  55%  { transform: translate(2px, -1px) rotate(.15deg); }
  100% { transform: translate(0, 0) rotate(0); }
}
@keyframes impactFlash {
  0%   { opacity: 0; transform: scale(.45); }
  28%  { opacity: 1; transform: scale(1.12); }
  100% { opacity: 0; transform: scale(.72); }
}
@keyframes toastInOut {
  0%   { opacity: 0; transform: translateX(-50%) translateY(6px); }
  14%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  78%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-4px); }
}

.tap-guide { margin: 0; }
.found-list {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; min-height: 34px; margin: 12px 0 0; padding: 0; list-style: none;
}
.found-list li { padding: 4px 9px; border-radius: 999px; background: #f3eadc; font-size: 11px; }

.result-summary {
  margin: 24px 0 16px; padding: 20px; border-radius: 22px;
}
.deluxe-result {
  position: relative; padding: 26px 18px 22px; border: 2px solid #f1cb67;
  background: linear-gradient(180deg, #fff8da 0%, #ffe8aa 100%);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.42);
}
.result-kicker {
  margin: 0 0 10px; color: #9a6c12; font-size: 11px; font-weight: 900; letter-spacing: .18em;
}
.deluxe-result span {
  display: block; color: #806033; font-size: 14px; font-weight: 800;
}
.deluxe-result strong {
  display: block; margin-top: 2px; color: #5f2d08; font-size: clamp(56px, 13vw, 92px); line-height: .96; font-weight: 900; letter-spacing: -.02em;
}
.deluxe-result em {
  display: block; margin-top: 4px; color: #5f2d08; font-style: normal; font-size: 22px; font-weight: 900; letter-spacing: .12em;
}

.result-items { margin-bottom: 26px; }
.result-items h3 { margin-bottom: 4px; }
.result-items p { color: var(--muted); }

.certificate {
  margin: 20px auto; padding: 22px; text-align: left;
}
.certificate-doc {
  border: 1px solid #d9c79a; border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.55), rgba(255,255,255,.18)),
    linear-gradient(180deg, #fffdf8 0%, #f8f0df 100%);
  box-shadow: 0 16px 34px rgba(76,52,29,.10), inset 0 0 0 6px rgba(255,255,255,.46);
}
.certificate-header {
  display: grid; grid-template-columns: 58px 1fr; gap: 14px; align-items: center;
  padding-bottom: 16px; border-bottom: 1px solid #e7d9b9;
}
.certificate-seal {
  display: grid; place-items: center; width: 58px; height: 58px;
  border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff1bf, #efc052 72%);
  color: #8c5f0e; font-size: 20px; font-weight: 900; box-shadow: inset 0 0 0 3px rgba(255,255,255,.35);
}
.certificate-office {
  margin: 0; color: #8b6a2b; font-size: 12px; font-weight: 900; letter-spacing: .16em;
}
.certificate-title {
  margin: 2px 0 0; color: #3d2b1f; font-size: clamp(26px, 6vw, 36px); font-weight: 900; letter-spacing: .08em;
}
.certificate-subtitle {
  margin: 2px 0 0; color: #9b8363; font-size: 11px; font-weight: 700; letter-spacing: .18em;
}
.certificate-score-panel {
  margin: 16px 0 18px; padding: 18px 16px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,248,218,.95), rgba(255,232,170,.85));
  border: 1px solid #efcf82; text-align: center;
}
.certificate-score-panel span {
  display: block; color: #8a6a34; font-size: 13px; font-weight: 800; letter-spacing: .06em;
}
.certificate-score-panel strong {
  display: block; margin-top: 6px; color: #5f2d08; font-size: clamp(42px, 11vw, 70px); line-height: 1; font-weight: 900; letter-spacing: -.02em;
}
.certificate-score-panel em {
  display: block; margin-top: 2px; color: #5f2d08; font-style: normal; font-size: 18px; font-weight: 900; letter-spacing: .12em;
}
.certificate-detail-list { margin: 0; }
.certificate-detail-list > div {
  display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 10px;
  padding: 10px 0; border-bottom: 1px solid #e7d9b9;
}
.certificate-detail-list dt { color: #826b4e; font-weight: 800; }
.certificate-detail-list dd { min-width: 0; margin: 0; overflow-wrap: anywhere; font-weight: 800; }
.certificate-note {
  margin: 18px 0 14px; color: #5d4a39; font-size: 13px; text-align: center;
}
.certificate-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-top: 12px; border-top: 1px dashed #d7c296; color: #8c6b3e; font-size: 12px; font-weight: 800;
}
.certificate-stamp {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 84px; padding: 6px 10px; border: 1px solid #c79c55; border-radius: 999px;
  color: #b24e3a; background: rgba(255,248,226,.78);
}

.certificate-actions { display: grid; gap: 11px; }

.personal-record {
  margin-top: 20px; padding: 18px; border: 1px solid var(--line); border-radius: 22px; background: var(--paper);
}
.personal-record h2 { margin: 0 0 13px; font-size: 18px; }
.record-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.record-grid div { padding: 11px 4px; border-radius: 13px; background: #f8eddb; text-align: center; }
.record-grid span { display: block; color: var(--muted); font-size: 10px; }
.record-grid strong { display: block; margin-top: 3px; font-size: 17px; }
.personal-record p { margin-bottom: 0; color: var(--muted); font-size: 11px; }

.day-transition {
  position: fixed; inset: 0; z-index: 99; display: none; place-items: center;
  background: #15202a; color: white; font-size: 20px; font-weight: 900; opacity: 0;
}
.day-transition.show { display: grid; animation: dayTransition 1.2s ease forwards; }
@keyframes dayTransition {
  0% { opacity: 0; }
  35%, 65% { opacity: 1; }
  100% { opacity: 0; }
}

@media (min-width: 720px) {
  .site-header { padding-inline: max(24px, calc((100% - 1060px) / 2)); }
  .work-main { padding-inline: 20px; }
  .certificate-actions { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 390px) {
  .brand-copy strong { font-size: 14px; }
  .brand-copy small { display: none; }
  .header-link { font-size: 11px; }
  .site-header { gap: 8px; padding-inline: 10px; }
  .status-main strong { font-size: 38px; }
  .status-main small { font-size: 16px; }
  .find-toast { font-size: 11px; }
  .deluxe-result strong { font-size: 50px; }
  .certificate-footer { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .mine-stage.is-hitting,
  .mine-stage.is-hitting .impact-flash,
  .find-toast.show,
  .day-transition.show { animation: none; }
  .mine-frame-hit { transition: none; }
}


/* v0.7: 勤務終了画面では得点数を主役にする */
.deluxe-result {
  padding-top: 30px;
  padding-bottom: 28px;
}

.deluxe-result > span {
  font-size: 14px;
  letter-spacing: .05em;
}

.deluxe-result > strong {
  display: block;
  margin-top: 10px;
  color: #5f2d08;
  font-size: clamp(72px, 19vw, 118px);
  line-height: .88;
  font-weight: 900;
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
}

.deluxe-result > em {
  margin-top: 12px;
  font-size: clamp(15px, 4vw, 19px);
  letter-spacing: .14em;
}

/* 古いHTMLやキャッシュに残った英字見出しも隠す */
.result-kicker {
  display: none !important;
}

@media (max-width: 390px) {
  .deluxe-result > strong {
    font-size: 68px;
  }

  .deluxe-result > em {
    font-size: 15px;
  }
}


/* v0.8 ------------------------------------------------------------ */

/* 勤務開始の見出しを、スマホでも不格好に折り返さない大きさへ */
#state-ready h1 {
  font-size: clamp(20px, 5.6vw, 32px);
  letter-spacing: 0;
  white-space: nowrap;
}

/* 新しい説明文は少し読みやすく */
#state-ready .state-copy {
  max-width: 560px;
  margin-inline: auto;
  line-height: 1.9;
}

/* 100打目のあと、結果遷移まで操作不能であることを明示 */
.mine-stage:disabled {
  cursor: default;
  opacity: 1;
}

.mine-stage:disabled::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 20;
  background: transparent;
  pointer-events: all;
}

@media (max-width: 350px) {
  #state-ready h1 {
    font-size: 18px;
  }
}


/* v1.0 ------------------------------------------------------------ */
.certificate-canvas-wrap {
  width: min(100%, 760px);
  margin: 20px auto;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 16px 34px rgba(76, 52, 29, .12);
  background: #f8f0df;
}

.certificate-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: transparent;
}

@media (max-width: 520px) {
  .certificate-canvas-wrap {
    width: 100%;
  }
}


/* v1.1.4 ---------------------------------------------------------- */
/* 砂漠採集局では鉱山用の発光ヒットエフェクトを表示しない */
.mine-stage[data-job-target="desert"] .impact-flash {
  display: none !important;
  animation: none !important;
  opacity: 0 !important;
}

/* ヒット後コマはJS側で260ms表示。揺れだけは短く保つ。 */


/* v1.2.1 ---------------------------------------------------------- */
/* 勤務進行 30% / 暫定労働点数 70% */
.work-status {
  grid-template-columns: minmax(0, 3fr) minmax(0, 7fr);
}

/* 桁数が増えても得点欄へ収まりやすくする */
.status-card-score .status-main {
  min-width: 0;
}

.status-card-score .status-main strong {
  min-width: 0;
  max-width: 100%;
  font-size: clamp(40px, 8.5vw, 60px);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.status-card-score .status-main small {
  flex: 0 0 auto;
  white-space: nowrap;
}

@media (max-width: 390px) {
  .work-status {
    gap: 8px;
  }

  .status-card {
    padding-inline: 7px;
  }

  .status-card-score .status-main {
    gap: 5px;
  }

  .status-card-score .status-main strong {
    font-size: 38px;
  }

  .status-card-score .status-main small {
    font-size: 14px;
  }
}


/* v1.2.2 ---------------------------------------------------------- */
/* 勤務進行 35% / 暫定労働点数 65% */
.work-status {
  grid-template-columns: minmax(0, 35fr) minmax(0, 65fr);
}

/* 得点側の単位「トリット」を少し控えめに */
.status-card-score .status-main small {
  font-size: clamp(15px, 3.3vw, 20px);
}

@media (max-width: 390px) {
  .status-card-score .status-main small {
    font-size: 13px;
  }
}
