* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #f5f0e5;
  color: #1f1b18;
  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;
}
h1, p, span, div, button, a { word-break: auto-phrase; text-wrap: pretty; }
[hidden] { display: none !important; }

#app {
  touch-action: none;
  position: fixed;
  inset: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px) 0;
  max-width: 560px;
  margin: 0 auto;
}
#c {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#next-prob {
  position: absolute;
  left: 10px;
  top: 8px;
  height: 38px;
  padding: 0 13px;
  border-radius: 19px;
  font-size: 13px;
  font-weight: 800;
  background: rgba(255, 252, 245, 0.92);
  color: #3a322a;
  border: 1.5px solid rgba(58, 50, 42, 0.35);
  box-shadow: 0 2px 8px rgba(34, 20, 8, 0.16);
  z-index: 4;
  touch-action: manipulation;
}
#next-prob::before {
  content: "";
  position: absolute;
  inset: -5px;
}
#next-prob:active { transform: scale(0.95); }

#hud-bar {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 4;
  pointer-events: none;
}
#tools {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}
.tool-btn {
  position: relative;
  height: 46px;
  padding: 0 12px 0 9px;
  border-radius: 23px;
  font-size: 14px;
  font-weight: 800;
  background: rgba(255, 252, 245, 0.90);
  color: #3a332c;
  border: 2px solid rgba(46, 38, 30, 0.28);
  box-shadow: 0 3px 10px rgba(34, 20, 8, 0.16);
  gap: 4px;
  transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
  touch-action: manipulation;
}
.tool-btn svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.tool-btn.active {
  background: #1f1b18;
  color: #fffdf9;
  border-color: #1f1b18;
  box-shadow: 0 5px 14px rgba(24, 14, 6, 0.32), 0 0 0 2px rgba(255, 252, 245, 0.85);
  transform: translateY(-2px);
}
.tool-btn:active { transform: scale(0.95); }

#submit {
  pointer-events: auto;
  position: relative;
  height: 48px;
  min-width: 82px;
  padding: 0 18px;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1px;
  background: #fffdf8;
  color: #c63326;
  border: 2.5px solid #c63326;
  box-shadow: 0 4px 14px rgba(38, 22, 10, 0.22);
  touch-action: manipulation;
  transition: transform 0.16s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.2s ease;
}
#submit::before {
  content: "";
  position: absolute;
  inset: -4px;
}
#submit.ready {
  background: #c63326;
  color: #fffdf9;
  border-color: #962016;
  animation: sub-pulse 1.5s ease-in-out infinite;
}
@keyframes sub-pulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(198, 51, 38, 0.34), 0 0 0 2px rgba(255, 252, 245, 0.9); transform: scale(1); }
  50% { box-shadow: 0 6px 20px rgba(198, 51, 38, 0.52), 0 0 0 4px rgba(255, 252, 245, 0.95); transform: scale(1.04); }
}
#submit:active { transform: scale(0.94); }

.panel {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 14px calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 10;
  background: #f5f0e5;
}
#title { background: rgba(246, 241, 230, 0.96); }
#result { align-items: flex-start; padding-top: 10px; }

.box { width: 100%; max-width: 350px; text-align: center; margin: auto; }
.box.wide { max-width: 500px; margin: 0 auto; }

#tart {
  width: 100%;
  height: clamp(160px, 34vh, 250px);
  display: block;
  margin: 0 auto 8px;
  border-radius: 12px;
}
h1 {
  font-size: 48px;
  letter-spacing: 3px;
  margin: 0 0 14px;
  white-space: nowrap;
}

button, .button {
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  color: #1f1b18;
  background: #fffdf9;
  border: 2px solid #1f1b18;
  border-radius: 24px;
  height: 46px;
  padding: 0 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
}
button.primary, .button.primary {
  background: #1f1b18;
  color: #fffdf9;
}
button.big {
  width: 100%;
  height: 54px;
  font-size: 19px;
  border-radius: 27px;
}
button:disabled { opacity: 0.45; cursor: default; }
#title-guide { min-height: 28px; margin-top: 12px; font-size: 13px; }

#card {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(262px, calc(100vh - 240px));
  aspect-ratio: 1200 / 630;
  margin: 0 auto;
  border-radius: 10px;
  border: 2px solid rgba(31, 27, 24, 0.16);
  box-shadow: 0 6px 20px rgba(31, 27, 24, 0.1);
}

.row {
  display: flex;
  gap: 8px;
  justify-content: center;
  max-width: 440px;
  margin: 8px auto 0;
}
#r-post {
  flex: 1.65;
  background: #1f1b18;
  color: #fffdf9;
  font-size: 16px;
  padding: 0 10px;
}
#r-post svg { width: 16px; height: 16px; }
#again { flex: 1; font-size: 15px; padding: 0 8px; }
#r-row { max-width: 440px; margin: 6px auto 0; }
#r-after { max-width: 440px; margin: 10px auto 0; }
.sn-chip { min-height: 36px; }
#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: 0;
  font-size: min(38px, 10vw);
}

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

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

.langsw {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 6px 12px;
  border: 2px solid #1f1b18;
  border-radius: 20px;
  background: #fff;
  color: #1f1b18;
  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;
}
