/* おにぎり：藍色の卓、檜のまな板、和紙の伝票、朱の判子。プレイ領域は全面の3D Canvas。 */
:root{--ai:#1c2438;--ai2:#2a3654;--washi:#f6efe1;--sumi:#2b2420;--shu:#c4432b;--shu2:#8a2c1b;--hinoki:#e0c193;
 --sans:system-ui,-apple-system,"Hiragino Sans","Yu Gothic UI","Apple SD Gothic Neo","Malgun Gothic","Noto Sans JP","Noto Sans KR",sans-serif;
 --serif:"Hiragino Mincho ProN","Yu Mincho","Noto Serif JP","AppleMyungjo","Noto Serif KR","Batang",Georgia,serif}
*{box-sizing:border-box}
html,body{margin:0;height:100%;overflow:hidden;background:var(--ai);color:var(--washi);font-family:var(--sans)}
button,select,a{font:inherit}
button{cursor:pointer}
:focus-visible{outline:3px solid #f2b04a;outline-offset:3px}
.hidden{display:none!important}
#gl{position:fixed;inset:0;width:100%;height:100%;display:block;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent}

/* 上部の道具（タイトル・結果のみ言語、プレイ中は音だけ左下） */
#bar{position:fixed;top:calc(10px + env(safe-area-inset-top));right:calc(10px + env(safe-area-inset-right));display:flex;gap:8px;align-items:center;z-index:8}
.brand{font-size:11px;font-weight:900;letter-spacing:.2em;color:#cfd6e6;margin-right:4px}
.brand i{font-style:normal;color:var(--shu)}
#language{border:0;border-radius:18px;padding:7px 10px;background:rgba(255,255,255,.14);color:#fff;font-size:13px}
#language option{color:#222}
.sound{width:36px;height:36px;border-radius:50%;border:0;background:rgba(255,255,255,.14);position:relative}
.sound span{position:absolute;left:11px;top:12px;width:8px;height:12px;background:#fff;clip-path:polygon(0 30%,40% 30%,100% 0,100% 100%,40% 70%,0 70%)}
.sound.on::after{content:"";position:absolute;left:21px;top:11px;width:6px;height:14px;border:2px solid #fff;border-left:0;border-radius:0 10px 10px 0}
.sound:not(.on)::after{content:"";position:absolute;left:20px;top:17px;width:10px;height:2px;background:#fff;transform:rotate(45deg)}
body.phase-play #bar,body.phase-finish #bar{top:auto;right:auto;bottom:calc(14px + env(safe-area-inset-bottom));left:calc(12px + env(safe-area-inset-left))}
body.phase-play .brand,body.phase-play #language,body.phase-finish .brand,body.phase-finish #language{display:none}

/* タイトル：米の塊とまな板が主役。言葉は題名と開始だけ */
#title{position:fixed;inset:0;pointer-events:none;display:flex;flex-direction:column;justify-content:space-between;align-items:center;padding:calc(58px + env(safe-area-inset-top)) 18px calc(34px + env(safe-area-inset-bottom))}
#title h1{margin:0;font-family:var(--serif);font-weight:700;font-size:clamp(26px,6.4vw,50px);line-height:1.3;text-align:center;color:#fff8ec;text-shadow:0 2px 0 rgba(0,0,0,.35),0 0 24px rgba(10,14,28,.6);max-width:14em;word-break:keep-all;overflow-wrap:anywhere}
.primary{pointer-events:auto;border:0;border-radius:999px;background:var(--shu);color:#fff;font-weight:800;font-size:20px;letter-spacing:.06em;padding:17px 46px;min-width:200px;box-shadow:0 6px 0 var(--shu2),0 10px 24px rgba(0,0,0,.3)}
.primary:active{transform:translateY(3px);box-shadow:0 3px 0 var(--shu2)}

/* プレイ中HUD：伝票（お題）、時間の輪、3個の進み、できた */
#hud{position:fixed;inset:0;pointer-events:none;z-index:4}
#order{position:absolute;top:calc(10px + env(safe-area-inset-top));left:calc(10px + env(safe-area-inset-left));background:var(--washi);color:var(--sumi);border-radius:4px 4px 10px 10px;padding:6px 10px 8px;display:flex;flex-direction:column;align-items:center;box-shadow:0 4px 0 rgba(0,0,0,.18),0 8px 18px rgba(0,0,0,.25);transform:rotate(-2deg);min-width:84px}
#order::before{content:"";position:absolute;left:0;right:0;top:-5px;height:6px;background:radial-gradient(circle at 4px 0,transparent 4px,var(--washi) 4.5px) 0 0/8px 6px repeat-x}
#orderIcon{width:66px;height:66px;display:block}
#orderPath{fill:#fffdf6;stroke:#5a4a3a;stroke-width:.07;stroke-linejoin:round}
#orderNori{fill:#1d2a1c}
#orderText{font-size:13px;line-height:1.25;text-align:center;white-space:nowrap}
#clock{position:absolute;top:calc(10px + env(safe-area-inset-top));right:calc(10px + env(safe-area-inset-right));display:flex;flex-direction:column;align-items:center;gap:6px}
#timer{--p:1;width:56px;height:56px;border-radius:50%;background:conic-gradient(#f2b04a calc(var(--p)*1turn),rgba(255,255,255,.16) 0);display:grid;place-items:center;transition:background .1s}
#timer::before{content:"";grid-area:1/1;width:44px;height:44px;border-radius:50%;background:var(--ai)}
#timerNum{grid-area:1/1;position:relative;font-family:var(--serif);font-size:20px;font-weight:700;color:#fff}
#timer.low{background:conic-gradient(var(--shu) calc(var(--p)*1turn),rgba(255,255,255,.16) 0)}
#pieces{display:flex;gap:5px}
#pieces i{width:18px;height:18px;border-radius:50% 50% 45% 45%;background:rgba(255,255,255,.18);font-style:normal;font-size:11px;font-weight:900;display:grid;place-items:center;color:var(--shu)}
#pieces i.now{background:rgba(255,255,255,.55)}
#pieces i.ok{background:#fffdf6}
#done{pointer-events:auto;position:absolute;right:calc(14px + env(safe-area-inset-right));bottom:calc(16px + env(safe-area-inset-bottom));width:86px;height:86px;border-radius:50%;border:0;background:var(--shu);color:#fff;font-weight:900;font-size:16px;box-shadow:0 5px 0 var(--shu2),0 8px 20px rgba(0,0,0,.35);padding:0 6px;line-height:1.15}
#done:active{transform:translateY(3px);box-shadow:0 2px 0 var(--shu2)}
body.phase-finish #done{opacity:.35;pointer-events:none}

/* 判子：1個ごとの評価 */
#stamp{position:fixed;left:50%;top:calc(11% + env(safe-area-inset-top));transform:translateX(-50%);z-index:6;display:flex;flex-direction:column;align-items:center;pointer-events:none}
#stampGrade{width:104px;height:104px;border-radius:50%;border:6px solid var(--shu);color:var(--shu);background:rgba(255,248,236,.92);display:grid;place-items:center;font-family:var(--serif);font-size:62px;font-weight:900;line-height:1;transform:rotate(-9deg);animation:stamp .32s cubic-bezier(.2,1.6,.4,1)}
#stampWord{margin-top:8px;font-weight:800;font-size:17px;color:#fff;text-shadow:0 2px 8px rgba(0,0,0,.7);white-space:nowrap}
@keyframes stamp{0%{transform:scale(2.2) rotate(-20deg);opacity:0}100%{transform:scale(1) rotate(-9deg);opacity:1}}

/* 結果：保存画像そのものを大きく見せる */
#result{position:fixed;inset:0;z-index:7;overflow-y:auto;-webkit-overflow-scrolling:touch;background:rgba(14,18,30,.8);padding:calc(54px + env(safe-area-inset-top)) 14px calc(30px + env(safe-area-inset-bottom))}
.sheet{max-width:460px;margin:0 auto;display:flex;flex-direction:column;align-items:center;gap:12px}
#preview{display:block;width:100%;aspect-ratio:1080/1350;border-radius:10px;background:var(--washi);box-shadow:0 10px 30px rgba(0,0,0,.45);-webkit-touch-callout:default}
.actions{display:flex;gap:10px;flex-wrap:wrap;justify-content:center;width:100%}
.actions button{flex:1 1 140px;border:0;border-radius:999px;background:var(--washi);color:var(--sumi);font-weight:800;padding:13px 16px}
#share{background:#0f1419;color:#fff}
.hint{margin:0;font-size:12px;line-height:1.55;color:#c9cfdd;text-align:center}
.hint.flash{color:#fff;animation:flash .8s}
@keyframes flash{0%,100%{opacity:1}50%{opacity:.4}}
#download{font-size:13px;color:#c9cfdd}
#download:not([href]),.actions button:disabled{opacity:.4;pointer-events:none}
#again{margin-top:4px}
#home{color:#f2c98a;font-size:14px;margin:6px 0 10px}
#nogl{position:fixed;inset:auto 16px 40% 16px;text-align:center;font-size:15px;line-height:1.6;background:rgba(0,0,0,.4);padding:16px;border-radius:12px;z-index:9}

@media (max-height:560px){#title{padding-top:calc(46px + env(safe-area-inset-top))}#title h1{font-size:clamp(22px,5vw,36px)}#orderIcon{width:48px;height:48px}#done{width:72px;height:72px;font-size:14px}}
