/* タイ語タイピング（/typing/）。ゲームの画面（.tg-stage）は、いつも夜の色で出す（ライト・ダークどちらでも同じ）。
   あそんでいる間（body.tg-on）は、ヘッダーなどをかくして、画面いっぱいをゲームと画面のキーボードに使う。 */
.tg-app{margin-top:12px;background:var(--surface);border:2px solid var(--edge);border-radius:var(--r);box-shadow:var(--pop);padding:20px;scroll-margin-top:16px}
.tg-app button{touch-action:manipulation;-webkit-tap-highlight-color:transparent}

/* はじめの画面 */
.tg-sec+.tg-sec{margin-top:20px}
.tg-h{font-size:1.1rem;margin:0}
.tg-gh{font-size:.85rem;color:var(--muted);font-weight:700;margin:12px 0 0}
.tg-opts{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}
.tg-opt{min-height:44px;padding:6px 14px;border:1.5px solid var(--line);border-radius:10px;background:var(--surface);font-weight:700;font-size:.92rem;text-align:left}
.tg-opt:hover{border-color:var(--saffron)}
.tg-opt[aria-pressed="true"]{background:var(--saffron-soft);border-color:var(--saffron);color:var(--saffron)}
.tg-toggle::before{content:"";display:inline-block;width:14px;height:14px;margin-right:8px;border:2px solid var(--muted);border-radius:4px;vertical-align:-2px}
.tg-toggle[aria-pressed="true"]::before{background:var(--saffron);border-color:var(--saffron);box-shadow:inset 0 0 0 2px var(--surface)}
.tg-rules ul{margin:8px 0 0;padding-left:1.2em;font-size:.92rem}
.tg-go{display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;margin-top:24px}
.tg-start{min-width:220px;min-height:54px;font-size:1.25rem}
.tg-best{margin:0 0 0 auto;font-size:.9rem;color:var(--muted);font-weight:700}

/* あそぶ画面 */
.tg-on .site-header,.tg-on .site-footer,.tg-on .fab-menu,.tg-on .breadcrumb,.tg-on .ptabs,.tg-on .tg-intro,.tg-on .tg-below{display:none}
.tg-on main.wrap{max-width:1120px;padding-left:6px;padding-right:6px}
.tg-on .tg-app{display:flex;flex-direction:column;margin-top:0;padding:6px 10px max(8px,env(safe-area-inset-bottom));height:100vh;height:100dvh;border-radius:0;border-width:0;box-shadow:none}
.tg-hud{display:flex;align-items:center;gap:16px;font-weight:700;font-variant-numeric:tabular-nums;min-height:40px;flex:none}
.tg-lives i{font-style:normal;color:#e5484d;margin-right:2px;font-size:1.35rem}
.tg-lives i.is-lost{color:var(--line)}
.tg-prog{color:var(--muted);font-size:1.1rem;min-width:3ch}
.tg-prog.is-last{color:var(--bad)}
.tg-combo{color:var(--ok);font-size:.9rem}
.tg-score{margin-left:auto;font-family:var(--f-num);font-size:1.3rem}
.tg-pause{min-height:36px;border:1.5px solid var(--line);background:var(--surface);border-radius:99px;padding:2px 16px;font-size:.85rem;font-weight:700}

.tg-stage{--u:8px;position:relative;overflow:hidden;margin-top:4px;border-radius:12px;color:#fff;width:100%;flex:1 1 0;min-height:170px;user-select:none;-webkit-user-select:none}
.tg-bg,.tg-fx,.tg-layer{position:absolute;inset:0;width:100%;height:100%}
.is-obake>.tg-bg{background:
  radial-gradient(circle at 84% 13%,#fff6d0 0,#fff6d0 4%,rgba(255,246,208,.2) 4.3%,rgba(255,246,208,0) 11%),
  linear-gradient(#0f1330 0%,#2a2556 31%,#22382c 31.2%,#1b2e24 65%,#142219 100%)}
/* 遠くの家・お寺・ヤシとバナナの木（地面の線の上） */
.tg-scene{position:absolute;left:0;bottom:69%;width:100%;height:22%}
/* まもる線：家を守る白い糸（サーイシン）。結び目つきの白い糸を、たてに張る */
.tg-line{position:absolute;pointer-events:none;transition:opacity .3s,filter .3s}
.is-obake .tg-line{top:31%;bottom:0;left:14%;width:3px;background:repeating-linear-gradient(180deg,#fff 0,#fff calc(var(--u)*3),rgba(255,255,255,.4) calc(var(--u)*3),rgba(255,255,255,.4) calc(var(--u)*3.6));box-shadow:0 0 10px rgba(255,255,255,.7)}
.is-obake[data-lives="2"] .tg-line{opacity:.7}
.is-obake[data-lives="1"] .tg-line{opacity:.45;box-shadow:0 0 10px #ff6b5e}
.tg-stage[data-lives="0"] .tg-line{opacity:0}

.tg-input{position:absolute;left:0;top:0;width:1px;height:1px;padding:0;border:0;opacity:0;font-size:16px;color:transparent;caret-color:transparent;background:transparent}
.tg-enemy,.tg-player{position:absolute;left:0;top:0;will-change:transform}
.tg-enemy{display:flex;flex-direction:column-reverse;align-items:center;gap:2px;transition:opacity .3s}
.tg-sprite,.tg-player{width:clamp(28px,calc(var(--u)*6),58px)}
.tg-sprite svg,.tg-player svg{display:block;width:100%;height:auto;overflow:visible}
.tg-label{background:rgba(8,10,26,.86);border:2px solid rgba(255,255,255,.28);border-radius:10px;padding:0 10px 3px;text-align:center;white-space:nowrap;line-height:1.5}
.tg-th{font-size:clamp(19px,calc(var(--u)*3),30px);font-weight:500}
.tg-th .is-done{color:#6ee7a8}
.tg-th .is-cur{text-decoration:underline;text-decoration-color:#ffd84d;text-underline-offset:5px}
.tg-rom{display:flex;gap:8px;justify-content:center;align-items:baseline;font-size:clamp(11px,calc(var(--u)*1.5),14px);line-height:1.3}
.tg-rom .rom{color:#c3c7d6;font-size:1em}
.tg-cap{font-family:var(--f-mono);color:#ffd84d;font-weight:500}
.tg-enemy.is-target{z-index:50!important}
.tg-enemy.is-target .tg-label{border-color:#ffd84d;box-shadow:0 0 0 3px rgba(255,216,77,.28)}
.tg-enemy.is-dead,.tg-enemy.is-gone{opacity:0}
.tg-enemy.is-dead .tg-sprite{transform:scale(1.5);filter:brightness(2.2);transition:transform .3s,filter .3s}
.tg-enemy.is-miss .tg-label,.tg-panel.is-miss{animation:tg-shake .25s}
.tg-stage.is-hit{animation:tg-hit .4s}
@keyframes tg-shake{25%{translate:-5px 0}75%{translate:5px 0}}
@keyframes tg-hit{30%{box-shadow:inset 0 0 0 6px #ff6b5e,inset 0 0 60px rgba(255,107,94,.6)}}
@keyframes tg-float{50%{translate:0 -4px}}
@media (prefers-reduced-motion:no-preference){.tg-sprite{animation:tg-float 1.8s ease-in-out infinite}}

.tg-overlay{position:absolute;inset:0;z-index:100;display:grid;place-content:center;justify-items:center;gap:16px;background:rgba(6,8,20,.78);text-align:center}
.tg-overlay h2{font-size:1.7rem;margin:0}
.tg-actions{display:flex;flex-wrap:wrap;gap:10px;justify-content:center}
.tg-actions .btn{min-height:50px;min-width:140px;font-size:1rem}

/* いまねらっていることば */
.tg-panel{display:flex;align-items:center;justify-content:center;gap:4px 28px;flex-wrap:wrap;flex:none;min-height:70px;margin-top:8px;padding:4px 16px;border:1px solid var(--line);border-radius:12px;background:var(--sunk)}
.tg-hint{margin:0;color:var(--muted);font-size:.92rem;text-align:center;line-height:1.5}
.tg-p-word{text-align:center}
.tg-p-word .th{font-size:1.9rem;line-height:1.5;white-space:nowrap}
.tg-p-word .is-done{color:var(--ok)}
.tg-p-word .is-cur{text-decoration:underline;text-decoration-color:var(--gold);text-underline-offset:6px}
.tg-p-sub{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;font-size:.85rem;color:var(--muted)}
.tg-p-next{display:grid;justify-items:center;line-height:1.2}
.tg-p-next small{font-size:.72rem;color:var(--muted)}
.tg-p-next b{font-size:1.7rem;font-weight:500;line-height:1.4}
kbd{font-family:var(--f-mono);font-size:.85rem;padding:1px 8px;border:1px solid var(--line);border-bottom-width:3px;border-radius:6px;background:var(--surface);white-space:nowrap}
.tg-keys{flex:none;font-size:.8rem;color:var(--muted);margin:8px 0 0;text-align:center}

/* 画面のキーボード（ケーッマニー配列）。キーの高さは画面の高さに合わせる */
.tg-kb{flex:none;display:grid;gap:5px;margin-top:8px;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
.tg-kb-row{display:flex;justify-content:center;gap:.6%}
.tg-key{position:relative;flex:0 0 7.1%;height:clamp(40px,7vh,58px);padding:0;border:1px solid var(--line);border-radius:8px;background:var(--surface);box-shadow:0 3px 0 var(--line);display:grid;place-content:center;line-height:1.05}
.tg-key .th{font-size:clamp(1rem,2.6vw,1.45rem)}
.tg-key small{font-family:var(--f-mono);font-size:clamp(.55rem,1.2vw,.7rem);color:var(--muted)}
.tg-key-wide{flex-basis:10%;min-width:0;overflow:hidden;padding:0 2px;font-size:clamp(.62rem,1.5vw,.85rem);font-weight:700;word-break:keep-all;line-height:1.2}
.tg-key.is-home::after{content:"";position:absolute;left:35%;right:35%;bottom:8%;height:3px;border-radius:2px;background:var(--muted);opacity:.5}
.tg-key.is-on{background:var(--saffron-soft);border-color:var(--saffron)}
.tg-key.is-next{background:#ffe48a;border-color:#e0b93a;box-shadow:0 3px 0 #e0b93a;color:#1f2333}
.tg-key.is-next small{color:#5f6577}
.tg-key.is-down{transform:translateY(2px);box-shadow:0 1px 0 var(--line)}
.has-kb .tg-panel{min-height:56px}
.has-kb .tg-p-word .th{font-size:1.5rem}

/* 結果 */
.tg-result{text-align:center;padding-block:10px}
.tg-result h2{font-size:1.5rem;margin:0}
.tg-stars{font-size:2.6rem;line-height:1.3;letter-spacing:6px}
.tg-stars i{font-style:normal;color:var(--line)}
.tg-stars i.is-on{color:var(--gold)}
.tg-bigscore{font-family:var(--f-num);font-size:3.6rem;line-height:1.15}
.tg-bigscore small{display:block;font-family:var(--f-ja);font-size:.85rem;color:var(--muted);font-weight:700}
.tg-newbest{display:inline-block;font-size:.8rem;font-weight:700;color:var(--ok);background:var(--ok-bg);border-radius:99px;padding:2px 12px}
.tg-msg{margin:10px 0 0}
.tg-stats{display:flex;justify-content:center;flex-wrap:wrap;gap:10px;margin:18px 0 0}
.tg-stats div{min-width:124px;border:1px solid var(--line);border-radius:12px;padding:8px 14px}
.tg-stats dt{font-size:.8rem;color:var(--muted)}
.tg-stats dd{margin:0;font-size:1.4rem;font-weight:700;font-variant-numeric:tabular-nums}
.tg-words{list-style:none;padding:0;display:flex;flex-wrap:wrap;justify-content:center;gap:8px;margin:10px 0 0}
.tg-words li{display:grid;justify-items:center;gap:2px;min-width:90px;padding:6px 12px;border:1px solid var(--line);border-radius:10px}
.tg-words b{font-size:1.4rem;font-weight:500;line-height:1.5}
.tg-words small{font-size:.78rem;color:var(--muted)}
.tg-result .tg-actions{margin-top:24px}

/* ページ */
.tg-below{margin-top:28px}
.tg-help{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);padding:12px 18px}
.tg-help summary{cursor:pointer;font-weight:700}
.tg-help ul{margin:10px 0 0;padding-left:1.2em;font-size:.92rem}
.tg-chart{display:grid;gap:4px;margin-top:14px;overflow-x:auto}
.tg-chart div{display:flex;gap:4px}
.tg-chart div:nth-child(2){padding-left:3%}.tg-chart div:nth-child(3){padding-left:5%}.tg-chart div:nth-child(4){padding-left:8%}
.tg-chart span{flex:0 0 auto;width:44px;display:grid;justify-items:center;border:1px solid var(--line);border-radius:6px;padding:2px 0;line-height:1.2}
.tg-chart b{font-weight:500;font-size:1.05rem}
.tg-chart i{font-style:normal;font-size:.75rem;color:var(--saffron)}
.tg-chart small{font-family:var(--f-mono);font-size:.62rem;color:var(--muted)}
.tg-ghosts{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}
.tg-ghost{display:grid;grid-template-columns:72px 1fr;gap:12px;align-items:center;border:1px solid var(--line);border-radius:var(--r);padding:10px 14px}
.tg-ghost .art{background:#1b2040;border-radius:10px;padding:8px 10px}
.tg-ghost svg{display:block;width:100%;height:auto}
.tg-ghost h3{margin:0;font-size:1rem}
.tg-ghost h3 .th{font-size:1.15rem;margin-right:6px}
.tg-ghost p{margin:2px 0 0;font-size:.85rem}
.theme-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:16px}
.theme-card{display:grid;grid-template-rows:auto 1fr;overflow:hidden;background:var(--surface);border:2px solid var(--edge);border-radius:var(--r);box-shadow:var(--pop);color:var(--ink);text-decoration:none}
a.theme-card:hover{transform:translate(-1px,-1px)}
.theme-art{position:relative;height:150px;min-height:0;margin:0;border-radius:0;display:flex;align-items:center;justify-content:center;gap:24px}
.theme-art>svg{position:relative;width:56px;height:auto;overflow:visible}
.theme-art .tg-label{position:relative;flex:none;color:#fff;font-size:1.4rem;padding:2px 16px 4px}
.theme-body{padding:14px 20px 18px}
.theme-body h3{font-size:1.2rem;margin:0}
.theme-body p{margin:6px 0 0;font-size:.92rem}
.theme-go{display:inline-block;margin-top:8px;font-weight:700;color:var(--jade)}
.theme-soon{display:grid;place-content:center;text-align:center;border:2px dashed var(--line);border-radius:var(--r);padding:20px;color:var(--muted);font-size:.9rem}

@media (max-width:760px){
  .tg-app{padding:14px 12px}
  .theme-grid,.tg-ghosts{grid-template-columns:1fr}
  .tg-best{margin-left:0}
  .tg-hud{gap:10px}
  .tg-on .tg-app{padding-inline:2px}
  .tg-kb{gap:4px}
  .tg-key{border-radius:6px}
  .tg-panel{gap:4px 16px}
}
.tg-feat{margin:0;padding-left:1.2em;font-size:.92rem}
.tg-feat li+li{margin-top:6px}
.tg-below .side-links{margin-top:20px}
