* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #f5f3ee; color: #1b1b1d; 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; }
#app { touch-action: none; position: fixed; inset: 0; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }

/* three dots (the gardens) and what the 住職 says */
#hud { flex: none; height: 64px; display: flex; align-items: center; gap: 10px; padding: 8px 14px 0; }
#hud.off { visibility: hidden; }
#dots { flex: none; display: flex; gap: 5px; }
#dots i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #1b1b1d; background: #fff; }
#dots i.now { background: #e8e1cf; }
#dots i.done { background: #1b1b1d; }
#dots i.done.hi { background: #c8392b; border-color: #c8392b; }
#say { flex: 1; min-width: 0; margin: 0; display: flex; align-items: center; gap: 6px; opacity: 0; transition: opacity .15s; }
#say.on { opacity: 1; }
#say svg { flex: none; width: 40px; height: 40px; }
#say-t { font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Noto Serif CJK JP", serif; font-size: 18px; font-weight: 800; line-height: 1.3; }
#stage { position: relative; flex: 1; min-height: 0; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* the first time: a finger drawing an S on the sand */
#hint { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; }
#hint[hidden] { display: none; }
#hint i { position: absolute; width: 30px; height: 38px; margin: -19px -15px; border-radius: 50% 50% 46% 46%; border: 3px solid #1b1b1d; background: rgba(255,255,255,.88);
  animation: ess 1.8s ease-in-out infinite; }
#hint b { position: absolute; white-space: nowrap; left: 30px; top: -16px; font-size: 22px; letter-spacing: 2px; -webkit-text-stroke: 5px #fff; paint-order: stroke; }
@keyframes ess {
  0% { transform: translate(-60px, -90px); opacity: 0; }
  12% { opacity: 1; }
  35% { transform: translate(50px, -40px); }
  65% { transform: translate(-50px, 30px); }
  88% { transform: translate(60px, 90px); opacity: 1; }
  100% { transform: translate(60px, 90px); opacity: 0; }
}

.panel { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(245,243,238,.9); overflow-y: auto; overscroll-behavior: contain; padding: 16px; z-index: 10; }
.panel[hidden] { display: none; }
#title { background: #f5f3ee; }
.box { width: 100%; max-width: 360px; text-align: center; margin: auto; }
.box.wide { max-width: 480px; }
#tart { width: 100%; height: clamp(130px, 30vh, 240px); display: block; margin: 0 auto 10px; }
h1 { font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Noto Serif CJK JP", serif; font-size: 54px; letter-spacing: 8px; margin: 0 0 4px; }
.sub { margin: 0 0 22px; font-size: 16px; font-weight: 700; }
button, .button { font: inherit; font-size: 16px; font-weight: 700; color: #1b1b1d; background: #fff; border: 2px solid #1b1b1d; border-radius: 0;
  padding: 10px 18px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
button.primary, .button.primary { background: #1b1b1d; color: #fff; }
button.big { width: 100%; padding: 14px; font-size: 18px; margin-top: 8px; }
.row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.row > * { flex: 1; }
#r-post { flex: 1.7; background: #1b1b1d; color: #fff; font-size: 18px; padding: 13px 8px; white-space: nowrap; }
#r-post svg { width: 18px; height: 18px; }
#again { flex: 1; font-size: 15px; padding: 10px 4px; white-space: nowrap; }
#r-after { margin-top: 18px; }
#r-share { gap: 6px; position: sticky; bottom: 0; z-index: 3; margin: 14px -12px 0; padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  background: #f5f3ee; border-top: 2px solid #1b1b1d; }

/* the 鑑定書 */
#result { align-items: flex-start; padding-bottom: 0; }
#sheet { background: #fffdf7; border: 2.5px solid #1b1b1d; padding: 10px 12px 10px; text-align: left; position: relative; }
.r-head { display: flex; align-items: center; gap: 8px; }
.r-head b { font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Noto Serif CJK JP", serif; font-size: 20px; letter-spacing: 6px; }
#r-best { color: #c8392b; border: 2px solid #c8392b; padding: 0 6px; font-style: normal; font-weight: 900; font-size: 12px; transform: rotate(-3deg); }
#r-best[hidden] { display: none; }
.r-total { display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid #1b1b1d; padding-bottom: 4px; }
.r-total p { margin: 0; }
.r-total small { display: block; font-size: 12px; font-weight: 800; }
#r-score { font-size: 48px; line-height: 1; font-weight: 900; color: #c8392b; font-variant-numeric: tabular-nums; }
#r-score.gold { color: #c8961e; }
#r-stamp { width: 92px; height: 92px; animation: hanko .35s cubic-bezier(.2,1.6,.4,1) .3s both; }
@keyframes hanko { from { transform: scale(2.2); opacity: 0; } }
#r-gardens { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; text-align: center; }
#r-gardens li { min-width: 0; }
#r-gardens canvas { width: 100%; aspect-ratio: 3 / 4; display: block; }
#r-gardens b { display: block; font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Noto Serif CJK JP", serif; font-size: 13px; line-height: 1.25; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#r-gardens span { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
#r-comment { margin: 6px 0 0; font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Noto Serif CJK JP", serif; font-size: 16px; font-weight: 800; }
@media (max-height: 600px) {
  #r-gardens { max-width: 300px; margin-left: auto; margin-right: auto; }
  #r-score { font-size: 40px; }
  #r-stamp { width: 76px; height: 76px; }
}

/* the 住職 reads the lines out: plus, minus, then the sum, the name, and on to the next garden */
#tally { position: absolute; left: 10px; right: 10px; bottom: 10px; background: #fffdf7; border: 2.5px solid #1b1b1d; padding: 8px 10px 10px; touch-action: manipulation; }
#tally[hidden] { display: none; }
#t-name { margin: 0 0 4px; min-height: 30px; text-align: center; font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Noto Serif CJK JP", serif; font-size: 23px; font-weight: 900; line-height: 30px; }
#t-name span { display: inline-block; animation: hanko .3s cubic-bezier(.2,1.6,.4,1) both; }
#t-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 5px; justify-content: center; min-height: 54px; align-content: flex-start; }
#t-rows li { animation: pop .18s ease-out both; }
#t-rows button { font-size: 14px; font-weight: 800; padding: 2px 7px; border: 2px solid #1b1b1d; background: #fff; color: #1b1b1d; white-space: nowrap; gap: 0; }
#t-rows button b { margin-left: 4px; font-variant-numeric: tabular-nums; }
#t-rows button small { font-size: 11px; margin-left: 1px; }
#t-rows button.on { background: #1b1b1d; color: #fff; }
#t-rows li.br { flex-basis: 100%; height: 0; padding: 0; border: 0; margin: 0; }
#t-rows li.minus button { border-color: #c8392b; color: #c8392b; background: #fff6f3; }
#t-rows li.minus button.on { background: #c8392b; color: #fff; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }
.t-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; border-top: 2px solid #1b1b1d; padding-top: 6px; }
#t-total { margin: 0; display: flex; align-items: baseline; gap: 6px; }
#t-total small { font-size: 13px; font-weight: 800; }
#t-score { font-size: 34px; line-height: 1; font-weight: 900; font-variant-numeric: tabular-nums; }
#t-score.hi { color: #c8392b; }
#next { padding: 10px 16px; font-size: 17px; visibility: hidden; }
#next.on { visibility: visible; }

/* languages (src/lang.js). Not Japanese: hidden until the table is in */
html.lang-wait #app, html.lang-wait .panel { visibility: hidden; }
.langsw { position: relative; display: inline-flex; align-items: center; gap: 4px; margin-top: 14px; padding: 5px 10px; border: 1.5px solid #1b1b1d; border-radius: 99px; font-size: 13px; font-weight: 800; }
.langsw svg { width: 15px; height: 15px; }
.langsw select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; cursor: pointer; }
: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; }
/* the titles, garden names and the monk: 明朝 in Japanese, each language's serif elsewhere */
:lang(ko) :is(h1, #say-t, #t-name, .r-head b, #r-gardens b, #r-comment) { font-family: "AppleMyungjo", "Noto Serif KR", "Noto Serif CJK KR", serif; }
:lang(zh-Hans) :is(h1, #say-t, #t-name, .r-head b, #r-gardens b, #r-comment) { font-family: "Songti SC", "Noto Serif SC", "Noto Serif CJK SC", serif; }
:lang(zh-Hant) :is(h1, #say-t, #t-name, .r-head b, #r-gardens b, #r-comment) { font-family: "Songti TC", "Noto Serif TC", "Noto Serif CJK TC", serif; }
:is(:lang(en), :lang(es), :lang(pt), :lang(fr), :lang(de)) :is(h1, #say-t, #t-name, .r-head b, #r-gardens b, #r-comment) { font-family: Georgia, "Times New Roman", "Noto Serif", serif; }
:is(:lang(en), :lang(es), :lang(pt), :lang(fr), :lang(de)) h1 { font-size: 44px; letter-spacing: 2px; }
:is(:lang(en), :lang(es), :lang(pt), :lang(fr), :lang(de)) .r-head b { letter-spacing: 1px; }
:is(:lang(en), :lang(es), :lang(pt), :lang(fr), :lang(de)) #t-name { font-size: 20px; }
:is(:lang(en), :lang(es), :lang(pt), :lang(fr), :lang(de)) #say-t { font-size: 16px; }
:is(:lang(en), :lang(es), :lang(pt), :lang(fr), :lang(de)) #r-gardens b { font-size: 12px; white-space: normal; overflow: visible; }
:is(:lang(en), :lang(es), :lang(pt), :lang(fr), :lang(de)) #r-post { font-size: 16px; }
