:root {
  --paper: #fbf8f2;
  --paper-deep: #f4ecdf;
  --card: #fffdf9;
  --ink: #3f332d;
  --muted: #7d6e64;
  --line: #ddcfbf;
  --orange: #d9672f;
  --orange-dark: #b8491e;
  --orange-soft: #f7d7bd;
  --green: #667b67;
  --shadow: 0 18px 45px rgba(76, 54, 39, .12);
}

* { box-sizing: border-box; }

html { background: var(--paper-deep); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 255, 255, .9), transparent 30%),
    linear-gradient(145deg, #f8f2e8, #efe4d4);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, textarea { font: inherit; }
button { color: inherit; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.atorilog {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
}

.atorilog__shell {
  position: relative;
  width: min(100%, 470px);
  min-height: calc(100dvh - 32px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(116, 90, 70, .13);
  border-radius: 28px;
  background:
    linear-gradient(rgba(255,255,255,.26) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 32px;
  box-shadow: var(--shadow);
}

.app-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 15px 18px;
  border-bottom: 1px solid rgba(116, 90, 70, .12);
  background: rgba(251, 248, 242, .88);
  backdrop-filter: blur(8px);
}

.brand {
  display: grid;
  gap: 1px;
  padding: 0;
  text-align: left;
  border: 0;
  background: none;
  cursor: pointer;
}

.brand__name { font-size: 18px; font-weight: 900; letter-spacing: .03em; }
.brand__name span { color: var(--orange); }
.brand__tagline { color: var(--muted); font-size: 10px; letter-spacing: .08em; }

.motion-toggle {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, .7);
  font-size: 11px;
  cursor: pointer;
}

.status {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  max-width: calc(100% - 40px);
  margin: 0;
  padding: 10px 15px;
  border-radius: 999px;
  color: #fff;
  background: rgba(63, 51, 45, .93);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  font-size: 13px;
  transform: translate(-50%, 25px);
  opacity: 0;
  pointer-events: none;
  transition: .22s ease;
}

.status.is-visible { transform: translate(-50%, 0); opacity: 1; }

.screen {
  position: relative;
  min-height: calc(100dvh - 104px);
  padding: 44px 24px 36px;
  animation: screen-in .36s ease both;
}

.screen[hidden] { display: none; }
.screen__heading { position: relative; z-index: 2; margin-bottom: 26px; }
.screen__heading--center { text-align: center; }
.eyebrow { margin: 0 0 8px; color: var(--orange-dark); font-size: 12px; font-weight: 800; letter-spacing: .12em; }
h1 { margin: 0 0 13px; font-size: clamp(27px, 8vw, 35px); line-height: 1.38; letter-spacing: .025em; }
.screen__heading h1, .screen__heading .eyebrow { text-align: center; }
.screen-title { white-space: nowrap; }
.screen__heading > p:last-child { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.9; }

label, .field-caption {
  display: block;
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

textarea {
  display: block;
  width: 100%;
  resize: vertical;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  color: var(--ink);
  background: rgba(255,255,255,.88);
  font-size: 16px;
  line-height: 1.7;
  box-shadow: inset 0 1px 2px rgba(76,54,39,.04);
  transition: border-color .2s, box-shadow .2s;
}

textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(217,103,47,.12); }
textarea::placeholder { color: #aa9b90; }

.suggestions { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0 22px; }
.suggestions button, .recent__items button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  cursor: pointer;
}
.suggestions button { padding: 7px 10px; color: var(--muted); font-size: 12px; }
.suggestions button:hover, .recent__items button:hover { border-color: var(--orange); color: var(--orange-dark); }

.recent { margin: 3px 0 22px; padding-top: 18px; border-top: 1px dashed var(--line); }
.recent__items { display: grid; gap: 8px; }
.recent__items button { width: 100%; padding: 10px 13px; overflow: hidden; text-align: left; text-overflow: ellipsis; white-space: nowrap; }

.button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 49px;
  padding: 12px 15px;
  border: 0;
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.button:active { transform: translateY(1px); }
.button--primary { color: #fff; background: var(--orange); box-shadow: 0 8px 18px rgba(184,73,30,.22); }
.button--primary:hover { background: var(--orange-dark); }
.button--start {
  flex-direction: column;
  width: 176px;
  min-height: 176px;
  height: 176px;
  margin: 22px auto 10px;
  padding: 18px;
  border: 4px solid rgba(255,255,255,.5);
  border-radius: 50%;
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: .03em;
  text-align: center;
  box-shadow: 0 16px 30px rgba(184,73,30,.28), inset 0 1px 0 rgba(255,255,255,.42);
}
.button--start span { display: block; white-space: nowrap; }
.button--start:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 34px rgba(184,73,30,.32), inset 0 1px 0 rgba(255,255,255,.42);
}
.button--start:active { transform: translateY(1px) scale(.98); }
.button--secondary { border: 1px solid var(--line); color: var(--ink); background: rgba(255,255,255,.75); }
.button--text { min-height: 42px; margin-top: 7px; color: var(--muted); background: transparent; font-size: 13px; }
.button--danger { color: #fff; background: #9d3b31; }

.timer-purpose { min-height: 78px; margin-bottom: 22px; text-align: center; }
.timer-purpose span, .planned-summary span, .trace-card__section span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.timer-purpose h1 { margin: 8px auto 0; font-size: 17px; line-height: 1.6; }

.timer-wrap { position: relative; width: min(68vw, 280px); aspect-ratio: 1; margin: 0 auto; }
.timer-ring { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring circle { fill: none; stroke-width: 7; }
.timer-ring__track { stroke: #eadfd1; }
.timer-ring__progress { stroke: var(--orange); stroke-linecap: round; transition: stroke-dashoffset .45s linear; }
.timer-digits { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: clamp(48px, 15vw, 68px); font-weight: 300; font-variant-numeric: tabular-nums; }
.timer-digits__number { line-height: 1; letter-spacing: -.04em; }
.timer-digits__colon {
  position: relative;
  width: .18em;
  height: .7em;
  margin: 0 .08em;
  flex: 0 0 .18em;
}
.timer-digits__colon::before,
.timer-digits__colon::after {
  content: "";
  position: absolute;
  left: 50%;
  width: .09em;
  height: .09em;
  border-radius: 50%;
  background: currentColor;
  transform: translateX(-50%);
}
.timer-digits__colon::before { top: 27%; }
.timer-digits__colon::after { bottom: 27%; }
.timer-caption { margin: 17px 0 28px; color: var(--muted); text-align: center; font-size: 13px; }
.timer-actions { display: grid; gap: 4px; }

.finish-mark { display: grid; place-items: center; width: 66px; height: 66px; margin: -13px auto 22px; border-radius: 50% 50% 48% 52%; color: white; background: var(--orange); box-shadow: 0 10px 22px rgba(184,73,30,.22); transform: rotate(-4deg); }
.finish-mark span { font-weight: 900; transform: rotate(4deg); }

.planned-summary { margin: 0 0 22px; padding: 14px 16px; border-left: 4px solid var(--orange-soft); border-radius: 3px 12px 12px 3px; background: rgba(255,255,255,.68); }
.planned-summary p { margin: 6px 0 0; line-height: 1.6; }
.input-note { margin: 9px 2px 22px; color: var(--muted); font-size: 12px; line-height: 1.7; }

.trace-card {
  position: relative;
  margin: 25px 0 24px;
  padding: 22px 20px 18px;
  overflow: hidden;
  border: 1px solid #dfcdbb;
  border-radius: 5px;
  background: #fffdf8;
  box-shadow: 0 13px 28px rgba(80,57,41,.12);
}
.trace-card::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .3; background-image: radial-gradient(#cdb9a3 .6px, transparent .6px); background-size: 6px 6px; }
.trace-card > * { position: relative; }
.trace-card__header { display: flex; align-items: baseline; justify-content: space-between; padding-bottom: 14px; border-bottom: 1px solid #eadfd2; }
.trace-card__brand { font-size: 16px; font-weight: 900; }
.trace-card__date { color: var(--muted); font-size: 11px; }
.trace-card__section { padding: 18px 0; }
.trace-card__section p { margin: 7px 0 0; font-size: 17px; font-weight: 700; line-height: 1.75; white-space: pre-wrap; }
.trace-card__section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.trace-card__edit-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 2px;
  border: 0;
  color: var(--orange-dark);
  background: transparent;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.trace-card__edit-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.trace-card__edit-form { margin-top: 10px; }
.trace-card__edit-form textarea { min-height: 92px; padding: 11px 12px; font-size: 15px; line-height: 1.6; }
.trace-card__edit-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.trace-card__edit-actions button { min-height: 40px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: #fff; font-size: 12px; font-weight: 800; cursor: pointer; }
.trace-card__edit-actions button[type="submit"] { border-color: var(--orange); color: #fff; background: var(--orange); }
.trace-card__path { display: flex; gap: 13px; align-items: center; padding-left: 10px; }
.trace-card__path i { display: block; width: 9px; height: 13px; border-radius: 60% 45% 55% 45%; background: var(--orange-soft); transform: rotate(26deg); }
.trace-card__path i:nth-child(2) { transform: translateY(5px) rotate(-20deg); }
.trace-card footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 14px; border-top: 1px solid #eadfd2; color: var(--muted); font-size: 9px; }
.trace-card footer strong { padding: 5px 8px; border: 2px solid rgba(217,103,47,.72); border-radius: 3px; color: var(--orange-dark); font-size: 10px; transform: rotate(-4deg); }
.card-actions { display: grid; gap: 9px; }

.app-footer {
  padding: 0 24px 28px;
  text-align: center;
}
.app-footer__links {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.app-footer a {
  display: inline-block;
  padding: 8px 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-decoration: underline;
  text-decoration-color: rgba(125, 110, 100, .45);
  text-underline-offset: 4px;
}
.app-footer a:hover,
.app-footer a:focus-visible {
  color: var(--orange-dark);
  text-decoration-color: currentColor;
}

.slime-guide { position: relative; z-index: 4; width: max-content; margin-left: auto; }
.slime-guide--start { margin: -6px -4px 0 auto; }
.slime-guide--timer { margin: 8px 0 -4px auto; }
.slime-guide--reflection { margin: 6px 0 -6px auto; }
.slime-guide--card { display: flex; align-items: center; gap: 10px; margin: -8px auto 0; }
.slime-guide--card + .trace-card { margin-top: 4px; }
.slime {
  display: block;
  width: 108px;
  height: 108px;
  padding: 0;
  border: 0;
  background-color: transparent;
  background-image: url('noritera-slime-sprites.png');
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 300% 200%;
  cursor: pointer;
  transform-origin: 50% 90%;
}
.slime--small { width: 90px; height: 90px; }
.slime > span { display: none; }
.atorilog-seal {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  width: 132px;
  min-height: 64px;
  padding: 6px 8px 6px 5px;
  border: 2px solid rgba(217, 103, 47, .78);
  border-radius: 4px;
  color: var(--orange-dark);
  background: transparent;
  opacity: 0;
  transform: rotate(-3deg) scale(.94);
  animation: seal-appear .38s ease .92s forwards;
}
.atorilog-seal__mascot {
  display: block;
  width: 38px;
  height: 38px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.atorilog-seal__copy { display: grid; min-width: 0; gap: 3px; text-align: center; }
.atorilog-seal strong { font-size: 10px; line-height: 1.2; letter-spacing: .01em; white-space: nowrap; }
.atorilog-seal small { font-size: 7.5px; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.slime-bubble { position: absolute; right: 66px; top: 0; width: 190px; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px 12px 3px 12px; color: var(--ink); background: #fff; box-shadow: 0 8px 22px rgba(69,48,34,.12); font-size: 12px; line-height: 1.55; }
.slime-guide--start .slime-bubble { right: 70px; top: 30px; }

[data-slime-state="guide"] .slime { background-position: 50% 0; animation: point 2.8s ease-in-out 1 .8s; }
[data-slime-state="working"] .slime { background-position: 100% 0; animation: breathe 3s ease-in-out infinite; }
[data-slime-state="paused"] .slime { background-position: 0 100%; transform: scaleY(.96); }
[data-slime-state="found"] .slime { background-position: 50% 100%; animation: hop .7s ease 2; }
[data-slime-state="stamp"] .slime { background-position: 100% 100%; animation: stamp .8s ease 1 .4s; }

.debug-skip { display: block; margin: 22px auto 0; padding: 6px 9px; border: 1px dashed var(--line); color: var(--muted); background: transparent; font-size: 10px; cursor: pointer; }

.confirm-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(calc(100% - 34px), 390px);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: var(--ink);
  background: var(--card);
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}
.confirm-dialog::backdrop { background: rgba(48,37,31,.38); backdrop-filter: blur(2px); }
.confirm-dialog form { padding: 23px; }
.confirm-dialog h2 { margin: 0 0 7px; font-size: 19px; }
.confirm-dialog p { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.confirm-dialog form > div { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.confirm-dialog .button--text { margin: 0; }

@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes point { 0%,100% { transform: rotate(0); } 35% { transform: rotate(-5deg) translateX(-5px); } 55% { transform: rotate(2deg); } }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.025, .97); } }
@keyframes hop { 0%,100% { transform: translateY(0) scaleY(1); } 45% { transform: translateY(-13px) scaleY(1.04); } }
@keyframes stamp { 0%,100% { transform: rotate(0); } 45% { transform: translate(-8px, 8px) rotate(-11deg) scaleY(.9); } }
@keyframes seal-appear { to { opacity: .82; transform: rotate(-3deg) scale(1); } }

.atorilog.is-motion-reduced *,
.atorilog.is-motion-reduced *::before,
.atorilog.is-motion-reduced *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
.atorilog.is-motion-reduced * { animation-delay: 0ms !important; }

@media (max-width: 430px) {
  .atorilog { padding: 0; }
  .atorilog__shell { min-height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
  .screen { padding: 38px 21px 32px; }
  .slime-guide--start { margin-top: -2px; transform: none; }
  .screen[data-screen="start"] .screen__heading { padding-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
