[hidden] { display: none !important; }
/* 言語。lang.js が描く前に <html lang> を決めるので、要らないほうの文言は最初から出ない */
html[lang="ja"] [lang="en"], html[lang="en"] [lang="ja"] { display: none !important; }
:root {
  --bg: #15181c;
  --panel: rgba(16, 20, 25, 0.84);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e9edf1;
  --sub: #9aa6b2;
  --water: #4fb3e8;
  --gold: #e3b65c;
  --red: #e5484d;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }

#site-header { display: flex; align-items: center; gap: 12px; max-width: 1200px; margin: 0 auto; padding: 12px 16px; }
#site-header .apps-link { color: var(--sub); text-decoration: none; font-size: 14px; display: inline-flex; align-items: center; min-height: 40px; }
#site-header .name { font-weight: 800; font-size: 18px; margin: 0; }
.header-sub { margin-left: 6px; font-size: 12px; font-weight: 500; color: var(--sub); }
.langsw { margin-left: auto; display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.langsw button { font-size: 12px; padding: 0 12px; min-height: 44px; min-width: 44px; border: 0; background: none; color: var(--sub); }
.langsw button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.12); color: var(--text); font-weight: 800; }

#app { padding: 0 16px; }
#stage { position: relative; max-width: 1200px; margin: 0 auto; aspect-ratio: 16 / 9; max-height: 76svh; width: 100%; border-radius: 12px; overflow: hidden; background: #262b31; user-select: none; -webkit-user-select: none; }
#view { display: block; width: 100%; height: 100%; touch-action: none; }

/* ── 操作の板（共通） ── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(6px); }
#hud button, #mute button { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; min-height: 36px; font-size: 13px; white-space: nowrap; }
#hud button:hover, #mute button:hover { background: rgba(255, 255, 255, 0.16); }
#hud button.ghost { background: transparent; border-color: transparent; color: var(--sub); }
#hud button.ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }
#hud > * { position: absolute; }

/* 上の帯: 戻る・品の名前・時計・進み具合・鑑定 */
#topbar { left: 10px; right: 10px; top: 10px; display: flex; align-items: center; gap: 14px; padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(6px); }
.who { display: flex; flex-direction: column; min-width: 0; }
#item-title { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stars { color: var(--gold); font-size: 11px; letter-spacing: 1px; }
#clock { display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; padding-left: 14px; border-left: 1px solid var(--line); }
#time { font-size: 22px; font-weight: 800; min-width: 4.4em; }
#par { color: var(--sub); font-size: 12px; white-space: nowrap; }
#clock.over #time { color: #ff9a6a; }
#clock.stop #time { color: #9be29b; }
#overall { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 120px; }
#overall-bar { flex: 1; height: 8px; background: rgba(255, 255, 255, 0.1); border-radius: 99px; overflow: hidden; }
#overall-bar i, #parts .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #3a95c9, #7fd3ff); border-radius: inherit; transition: width 0.15s; }
#overall-num { font-variant-numeric: tabular-nums; font-weight: 800; min-width: 3em; text-align: right; }
.acts { display: flex; gap: 6px; }
#appraise.ready { background: var(--gold); color: #241a06; border-color: var(--gold); font-weight: 800; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(227, 182, 92, 0.25); } }
#parts-btn { display: none; }

/* 上の帯の高さは品名の長さと言語で変わる。--bar-bottom は main.js が帯を測って入れる */
#parts { right: 10px; top: calc(var(--bar-bottom, 62px) + 8px); margin: 0; padding: 8px 10px; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: 250px; font-size: 13px; backdrop-filter: blur(6px); }
#parts li { display: grid; grid-template-columns: 1fr 44px 56px; align-items: center; gap: 6px; padding: 3px 0; }
#parts .nm { overflow-wrap: anywhere; line-height: 1.25; }
#parts .bar { height: 5px; background: rgba(255, 255, 255, 0.1); border-radius: 99px; overflow: hidden; }
#parts .pc { text-align: right; font-variant-numeric: tabular-nums; color: var(--sub); white-space: nowrap; }
#parts li.done .nm, #parts li.done .pc { color: #9be29b; }
#parts li.done .pc { font-weight: 700; }
#parts li.done .bar i { background: #6cc66c; }

#cam { right: 10px; bottom: 80px; display: flex; flex-direction: column; gap: 6px; }
#cam button { width: 44px; height: 40px; padding: 0; font-size: 16px; }
#cam #home { font-size: 12px; }

#bottom { left: 50%; bottom: 10px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; }
#tools { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 5px; backdrop-filter: blur(6px); }
#hud .tool { display: flex; align-items: center; gap: 8px; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 0 14px; min-height: 44px; font-size: 14px; }
#hud .tool:hover { background: rgba(255, 255, 255, 0.08); }
#hud .tool.on { background: rgba(79, 179, 232, 0.2); border-color: var(--water); }
.tool .key { font-size: 11px; color: var(--sub); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.ico { width: 18px; height: 18px; display: inline-block; flex: none; }
.ico-wide { background: radial-gradient(circle at 20% 50%, #cfe9ff 2px, transparent 3px), conic-gradient(from 60deg at 10% 50%, transparent 0 0deg, rgba(127, 211, 255, 0.85) 0 60deg, transparent 60deg); }
.ico-jet { background: linear-gradient(90deg, #7fd3ff, #e6f4ff) center / 100% 3px no-repeat; }
.ico-chem { background: radial-gradient(circle at 35% 40%, #b9f0a0 3px, transparent 4px), radial-gradient(circle at 65% 65%, #8fd877 4px, transparent 5px); }
.ico-steam { background: radial-gradient(circle at 30% 70%, rgba(244, 246, 248, 0.95) 3px, transparent 4px), radial-gradient(circle at 60% 45%, rgba(244, 246, 248, 0.8) 4px, transparent 5px), radial-gradient(circle at 40% 22%, rgba(244, 246, 248, 0.6) 3px, transparent 4px); }
.ico-paint { background: linear-gradient(135deg, #e4d6b0 0 33%, #781c24 33% 66%, #1e4634 66%); border-radius: 50%; }
#paints { display: flex; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 6px 10px; }
#hud .swatch { width: 30px; height: 30px; min-height: 0; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); padding: 0; }
#hud .swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--water); }

#mute { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 6px; }
#mute button[aria-pressed="false"] { color: var(--sub); text-decoration: line-through; }
#result:not([hidden]) ~ #mute, #help:not([hidden]) ~ #mute { display: none; }

#toast { position: absolute; left: 50%; top: calc(var(--bar-bottom, 62px) + 14px); transform: translateX(-50%); background: rgba(10, 12, 15, 0.88); border: 1px solid var(--line); padding: 8px 14px; border-radius: 99px; font-size: 14px; pointer-events: none; max-width: calc(100% - 32px); text-align: center; }
#loading { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(14, 16, 19, 0.7); font-weight: 800; font-size: 18px; z-index: 5; }

/* ── 品選び ── */
#menu { position: absolute; inset: 0; display: flex; flex-direction: column; background: radial-gradient(ellipse at center, rgba(30, 36, 43, 0.85), rgba(14, 16, 19, 0.97)); }
/* 音の釦は品選びのあいだ見出しの並びに入る（main.js の placeSound）。浮かせて右をあけておくと、釦の幅が変わったときにタブへかぶる */
.menu-head { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "title tabs snd"; align-items: center; gap: 10px 18px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.menu-head .menu-title { grid-area: title; }
.menu-head #tabs { grid-area: tabs; }
.menu-head #mute { grid-area: snd; position: static; }
#menu .menu-title { margin: 0; font-size: 22px; white-space: nowrap; }
#tabs { display: flex; gap: 6px; flex: 1; }
#tabs button { flex: 1; max-width: 150px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 8px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 10px; color: var(--sub); }
#tabs button b { color: var(--gold); font-size: 15px; letter-spacing: 1px; }
#tabs button small { font-size: 11px; font-variant-numeric: tabular-nums; }
#tabs button.on { background: rgba(79, 179, 232, 0.18); border-color: var(--water); color: var(--text); }
.cards { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; padding: 14px 18px 18px; align-content: start; }
.card { background: #1f252c; border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 5px; text-align: left; transition: transform 0.12s, border-color 0.12s; }
.card:hover { transform: translateY(-2px); border-color: var(--water); }
.card b { font-size: 14px; line-height: 1.35; }
.pic { position: relative; display: block; aspect-ratio: 4 / 3; border-radius: 8px; background: linear-gradient(#3a4652, #262c33); overflow: hidden; }
.pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.place { position: absolute; left: 6px; top: 6px; border-radius: 4px; padding: 1px 7px; color: #fff; font-size: 12px; font-weight: 700; }
.place[data-place="海"] { background: #2b6ca3; }
.place[data-place="川"] { background: #5d7a3a; }
.place[data-place="蔵"] { background: #7a6248; }
.place[data-place="庭"] { background: #3f7d5c; }
.badge { position: absolute; right: 6px; top: 6px; font-weight: 900; font-size: 15px; border-radius: 6px; padding: 0 8px; color: #241a06; background: #9aa6b2; }
.rec { font-size: 12px; color: var(--sub); font-variant-numeric: tabular-nums; }
.rank { font-weight: 900; border-radius: 6px; color: #241a06; background: #9aa6b2; }
[data-rank="S"] { background: #f2c14e !important; }
[data-rank="A"] { background: #e3b65c !important; }
[data-rank="B"] { background: #9fd3a0 !important; }
[data-rank="C"] { background: #9ec4e0 !important; }

/* ── 操作の案内 ── */
#hud .tool.new { position: relative; border-color: var(--gold); }
#hud .tool.new::after { content: "新"; position: absolute; top: -8px; right: -6px; background: var(--gold); color: #241a06; font-size: 11px; font-weight: 900; border-radius: 99px; padding: 0 6px; line-height: 18px; }
html[lang="en"] #hud .tool.new::after { content: "NEW"; font-size: 10px; }
#help { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(8, 10, 13, 0.6); padding: 16px; z-index: 4; }
.help-card { width: min(460px, 100%); background: #1f252c; border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.help-card h2 { margin: 0 0 10px; font-size: 18px; }
.help-card dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 10px; font-size: 14px; }
.help-card dt { color: var(--water); font-weight: 700; }
.help-card dd { margin: 0; }
.help-card p { margin: 0 0 14px; font-size: 13px; color: var(--sub); line-height: 1.6; }
.help-card button { width: 100%; min-height: 44px; border-radius: 10px; border: 0; background: var(--water); color: #0b1a24; font-weight: 800; }

/* ── 鑑定 ── */
#result { position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; padding: 16px 4%; background: linear-gradient(90deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.55)); }
.sheet { position: relative; width: min(380px, 100%); max-height: 100%; overflow-y: auto; background: #f3eee2; color: #2a241b; border-radius: 6px; padding: 22px 22px 18px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45); font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif; }
.sheet .stamp { position: absolute; right: 16px; top: 14px; color: #b3302a; border: 2px solid #b3302a; border-radius: 4px; padding: 2px 6px; font-weight: 800; transform: rotate(8deg); }
.sheet h2 { margin: 0 64px 4px 0; font-size: 22px; }
#r-note { margin: 0 0 12px; font-size: 13px; color: #6b5f4c; }
.sheet .base, .sheet .price { display: flex; justify-content: space-between; align-items: baseline; }
.sheet .base { font-size: 14px; color: #6b5f4c; border-bottom: 1px solid #d8cfbc; padding-bottom: 6px; }
#r-lines { list-style: none; margin: 6px 0; padding: 0; font-size: 14px; }
#r-lines li { display: grid; grid-template-columns: 1fr auto 96px; gap: 8px; padding: 3px 0; }
#r-lines small { color: #8a7d66; }
#r-lines b { text-align: right; color: #a23a2f; font-weight: 600; }
#r-lines li.plus b { color: #2f7a46; }
.sheet .price { border-top: 2px solid #2a241b; padding-top: 8px; margin-top: 6px; }
.sheet .price b { font-size: 30px; }
.sheet .score { display: flex; gap: 12px; align-items: center; margin-top: 10px; padding-top: 8px; border-top: 1px dashed #c9bfa8; }
.sheet .rank { font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif; font-size: 34px; padding: 2px 14px; }
#r-score { list-style: none; margin: 0; padding: 0; flex: 1; font-size: 13px; }
#r-score li { display: grid; grid-template-columns: 4em 1fr auto; gap: 6px; padding: 1px 0; }
html[lang="en"] #r-score li { grid-template-columns: 5.5em 1fr auto; }
#r-score small { color: #8a7d66; font-size: 12px; }
#r-score li:last-child { font-weight: 800; font-size: 15px; border-top: 1px solid #d8cfbc; margin-top: 2px; padding-top: 3px; }
#r-best { margin: 4px 0 10px; font-size: 13px; color: #8a6d2a; min-height: 1em; }
.sheet .share { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.sheet .share button { min-height: 40px; border-radius: 6px; border: 1px solid #c9bfa8; background: #ebe4d3; color: #2a241b; font-size: 13px; font-weight: 700; font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif; white-space: nowrap; }
.sheet .share button:hover { background: #e0d7c2; }
#sh-x { background: #1a1a1a !important; color: #fff !important; border-color: #1a1a1a !important; }
#sh-line { background: #06c755 !important; color: #fff !important; border-color: #06c755 !important; }
.sheet .row { display: flex; gap: 6px; }
.sheet .row button { flex: 1; min-height: 44px; border-radius: 6px; border: 1px solid #b9ad94; background: #fff; color: #2a241b; font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif; }
.sheet .row button.primary { background: #2a241b; color: #f3eee2; border-color: #2a241b; }

#guide-section { max-width: 1200px; margin: 20px auto; padding: 0 4px; color: #c9d1d9; font-size: 15px; line-height: 1.8; }
#guide-section h2 { font-size: 18px; }
#guide-section h3 { font-size: 15px; margin: 14px 0 4px; color: var(--text); }
.related-apps, #ad-section { max-width: 1200px; margin: 28px auto 0; padding: 0 4px; }
.related-apps-title { font-size: 18px; margin: 0 0 10px; }
.related-apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(180px, calc(50% - 5px)), 1fr)); gap: 10px; }
.related-app-link.ra-card { display: flex; flex-direction: column; overflow: hidden; border-radius: 10px; border: 1px solid var(--line); background: #1f252c; color: var(--text); text-decoration: none; transition: transform 0.15s, border-color 0.15s; }
.related-app-link.ra-card:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.2); }
.ra-card .ra-thumb { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
.ra-card .ra-name { display: block; padding: 8px 12px 10px; font-size: 13px; font-weight: 700; line-height: 1.4; }
#site-footer { max-width: 1200px; margin: 0 auto; padding: 24px 16px 40px; color: var(--sub); font-size: 13px; text-align: center; }
.footer-links { display: flex; justify-content: center; gap: 10px; align-items: center; }
.footer-link { color: var(--sub); text-decoration: none; display: inline-flex; align-items: center; min-height: 40px; }
.footer-copy { margin: 6px 0 0; }
.footer-refs { margin: 6px 0 0; }
.footer-refs a { color: var(--sub); }

/* ── 中くらいの幅: 帯を 2 段に ── */
@media (max-width: 1000px) {
  #topbar { flex-wrap: wrap; row-gap: 6px; }
  #overall { order: 5; flex-basis: 100%; }
  .cards { grid-template-columns: repeat(4, 1fr); }
  /* 舞台が低くなり、右の部品の一覧がカメラの釦に、下の道具の帯が音の釦にかぶる。一覧は «部品» で開き、釦は帯の上へ */
  .menu-head { grid-template-columns: 1fr auto; grid-template-areas: "title snd" "tabs tabs"; }
  #parts-btn { display: inline-block; }
  #parts { display: none; left: 10px; right: auto; }
  #parts.open { display: block; }
  #cam { bottom: 120px; }
  #mute { bottom: 72px; }
}

/* ── スマホ ── */
@media (max-width: 760px) {
  #app { padding: 0 8px; }
  #stage { aspect-ratio: 3 / 4.6; max-height: 86svh; border-radius: 10px; }
  #topbar { left: 6px; right: 6px; top: 6px; display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "back who clock" "prog prog prog" "acts acts acts"; gap: 6px 8px; padding: 6px; }
  #hud button, #mute button { min-height: 40px; }
  #back { grid-area: back; padding: 0 8px; }
  .who { grid-area: who; }
  /* 英語の品名は長い（A car dug out of the mud）。狭い幅では «…» で切らず 2 行に折る */
  #item-title { white-space: normal; overflow: visible; line-height: 1.2; }
  #clock { grid-area: clock; border: 0; padding: 0; flex-direction: column; align-items: flex-end; gap: 0; }
  #time { font-size: 18px; min-width: 0; }
  #par { font-size: 11px; }
  #overall { grid-area: prog; order: 0; }
  .acts { grid-area: acts; }
  .acts button { flex: 1; padding: 0 4px; font-size: 12px; }
  #parts-btn { display: inline-block; }
  #parts { display: none; left: 6px; right: auto; width: 230px; font-size: 12px; padding: 6px 8px; }
  #parts.open { display: block; }
  #parts li { grid-template-columns: 1fr 36px 52px; }
  #bottom { left: 6px; right: 6px; bottom: 6px; transform: none; }
  #tools { width: 100%; gap: 2px; padding: 4px; }
  #hud .tool { flex: 1; flex-direction: column; justify-content: center; gap: 2px; padding: 4px 2px; font-size: 11px; }
  .tool .key { display: none; }
  #paints { position: absolute; right: 0; bottom: 120px; display: grid; grid-template-columns: repeat(2, 40px); gap: 6px; padding: 6px; border-radius: 12px; }
  #hud .swatch { width: 40px; height: 40px; }
  #cam { right: 6px; bottom: 70px; flex-direction: row; }
  #cam button { width: 44px; height: 40px; }
  #mute { left: 6px; bottom: 70px; }
  #toast { font-size: 12px; border-radius: 10px; }
  #result { justify-content: center; align-items: flex-end; background: rgba(0, 0, 0, 0.35); padding: 8px; }
  .sheet { padding: 16px; }
  .sheet h2 { font-size: 18px; }
  .sheet .price b { font-size: 24px; }
  .menu-head { gap: 8px; padding: 10px 10px 8px; }
  #menu .menu-title { font-size: 18px; }
  .header-sub { display: none; }
  #tabs { gap: 4px; }
  /* タブの幅は★の数で決まる（★5 は★1 より広い）。幅 340px で★1・★2 が 39px まで縮んだので、
     中身の幅を土台に余りを分け（flex-basis: auto）、★の字間を詰める。min-width を書くと中身より狭くなり★がはみ出す */
  #tabs button { padding: 4px 2px; flex: 1 1 auto; }
  #tabs button b { font-size: 13px; letter-spacing: 0; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 10px; }
  .card b { font-size: 13px; }
}
