:root {
  --bg: #14101c; --panel: #241c33; --ink: #fff7ea; --clay: #f3efe6;
  --red: #e8412d; --yellow: #ffc928; --blue: #3a7bff; --radius: 14px;
  --font: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); overflow: hidden; overscroll-behavior: none; }
[hidden] { display: none !important; }
#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#hud-root { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud-root > * { pointer-events: auto; }

.screen { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom); overflow-y: auto; }
.screen-opaque { background: radial-gradient(ellipse at 50% 0%, #3a2a55 0%, var(--bg) 70%); }
.screen-dim { background: rgba(10, 6, 18, .55); }

/* ボタン: 粘土っぽい厚み */
.btn { font: inherit; font-weight: 900; font-size: 1.1rem; letter-spacing: .04em; color: #fff; background: var(--red); border: 0; border-radius: 999px; padding: .7em 1.4em; cursor: pointer;
  box-shadow: 0 6px 0 #a02a1b, 0 10px 18px rgba(0,0,0,.45); transition: transform .08s, box-shadow .08s; touch-action: manipulation; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 #a02a1b, 0 3px 8px rgba(0,0,0,.4); }
.btn { white-space: nowrap; }
.btn-big { font-size: clamp(1.2rem, 5vw, 1.6rem); padding: .75em 1.8em; background: var(--yellow); color: #3b2300; box-shadow: 0 7px 0 #b07f00, 0 12px 22px rgba(0,0,0,.5); }
.btn-big:active { box-shadow: 0 1px 0 #b07f00, 0 3px 8px rgba(0,0,0,.4); }
.btn-small { font-size: .95rem; padding: .55em 1.1em; }
.btn-ghost { background: #4a3d66; box-shadow: 0 5px 0 #2c2340, 0 8px 14px rgba(0,0,0,.4); }
.btn-ghost:active { box-shadow: 0 1px 0 #2c2340; }

/* タイトル */
#screen-title { background: linear-gradient(180deg, rgba(10,6,18,.15), rgba(10,6,18,.7)); }
.title-box { text-align: center; max-width: 640px; }
.title-sub { margin: 0; letter-spacing: .5em; color: var(--yellow); font-weight: 900; }
.logo { margin: .1em 0 .2em; font-size: clamp(2.8rem, 12vw, 6.5rem); line-height: .95; font-weight: 900; font-style: italic; color: var(--clay);
  text-shadow: 0 5px 0 #b9b1a0, 0 9px 0 #8d8676, 0 18px 24px rgba(0,0,0,.6); transform: rotate(-3deg); }
.logo span { display: block; }
.logo span:last-child { color: var(--red); text-shadow: 0 5px 0 #8a2417, 0 9px 0 #5e170e, 0 18px 24px rgba(0,0,0,.6); }
.title-copy { font-size: 1.15rem; line-height: 1.7; font-weight: 700; text-shadow: 0 2px 6px #000; }
.title-copy small { color: var(--yellow); font-size: 1rem; }
.title-help { margin-top: 1.4rem; font-size: .75rem; opacity: .75; text-shadow: 0 1px 4px #000; }

/* 対戦相手選択 */
.select-wrap { width: min(980px, 100%); margin: auto; padding: 14px 0 28px; }
.select-head { display: flex; align-items: center; gap: 12px; }
.select-head h2 { margin: 0; font-size: clamp(1.3rem, 4vw, 2rem); font-weight: 900; font-style: italic; }
.select-me { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin: 14px 0; padding: 12px; background: var(--panel); border-radius: var(--radius); }
.select-me canvas { border-radius: 12px; background: #3a3050; max-width: 100%; }
#me-face { background: var(--clay); width: 96px; height: 96px; border-radius: 50%; }
.select-me-info { flex: 1 1 200px; }
.nick { font-size: clamp(1.2rem, 4vw, 1.8rem); font-weight: 900; color: var(--yellow); }
.comment { margin-top: .3em; line-height: 1.5; opacity: .92; }
.opponent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.opp-card { font: inherit; color: inherit; text-align: center; background: var(--panel); border: 3px solid transparent; border-radius: var(--radius); padding: 10px; cursor: pointer; transition: transform .1s, border-color .1s; }
.opp-card:hover, .opp-card:focus-visible { transform: translateY(-3px) rotate(-1deg); border-color: var(--yellow); outline: 0; }
.opp-card canvas { width: 96px; height: 96px; border-radius: 50%; background: var(--clay); display: block; margin: 0 auto 6px; }
.opp-name { font-weight: 900; }
.opp-title { font-size: .75rem; opacity: .8; min-height: 2.2em; }
.opp-stars { color: var(--yellow); letter-spacing: .1em; }
.opp-bars { display: grid; gap: 2px; margin-top: 6px; }
.opp-bars i { display: block; height: 4px; border-radius: 2px; background: var(--red); }
.select-extra { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 18px; }

/* 対戦方法セクション */
.select-sec { margin: 14px 0; padding: 14px; background: var(--panel); border-radius: var(--radius); }
.select-sec-h { margin: 0 0 10px; font-size: 1.05rem; font-weight: 900; color: var(--yellow); }
.select-sec-h small { color: var(--ink); opacity: .7; font-weight: 700; }
.diff-row { display: flex; gap: 12px; flex-wrap: wrap; }
.diff-btn { flex: 1 1 140px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .8em 1em; }
.diff-stars { color: var(--yellow); letter-spacing: .12em; font-size: .9em; }

/* オンライン対戦パネル */
.net-panel { display: grid; gap: 10px; }
.net-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.net-input { font: inherit; font-size: 1.4rem; font-weight: 900; letter-spacing: .3em; text-align: center; width: 7.5em;
  padding: .35em .5em; color: var(--ink); background: #171224; border: 3px solid #4a3d66; border-radius: 12px; }
.net-input:focus { outline: 0; border-color: var(--yellow); }
.net-code-wrap { display: flex; align-items: baseline; gap: 8px; font-size: 1.1rem; }
.net-code-wrap strong { font-size: 2rem; letter-spacing: .25em; color: var(--yellow); }
.net-status { min-height: 1.2em; font-size: .9rem; opacity: .9; }

/* 顔ライブラリ */
.fp-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(10,6,18,.7); }
.fp-wrap { width: min(880px, 100%); max-height: min(85vh, 100%); overflow-y: auto; background: var(--panel); border-radius: 20px; padding: 16px 18px; box-shadow: 0 24px 70px rgba(0,0,0,.6); }
.fp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.fp-title { margin: 0; font-size: 1.25rem; font-weight: 900; }
.fp-title small { opacity: .6; font-weight: 700; }
.fp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.fp-card { position: relative; background: #171224; border: 3px solid transparent; border-radius: 14px; padding: 10px; text-align: center; }
.fp-card:hover, .fp-card:focus-visible { border-color: var(--yellow); outline: 0; }
.fp-thumb { width: 84px; height: 84px; border-radius: 50%; background: var(--clay); display: block; margin: 0 auto 6px; }
.fp-name { font-weight: 900; font-size: .85rem; min-height: 1.4em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-act { font: inherit; font-size: .72rem; font-weight: 900; color: #fff; background: var(--red); border: 0; border-radius: 999px; padding: .45em .8em; margin: 6px 2px 0; cursor: pointer; box-shadow: 0 3px 0 #a02a1b; }
.fp-act:active { transform: translateY(2px); box-shadow: 0 1px 0 #a02a1b; }
.fp-del { position: absolute; top: 6px; right: 6px; font: inherit; font-size: .7rem; font-weight: 900; color: #fff; background: #4a3d66; border: 0; border-radius: 999px; width: 26px; height: 26px; cursor: pointer; }
.fp-del.is-armed { width: auto; padding: 0 10px; background: var(--red); }
.fp-empty { opacity: .75; line-height: 1.6; }

/* リザルト */
.result-box { text-align: center; max-width: 560px; padding: 24px; background: rgba(36,28,51,.92); border-radius: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.result-verdict { font-size: clamp(2rem, 9vw, 3.6rem); font-weight: 900; font-style: italic; color: var(--yellow); text-shadow: 0 4px 0 #8a5d00; }
.result-method { opacity: .8; letter-spacing: .2em; margin-bottom: .6em; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 18px; }

.loading { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: var(--bg); font-weight: 900; font-size: 1.3rem; transition: opacity .4s; }
.loading.done { opacity: 0; pointer-events: none; }
.fatal { position: fixed; inset: 0; z-index: 101; padding: 24px; background: #200; color: #fcc; white-space: pre-wrap; overflow: auto; }
