/* ローポリ・サッカー UI — eFootball風（濃紺 × シアン × 斜めスキュー） */
:root {
  --bg: #080e1c; --panel: rgba(10, 17, 34, .9); --panel2: rgba(22, 34, 62, .9);
  --line: rgba(255, 255, 255, .14); --ink: #f2f6ff; --muted: #93a2c4;
  --acc: #27e0ff; --acc2: #0a8fff; --gold: #ffe14a; --red: #ff5a4a; --green: #3fe08a;
  --font: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, "Segoe UI", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { 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; touch-action: none; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
#gl, #hud { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#hud { pointer-events: none; z-index: 2; }

/* ---------- 読み込み ---------- */
#loading { position: fixed; inset: 0; z-index: 99; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); color: var(--muted); font-size: 14px; letter-spacing: .1em; }
#loading .spin { width: 42px; height: 42px; background: conic-gradient(from 0deg, var(--acc), transparent 70%); clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 試合HUD ---------- */
#hudbox { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
#score { position: absolute; left: calc(14px + var(--safe-l)); top: calc(12px + var(--safe-t)); }
#score .sc { display: flex; align-items: center; gap: 8px; padding: 6px 16px 6px 12px; background: linear-gradient(90deg, rgba(8, 14, 30, .92), rgba(16, 28, 56, .88)); border-left: 4px solid var(--acc); transform: skewX(-12deg); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
#score .sc > * { transform: skewX(12deg); }
#score .chip { width: 12px; height: 22px; border-radius: 2px; border: 1px solid rgba(255, 255, 255, .5); display: inline-block; }
#score b { font-size: 15px; letter-spacing: .08em; }
#score em { font-style: normal; font-weight: 900; font-size: 24px; min-width: 20px; text-align: center; font-variant-numeric: tabular-nums; }
#score u { text-decoration: none; color: var(--muted); }
#score #clock { margin-left: 8px; padding-left: 12px; border-left: 1px solid var(--line); font-weight: 800; font-size: 17px; color: var(--acc); font-variant-numeric: tabular-nums; }
#score small { color: var(--muted); font-size: 12px; font-weight: 700; }

#ctlcard { position: absolute; left: calc(14px + var(--safe-l)); bottom: calc(46px + var(--safe-b)); display: flex; align-items: center; gap: 10px; }
#ctlcard:empty { display: none; }
#ctlcard em { font-style: normal; font-weight: 900; font-size: 26px; width: 46px; height: 46px; display: grid; place-items: center; background: linear-gradient(135deg, var(--gold), #ffb300); color: #151515; clip-path: polygon(14% 0, 100% 0, 86% 100%, 0 100%); }
#ctlcard b { display: block; font-size: 16px; text-shadow: 0 2px 6px #000; }
#ctlcard small { color: #cfd9f2; font-size: 12px; text-shadow: 0 1px 4px #000; }

#radar { position: absolute; right: calc(14px + var(--safe-r)); top: calc(12px + var(--safe-t)); width: 220px; height: 130px; border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
#hint { position: absolute; left: 50%; bottom: calc(10px + var(--safe-b)); transform: translateX(-50%); max-width: min(94vw, 980px); padding: 6px 16px; font-size: 12px; line-height: 1.4; text-align: center; color: #dfe8ff; background: rgba(6, 10, 22, .66); border-radius: 999px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#banner { position: absolute; left: 0; right: 0; top: 20%; display: grid; justify-items: center; pointer-events: none; }
.bn { display: grid; justify-items: center; gap: 4px; padding: 10px 56px 12px; min-width: 320px; background: linear-gradient(90deg, transparent, rgba(8, 14, 30, .9) 18%, rgba(8, 14, 30, .9) 82%, transparent); animation: bn-in .35s cubic-bezier(.2, .9, .3, 1.2) both; }
.bn strong { font-size: 30px; font-weight: 900; letter-spacing: .08em; font-style: italic; text-shadow: 0 3px 10px rgba(0, 0, 0, .5); }
.bn span { font-size: 15px; color: var(--acc); font-weight: 700; letter-spacing: .06em; }
.bn.vs strong { font-size: 24px; }
.bn.small { padding: 6px 40px 8px; min-width: 220px; }
.bn.small strong { font-size: 22px; }
.bn.foul strong { color: #ffb347; }
.bn.goal { padding: 18px 90px 20px; background: linear-gradient(90deg, transparent, rgba(255, 225, 74, .92) 12%, rgba(255, 150, 20, .94) 88%, transparent); animation: goal-in .55s cubic-bezier(.2, 1.2, .3, 1) both; }
.bn.goal strong { font-size: 64px; color: #101830; text-shadow: 0 2px 0 rgba(255, 255, 255, .5); letter-spacing: .1em; }
.bn.goal span { color: #1a2038; font-size: 18px; }
@keyframes bn-in { from { opacity: 0; transform: translateY(-14px) scaleY(.6); } to { opacity: 1; transform: none; } }
@keyframes goal-in { from { opacity: 0; transform: scale(2.2) skewX(-14deg); } to { opacity: 1; transform: scale(1) skewX(-8deg); } }

#toast { position: fixed; left: 50%; bottom: 64px; transform: translate(-50%, 20px); z-index: 60; padding: 8px 20px; background: rgba(10, 17, 34, .94); border: 1px solid var(--acc); border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 画面（メニュー等） ---------- */
#screen { position: fixed; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); touch-action: pan-y; }
#screen.on { display: flex; animation: fade .3s ease both; }
#screen.dim0 { background: linear-gradient(100deg, rgba(5, 9, 20, .93) 0%, rgba(5, 9, 20, .72) 38%, rgba(5, 9, 20, .08) 70%); justify-content: flex-start; padding-left: clamp(20px, 7vw, 110px); }
#screen.dim { background: rgba(4, 8, 18, .72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.title { display: flex; flex-direction: column; gap: 30px; align-items: flex-start; width: 100%; }
.logo small { display: block; letter-spacing: .5em; font-size: 12px; font-weight: 800; color: var(--acc); margin-bottom: 6px; }
.logo h1 { margin: 0; font-size: clamp(44px, 9vw, 92px); line-height: .98; font-weight: 900; font-style: italic; letter-spacing: .02em; text-shadow: 0 6px 0 rgba(10, 143, 255, .45), 0 12px 40px rgba(0, 0, 0, .6); }
.logo p { margin: 12px 0 0; font-size: 13px; letter-spacing: .38em; color: var(--muted); font-weight: 700; }
.title .foot { position: fixed; left: 0; right: 0; bottom: calc(14px + var(--safe-b)); text-align: center; font-size: 12px; color: #aebbd8; text-shadow: 0 1px 6px #000; }

.menu { display: flex; flex-direction: column; gap: 10px; min-width: 260px; }
.row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.btn { position: relative; padding: 13px 34px; border: 0; font-weight: 800; letter-spacing: .08em; font-size: 15px; background: rgba(24, 38, 70, .92); border-left: 4px solid rgba(255, 255, 255, .25); clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 100%, 0 100%); transition: .15s; text-align: left; }
.btn:hover, .btn:focus-visible { background: rgba(40, 62, 112, .96); border-left-color: var(--acc); transform: translateX(4px); outline: none; }
.btn.primary { background: linear-gradient(90deg, var(--acc2), var(--acc)); color: #04101f; border-left-color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: rgba(120, 30, 40, .92); border-left-color: var(--red); }
.row .btn { text-align: center; padding: 12px 26px; }

.panel { width: min(1000px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; padding: 22px 28px 26px; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--acc); box-shadow: 0 20px 60px rgba(0, 0, 0, .55); touch-action: pan-y; }
.panel:not(.wide) { width: min(660px, 100%); }
.panel h2 { margin: 0 0 14px; font-size: 22px; letter-spacing: .1em; font-style: italic; display: flex; gap: 14px; align-items: baseline; }
.panel h2 small { font-size: 14px; color: var(--gold); font-style: normal; letter-spacing: .05em; }
.panel h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: .18em; color: var(--acc); font-weight: 800; }
.panel h4 { margin: 12px 0 6px; font-size: 13px; color: #dbe5ff; }
.panel h4 small { color: var(--muted); font-weight: 500; }
.panel .menu { margin-top: 14px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.7; }

/* 操作説明 */
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; }
.help-grid section { padding: 12px 14px; background: var(--panel2); border-left: 3px solid var(--acc2); }
.help-grid p { margin: 6px 0; font-size: 13px; line-height: 1.8; color: #dbe4fa; }
kbd { display: inline-block; min-width: 24px; padding: 1px 7px; margin: 0 1px; text-align: center; font: 700 12px var(--font); color: #04101f; background: linear-gradient(#fff, #c9d6f2); border-radius: 5px; box-shadow: 0 2px 0 #6f7fa6; }

/* 試合設定 */
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.teams { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.team { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 9px 10px; text-align: left; background: var(--panel2); border: 1px solid transparent; border-left: 3px solid rgba(255, 255, 255, .18); transition: .15s; }
.team:hover { background: rgba(40, 62, 112, .9); }
.team.sel { border-color: var(--acc); border-left-color: var(--acc); background: linear-gradient(90deg, rgba(10, 143, 255, .35), rgba(22, 34, 62, .9)); }
.team .crest { grid-row: 1 / 3; }
.team b { font-size: 13px; }
.team span { font-size: 11px; color: var(--muted); }
.crest { display: inline-block; width: 30px; height: 34px; margin: 0 6px; vertical-align: middle; background: linear-gradient(135deg, var(--c1, #888) 0 50%, var(--c2, #444) 50% 100%); clip-path: polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .5)); }
.opts { display: grid; grid-template-columns: repeat(3, auto); gap: 18px; margin-top: 18px; justify-content: start; }
.seg { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.seg button { padding: 7px 16px; border: 0; font-size: 13px; font-weight: 700; background: var(--panel2); color: #c3cfee; border-bottom: 2px solid transparent; }
.seg button:hover { color: #fff; }
.seg button.sel { background: var(--acc2); color: #fff; border-bottom-color: var(--acc); }

/* スカッド */
.squad .sq-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; margin-bottom: 10px; }
.squad .sq-head h2 { margin: 0; }
.sq-body { display: grid; grid-template-columns: 1fr 290px; gap: 16px; }
.sq-pitch { position: relative; width: 100%; aspect-ratio: 105 / 68; min-height: 260px; background: repeating-linear-gradient(90deg, #2a7d3e 0 9.5%, #2f8a45 9.5% 19%); border: 2px solid rgba(255, 255, 255, .5); overflow: hidden; }
.sq-pitch .pl { position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, .55), rgba(255, 255, 255, .55)) 50% 0 / 2px 100% no-repeat,
    radial-gradient(circle at 50% 50%, transparent 0 13.4%, rgba(255, 255, 255, .55) 13.4% 14.4%, transparent 14.4%),
    linear-gradient(90deg, rgba(255, 255, 255, .5) 0 2px, transparent 2px) 15.7% 20% / 100% 60% no-repeat; }
.sq-pitch .pl::before, .sq-pitch .pl::after { content: ""; position: absolute; top: 20%; height: 60%; width: 15.7%; border: 2px solid rgba(255, 255, 255, .5); }
.sq-pitch .pl::before { left: 0; border-left: 0; }
.sq-pitch .pl::after { right: 0; border-right: 0; }
.slot { position: absolute; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 1px; width: 74px; padding: 2px 0; background: none; border: 2px solid transparent; border-radius: 8px; transition: .12s; }
.slot:hover { background: rgba(0, 0, 0, .25); }
.slot.sel { border-color: var(--gold); background: rgba(255, 225, 74, .22); }
.slot.warn span { color: #ff9a8f; }
.slot.warn { border-color: rgba(255, 90, 74, .75); }
.slot.warn.sel { border-color: var(--gold); }
.jersey { position: relative; width: 34px; height: 32px; display: grid; place-items: center; background: linear-gradient(90deg, var(--c1, #888) 0 100%); clip-path: polygon(22% 0, 38% 8%, 62% 8%, 78% 0, 100% 24%, 86% 40%, 80% 34%, 80% 100%, 20% 100%, 20% 34%, 14% 40%, 0 24%); }
.jersey::after { content: ""; position: absolute; left: 20%; right: 20%; bottom: 0; height: 28%; background: var(--c2, #333); opacity: .5; }
.jersey em { position: relative; z-index: 1; font-style: normal; font-weight: 900; font-size: 13px; color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.slot span { font-size: 10.5px; font-weight: 800; text-shadow: 0 1px 3px #000, 0 0 4px #000; max-width: 72px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot b { font-size: 11px; color: var(--gold); text-shadow: 0 1px 3px #000; }
.slot u { text-decoration: none; font-size: 9px; color: #d6e2ff; opacity: .9; }
.sq-body aside { display: flex; flex-direction: column; min-width: 0; }
.sq-body aside h3 { font-size: 15px; color: var(--ink); letter-spacing: .04em; }
.sq-body aside h3 small { color: var(--gold); margin-left: 6px; }
.sq-body aside h4 { margin-top: 2px; }
.bench { display: grid; gap: 4px; }
.bp { display: grid; grid-template-columns: 30px 1fr 34px 30px; gap: 6px; align-items: center; padding: 6px 8px; text-align: left; background: var(--panel2); border: 1px solid transparent; font-size: 12px; }
.bp:hover { background: rgba(40, 62, 112, .9); }
.bp.sel { border-color: var(--gold); background: rgba(255, 225, 74, .18); }
.bp em { font-style: normal; font-weight: 900; color: var(--acc); }
.bp span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp u { text-decoration: none; color: var(--muted); font-size: 11px; }
.bp b { color: var(--gold); text-align: right; }
.detail { margin-top: 10px; padding: 10px 12px; background: var(--panel2); border-left: 3px solid var(--acc); min-height: 150px; }
.bar { display: grid; grid-template-columns: 74px 1fr 28px; gap: 8px; align-items: center; margin: 4px 0; font-size: 12px; }
.bar span { color: var(--muted); }
.bar > div { height: 6px; background: rgba(255, 255, 255, .12); }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--acc2), var(--acc)); }
.bar b { text-align: right; }

/* スコア・統計 */
.big { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: center; margin: 4px 0 14px; padding: 12px 18px; background: var(--panel2); }
.big span { font-weight: 800; font-size: 14px; display: flex; align-items: center; white-space: nowrap; }
.big span:last-child { justify-content: flex-end; }
.big strong { font-size: 40px; font-weight: 900; font-style: italic; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.stats { display: grid; gap: 8px; }
.st { display: grid; grid-template-columns: 54px 1fr 54px; grid-template-areas: "a bar b" ". k ."; gap: 2px 10px; align-items: center; text-align: center; font-size: 14px; }
.st > b:nth-of-type(1) { grid-area: a; text-align: right; }
.st > b:nth-of-type(2) { grid-area: b; text-align: left; }
.st > span { grid-area: k; font-size: 11px; color: var(--muted); letter-spacing: .12em; }
.stbar { grid-area: bar; display: flex; gap: 3px; height: 8px; }
.stbar i { background: var(--acc); }
.stbar u { background: #ff7a59; }

/* ---------- オンスクリーン操作（タッチ/マウス） ---------- */
#touchRoot { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#touch { display: none; position: absolute; inset: 0; }
body.inmatch.touch-on #touch { display: block; }
#stickZone { position: absolute; left: calc(10px + var(--safe-l)); bottom: calc(10px + var(--safe-b)); width: 190px; height: 190px; pointer-events: auto; touch-action: none; display: grid; place-items: center; }
#stickBase { position: relative; width: 124px; height: 124px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .06), rgba(255, 255, 255, .16)); border: 2px solid rgba(255, 255, 255, .35); backdrop-filter: blur(2px); }
#stickKnob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #9fb4e6); box-shadow: 0 4px 10px rgba(0, 0, 0, .5); }
#btns { position: absolute; right: calc(8px + var(--safe-r)); bottom: calc(8px + var(--safe-b)); width: 250px; height: 230px; pointer-events: none; }
#btns .b { position: absolute; pointer-events: auto; touch-action: none; width: 66px; height: 66px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .55); background: rgba(14, 24, 48, .62); color: #fff; font-size: 12px; font-weight: 800; line-height: 1.1; display: grid; place-content: center; text-align: center; backdrop-filter: blur(3px); transition: transform .06s, background .06s; }
#btns .b small { display: none; font-size: 9px; opacity: .6; font-weight: 600; }
@media (hover: hover) and (pointer: fine) { #btns .b small { display: block; } }
#btns .b.on { transform: scale(.92); background: rgba(39, 224, 255, .55); }
#btns .tri { right: 92px; bottom: 120px; border-color: #3fe08a; }
#btns .sq { right: 160px; bottom: 62px; border-color: #ff7ac6; }
#btns .cir { right: 24px; bottom: 62px; border-color: #ff5a4a; }
#btns .crs { right: 92px; bottom: 4px; border-color: #6ab7ff; width: 74px; height: 74px; font-size: 13px; }
#btns .sm { width: 56px; height: 50px; font-size: 10.5px; border-radius: 14px; white-space: nowrap; }
#btns .s1 { right: 2px; bottom: 148px; }
#btns .s2 { right: 190px; bottom: 148px; }
#btns .s3 { right: 62px; bottom: 182px; width: 46px; height: 40px; }
#btns .s4 { right: 4px; bottom: 4px; }
body.touch-on #hint { display: none; }
body.touch-on #ctlcard { bottom: auto; top: calc(62px + var(--safe-t)); }

/* ---------- レスポンシブ ---------- */
@media (max-width: 860px) {
  .two { grid-template-columns: 1fr; }
  .sq-body { grid-template-columns: 1fr; }
  .opts { grid-template-columns: 1fr; gap: 12px; }
  .panel { padding: 16px 16px 20px; }
  #radar { width: 150px; height: 88px; }
  .bn.goal strong { font-size: 44px; }
  .bn.goal { padding: 14px 40px 16px; }
}
@media (max-height: 520px) {
  #score .sc { padding: 3px 12px 3px 8px; }
  #score em { font-size: 19px; }
  #btns { transform: scale(.8); transform-origin: right bottom; }
  #stickZone { transform: scale(.85); transform-origin: left bottom; }
  #radar { width: 130px; height: 76px; }
  .logo h1 { font-size: 44px; }
  .title { gap: 16px; }
  .bn { padding: 6px 40px 8px; }
  .bn strong { font-size: 22px; }
  .bn.goal strong { font-size: 38px; }
  .panel h2 { font-size: 18px; margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
