* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #ede4d3;
  color: #1b1b1f;
  touch-action: manipulation;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  overflow: hidden;
}
#app {
  touch-action: none;
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  max-width: 580px;
  margin: 0 auto;
}
#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
}
#c {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
#dock {
  flex: 0 0 auto;
  background: #e3d7c1;
  border-top: 2px solid #c9b99c;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 2;
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.bar[hidden] { display: none; }
.group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.tool, .icon-btn, .swatch {
  position: relative;
  min-width: 42px;
  min-height: 44px;
  padding: 4px;
  border: 2px solid #9d8b6f;
  background: #f7f1e3;
  color: #1b1b1f;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.tool svg { width: 30px; height: 32px; display: block; }
.icon-btn svg { width: 22px; height: 22px; display: block; }
.tool.on, .icon-btn.on {
  background: #fffdf7;
  border-color: #1b1b1f;
  box-shadow: inset 0 0 0 1px #1b1b1f;
}
.guide-btn {
  min-width: 58px;
  padding: 3px 6px 4px;
  flex-direction: column;
  gap: 2px;
  margin-right: 3px;
  box-shadow: 3px -3px 0 -1px #efe6d4, 3px -3px 0 0.5px #9d8b6f;
  transition: transform 80ms ease;
}
.guide-btn.on {
  box-shadow: inset 0 0 0 1px #1b1b1f, 3px -3px 0 -1px #efe6d4, 3px -3px 0 0.5px #1b1b1f;
}
.guide-btn:active {
  transform: translateY(1px);
}
.guide-ico {
  width: 24px;
  height: 20px;
  margin-right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.guide-ico svg {
  width: 24px;
  height: 20px;
  display: block;
}
.guide-cyc {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  color: #c43828;
  pointer-events: none;
}
.guide-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 6px;
}
.guide-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(27, 27, 31, 0.24);
  display: block;
  transition: transform 140ms ease, background 140ms ease;
}
.guide-dots i.on {
  background: #1b1b1f;
  transform: scale(1.3);
}
.guide-btn.flip .guide-ico {
  animation: guide-swap 200ms cubic-bezier(0.22, 1, 0.36, 1);
}
.guide-btn.flip .guide-cyc {
  animation: guide-spin 240ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes guide-swap {
  0% { opacity: 0.3; transform: translateX(6px) scale(0.84); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes guide-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.swatch {
  min-width: 38px;
  min-height: 44px;
  padding: 5px;
}
.swatch span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(27, 27, 31, 0.25);
  display: block;
}
.swatch.on {
  background: #fffdf7;
  border-color: #1b1b1f;
  box-shadow: inset 0 0 0 1px #1b1b1f;
}
.swatch.on span {
  transform: scale(1.12);
  border-color: #1b1b1f;
}
.step-btn {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 14px;
  white-space: nowrap;
  border-radius: 4px;
}
.step-btn.ready {
  background: #c43828;
  border-color: #8f2217;
  color: #fff;
}
.meter {
  flex: 1;
  height: 10px;
  background: #d2c4aa;
  border: 1.5px solid #9d8b6f;
  border-radius: 5px;
  overflow: hidden;
  min-width: 40px;
}
.meter i {
  display: block;
  height: 100%;
  width: 0%;
  background: #1b1b1f;
  transition: width 120ms ease-out;
}
.panel {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(237, 228, 211, 0.92);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  z-index: 10;
}
.panel[hidden] { display: none; }
#title { background: rgba(237, 228, 211, 0.98); }
#result { background: #ede4d3; align-items: flex-start; }
.box {
  width: 100%;
  max-width: 360px;
  text-align: center;
  margin: auto;
}
.box.wide {
  max-width: 520px;
  margin-top: 0;
}
#tart {
  width: 100%;
  height: clamp(136px, 28vh, 210px);
  display: block;
  margin: 0 auto 6px;
}
h1 {
  font-size: 54px;
  letter-spacing: 10px;
  margin: 0 0 4px;
  padding-left: 10px;
}
.sub {
  margin: 0 0 22px;
  font-size: 15px;
  font-weight: 700;
  color: #463e34;
}
h1, .sub, p {
  word-break: auto-phrase;
  text-wrap: pretty;
}
button, .button {
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  color: #1b1b1f;
  background: #fffdf7;
  border: 2px solid #1b1b1f;
  border-radius: 0;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
button.primary, .button.primary {
  background: #1b1b1f;
  color: #fff;
}
button.big {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  margin-top: 10px;
}
button:disabled { opacity: 0.45; }
#hero {
  width: 100%;
  aspect-ratio: 9 / 11;
  max-height: 60vh;
  display: block;
  margin: 0 auto;
}
.r-guides {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}
.guide-pick {
  position: relative;
  flex: 1;
  max-width: 68px;
  min-width: 44px;
  min-height: 44px;
  padding: 6px 4px;
  border: 2px solid #9d8b6f;
  background: #f7f1e3;
  color: #1b1b1f;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 80ms ease;
}
.guide-pick:active {
  transform: translateY(1px);
}
.guide-pick svg {
  width: 28px;
  height: 24px;
  display: block;
}
.guide-pick.cur {
  background: #e8decb;
  opacity: 0.72;
}
.guide-pick.next {
  border-color: #c43828;
  background: #fffdf7;
  box-shadow: inset 0 0 0 1px #c43828;
}
.guide-pick.done::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c43828;
}
.row {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
}
#r-post {
  flex: 1.6;
  background: #1b1b1f;
  color: #fff;
  font-size: 16px;
  padding: 11px 8px;
  white-space: nowrap;
}
#r-post svg { width: 17px; height: 17px; }
#recarve, #again {
  flex: 1;
  font-size: 14px;
  padding: 10px 6px;
  white-space: nowrap;
}
#r-share {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin: 10px -12px 0;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  background: #ede4d3;
  box-shadow: 0 -8px 10px -8px rgba(27, 27, 31, 0.28);
}
#r-share .x { flex: 1.45; }
#r-row { margin-top: 8px; }
#r-after { margin-top: 16px; }

@media (max-width: 375px) {
  #dock { padding: 5px 5px calc(5px + env(safe-area-inset-bottom, 0px)); }
  .group { gap: 3px; }
  .tool { min-width: 38px; padding: 3px; }
  .tool svg { width: 28px; height: 30px; }
  .icon-btn { min-width: 38px; padding: 3px; }
  .guide-btn { min-width: 52px; padding: 3px 4px 4px; }
  .swatch { min-width: 36px; padding: 4px; }
  .step-btn { padding: 8px 9px; font-size: 13px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  #app {
    flex-direction: row;
    max-width: none;
  }
  #dock {
    border-top: 0;
    border-left: 2px solid #c9b99c;
    padding: 8px calc(8px + env(safe-area-inset-right, 0px)) 8px 8px;
    width: 124px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .bar {
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    width: 100%;
  }
  .group {
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
  }
  .step-btn {
    width: 100%;
    padding: 8px 6px;
  }
  .meter {
    width: 100%;
    flex: 0 0 auto;
  }
  #tart { height: 110px; }
  h1 { font-size: 40px; }
  .sub { margin-bottom: 12px; }
}

#title-guide:empty {
  display: none;
}

:lang(ko) body {
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans CJK KR", "Malgun Gothic", sans-serif;
}

:lang(zh-Hans) body {
  font-family: "PingFang SC", "Noto Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}

:lang(zh-Hant) body {
  font-family: "PingFang TC", "Noto Sans TC", "Noto Sans CJK TC", "Microsoft JhengHei", sans-serif;
}

:lang(en) body, :lang(es) body, :lang(pt) body, :lang(fr) body, :lang(de) body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

:lang(en) h1, :lang(es) h1, :lang(pt) h1, :lang(fr) h1, :lang(de) h1 {
  letter-spacing: 2px;
  padding-left: 2px;
}

html.lang-wait #app, html.lang-wait #title {
  visibility: hidden;
}

#t-lang {
  margin: -10px 0 12px;
}

.langsw {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 6px 12px;
  border: 2px solid #1b1b1f;
  background: #fffdf7;
  color: #1b1b1f;
  font-size: 14px;
  font-weight: 800;
}

.langsw svg {
  width: 16px;
  height: 16px;
}

.langsw select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  font-size: 16px;
  cursor: pointer;
}
