:root {
  --paper: #fbf5e6; --paper2: #f3e9d2; --ink: #33241a; --ink2: #6b5646; --red: #e2553f; --green: #2f7a4f; --gold: #d9a330; --line: rgba(51, 36, 26, .18);
  --jp: "Zen Kaku Gothic New", system-ui, sans-serif; --en: "Bricolage Grotesque", "Zen Kaku Gothic New", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2d2018; color: var(--ink); font-family: var(--jp); user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hide { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
svg .thin { stroke-width: 1.6; }
.ic { width: 44px; height: 44px; border-radius: 12px; background: var(--paper); box-shadow: 0 3px 0 rgba(0,0,0,.25), 0 6px 14px rgba(0,0,0,.2); display: grid; place-items: center; }
.ic:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.25); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hl { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); display: flex; gap: 8px; align-items: stretch; pointer-events: none !important; }
.holeno { background: var(--ink); color: var(--paper); border-radius: 12px; min-width: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 8px; box-shadow: 0 4px 12px rgba(0,0,0,.25); }
.holeno b { font: 800 26px/1 var(--en); }
.holeno small { font: 800 9px/1 var(--en); letter-spacing: .15em; opacity: .7; margin-top: 2px; }
.hname { background: var(--paper); border-radius: 12px; padding: 6px 12px; display: flex; flex-direction: column; justify-content: center; box-shadow: 0 4px 12px rgba(0,0,0,.25); }
.hname b { font-weight: 900; font-size: 15px; white-space: nowrap; }
.hname span { font: 800 11px var(--en); letter-spacing: .1em; color: var(--ink2); }
.hname i { font-style: normal; color: var(--red); font-size: 13px; }
.hr { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); display: flex; gap: 8px; }
.strokes { background: var(--paper); border-radius: 12px; padding: 4px 12px; display: flex; align-items: baseline; gap: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.25); pointer-events: none; }
.strokes small { font-size: 11px; font-weight: 700; color: var(--ink2); }
.strokes b { font: 800 30px/1.2 var(--en); }
#players { position: absolute; left: 50%; top: max(10px, env(safe-area-inset-top)); transform: translateX(-50%); display: flex; gap: 6px; pointer-events: none !important; }
.pc { background: rgba(251,245,230,.82); border-radius: 10px; padding: 4px 9px 4px 6px; display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; box-shadow: 0 3px 8px rgba(0,0,0,.2); transition: transform .2s, background .2s; opacity: .75; }
.pc.on { background: var(--paper); transform: translateY(3px) scale(1.06); opacity: 1; box-shadow: 0 0 0 2.5px var(--ink), 0 6px 14px rgba(0,0,0,.3); }
.pc .dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset -2px -2px 3px rgba(0,0,0,.25), 0 0 0 1.5px rgba(0,0,0,.25); }
.pc .s { font: 800 15px var(--en); margin-left: 2px; }
.pc.done { opacity: .5; }
#turnTag { position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 8px 18px; border-radius: 99px; font-weight: 900; font-size: 15px; box-shadow: 0 6px 16px rgba(0,0,0,.35); pointer-events: none !important; display: flex; align-items: center; gap: 8px; animation: pop .35s cubic-bezier(.3,1.6,.5,1); }
#turnTag i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
#hint { position: absolute; left: 50%; bottom: max(70px, calc(env(safe-area-inset-bottom) + 60px)); transform: translateX(-50%); background: rgba(251,245,230,.94); padding: 9px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; box-shadow: 0 6px 16px rgba(0,0,0,.3); pointer-events: none !important; white-space: nowrap; }
@media (max-width: 560px) { .hname b { font-size: 13px; } .hname { padding: 5px 9px; } #players { top: auto; bottom: max(64px, calc(env(safe-area-inset-bottom) + 56px)); } .pc { font-size: 11px; } #hint { font-size: 12.5px; white-space: normal; width: 86vw; text-align: center; } }

/* ---------- ホール紹介 ---------- */
#intro { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(20,12,6,.25); }
#intro .card { background: var(--paper); border-radius: 6px; padding: 22px 34px 18px; text-align: center; min-width: 280px; max-width: 88vw; box-shadow: 0 18px 40px rgba(0,0,0,.4); transform: rotate(-1.5deg); position: relative; animation: drop .5s cubic-bezier(.2,1.4,.4,1); background-image: repeating-linear-gradient(transparent 0 27px, rgba(80,120,180,.12) 27px 28px); }
#intro .card::before { content: ''; position: absolute; left: 50%; top: -12px; width: 110px; height: 26px; transform: translateX(-50%) rotate(2deg); background: rgba(226,200,140,.75); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
#intro .no { font: 800 14px var(--en); letter-spacing: .3em; color: var(--ink2); }
#intro .no b { font-size: 28px; color: var(--red); letter-spacing: 0; margin-left: 4px; }
#intro h2 { margin: 4px 0 6px; font-weight: 900; font-size: 30px; }
#intro .par { font: 800 15px var(--en); letter-spacing: .2em; display: inline-block; border: 2px solid var(--ink); padding: 2px 12px; border-radius: 99px; }
#intro .tip { margin: 12px 0 4px; font-weight: 700; font-size: 14px; color: var(--ink2); }
#intro .tap { font-size: 11px; color: var(--ink2); opacity: .7; margin-top: 6px; animation: blink 1.4s infinite; }
@keyframes drop { from { transform: translateY(-40px) rotate(-6deg); opacity: 0; } }
@keyframes blink { 50% { opacity: .2; } }
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } }

/* ---------- 決まったときの大きい字 ---------- */
#banner { position: fixed; left: 0; right: 0; top: 38%; transform: translateY(-50%); text-align: center; pointer-events: none; }
#banner b { display: inline-block; font-weight: 900; font-size: clamp(40px, 9vw, 92px); color: #fff; letter-spacing: .02em; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink), 0 14px 26px rgba(0,0,0,.45); animation: slam .6s cubic-bezier(.2,1.6,.4,1); }
#banner small { display: block; margin-top: 10px; font: 800 18px var(--en); color: var(--paper); letter-spacing: .25em; text-shadow: 0 2px 6px rgba(0,0,0,.6); animation: up .5s .2s both; }
#banner.ace b { color: #ffd23f; font-size: clamp(46px, 11vw, 120px); }
#banner.good b { color: #8ee6a2; }
#banner.bad b { color: #ffd5c8; font-size: clamp(34px, 7vw, 70px); }
@keyframes slam { from { transform: scale(2.4) rotate(-8deg); opacity: 0; } 60% { transform: scale(.94); } }
@keyframes up { from { transform: translateY(14px); opacity: 0; } }
#pops { position: fixed; inset: 0; pointer-events: none; }
.pop { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 18px; color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; animation: popf 1.3s ease-out forwards; white-space: nowrap; }
.pop.red { color: #ffb4a6; }
@keyframes popf { 0% { transform: translate(-50%, -30%) scale(.5); opacity: 0; } 15% { transform: translate(-50%, -60%) scale(1.15); opacity: 1; } 100% { transform: translate(-50%, -180%) scale(1); opacity: 0; } }

/* ---------- 画面（タイトル・選択） ---------- */
.scr { position: fixed; inset: 0; overflow-y: auto; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
#title { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; background: radial-gradient(ellipse at center, rgba(20,12,6,0) 30%, rgba(20,12,6,.55)); }
.logo { position: relative; background: var(--paper); padding: 18px 40px 16px; border-radius: 4px; transform: rotate(-2deg); box-shadow: 0 20px 50px rgba(0,0,0,.45); text-align: center; animation: drop .7s cubic-bezier(.2,1.4,.4,1); }
.logo .tape { position: absolute; width: 90px; height: 26px; background: rgba(226,200,140,.78); box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.logo .t1 { left: -22px; top: 6px; transform: rotate(-38deg); } .logo .t2 { right: -22px; bottom: 8px; transform: rotate(-38deg); }
.lg1, .lg2 { font: 800 clamp(48px, 11vw, 104px)/.88 var(--en); letter-spacing: -.02em; }
.lg1 { color: var(--green); } .lg2 { color: var(--red); }
.flagI { position: relative; display: inline-block; width: .3em; height: .7em; vertical-align: baseline; margin: 0 .02em; }
.flagI::before { content: ''; position: absolute; left: 50%; bottom: 0; width: .07em; height: .78em; background: var(--ink); transform: translateX(-50%); border-radius: 2px; }
.flagI i { position: absolute; left: 50%; top: -.08em; width: .42em; height: .26em; background: var(--red); clip-path: polygon(0 0, 100% 50%, 0 100%); animation: wave 1.6s ease-in-out infinite; transform-origin: left; }
.flagI::after { content: ''; position: absolute; left: 50%; bottom: -.06em; width: .26em; height: .1em; border-radius: 50%; background: var(--ink); transform: translateX(-50%); opacity: .8; }
@keyframes wave { 50% { transform: scaleX(.82) skewY(4deg); } }
.lgj { margin-top: 10px; font-weight: 900; font-size: clamp(14px, 3vw, 20px); letter-spacing: .3em; color: var(--ink2); }
.menu { display: flex; flex-direction: column; gap: 12px; width: min(360px, 90vw); }
.big { background: var(--paper); border-radius: 14px; padding: 14px 18px; text-align: left; box-shadow: 0 5px 0 #c9b893, 0 12px 26px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 3px; transition: transform .1s; position: relative; overflow: hidden; }
.big::after { content: '›'; position: absolute; right: 18px; top: 50%; transform: translateY(-52%); font: 800 34px var(--en); color: var(--red); }
.big span { font-weight: 900; font-size: 21px; }
.big small { font-size: 12px; font-weight: 700; color: var(--ink2); }
.big.alt { background: #e9f3e6; box-shadow: 0 5px 0 #a9c4a2, 0 12px 26px rgba(0,0,0,.35); }
.big.alt::after { color: var(--green); }
.big:active { transform: translateY(4px); box-shadow: 0 1px 0 #c9b893, 0 6px 14px rgba(0,0,0,.3); }
.foot { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px; }
.foot .ver { font: 600 11px var(--en); color: rgba(251,245,230,.5); }
.ic.off { opacity: .5; }

.scr header { display: flex; align-items: center; gap: 12px; max-width: 1000px; margin: 0 auto 14px; }
.scr header h3 { margin: 0; font-weight: 900; font-size: 22px; color: var(--paper); text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.scr header .total { margin-left: auto; color: var(--paper); font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 4px; }
.back { background: var(--paper); border-radius: 99px; padding: 7px 14px 7px 10px; font-weight: 900; box-shadow: 0 3px 0 rgba(0,0,0,.3); }
#worlds, #party { background: rgba(20,12,6,.62); }
.wlist { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; max-width: 1000px; margin: 0 auto; }
.wc { background: var(--paper); border-radius: 14px; overflow: hidden; box-shadow: 0 6px 0 rgba(0,0,0,.25), 0 14px 30px rgba(0,0,0,.35); text-align: left; transition: transform .12s; position: relative; }
.wc:active { transform: translateY(3px); }
.wc canvas { display: block; width: 100%; aspect-ratio: 16/10; background: #222; }
.wc .wi { padding: 10px 14px 12px; display: flex; align-items: center; gap: 10px; }
.wc .wn { display: flex; flex-direction: column; }
.wc .wn b { font-weight: 900; font-size: 19px; }
.wc .wn small { font: 800 11px var(--en); letter-spacing: .2em; color: var(--ink2); }
.wc .ws { margin-left: auto; text-align: right; font-weight: 700; font-size: 13px; color: var(--ink2); }
.wc .ws b { font: 800 18px var(--en); color: var(--ink); }
.wc.lock canvas { filter: grayscale(1) brightness(.45) blur(1px); }
.wc .lk { position: absolute; left: 0; right: 0; top: 0; aspect-ratio: 16/10; display: grid; place-items: center; color: var(--paper); font-weight: 900; font-size: 15px; text-align: center; text-shadow: 0 2px 6px #000; }
.wc .lk svg { width: 40px; height: 40px; display: block; margin: 0 auto 6px; }
.star { color: var(--gold); }
.holes { max-width: 1000px; margin: 16px auto 0; background: var(--paper); border-radius: 14px; padding: 14px; box-shadow: 0 14px 30px rgba(0,0,0,.35); animation: up .3s; }
.holes .hh { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.holes .hh b { font-weight: 900; font-size: 18px; }
.holes .hh .round { margin-left: auto; background: var(--red); color: #fff; font-weight: 900; padding: 10px 18px; border-radius: 12px; box-shadow: 0 4px 0 #a83a28; }
.holes .hh .round:active { transform: translateY(3px); box-shadow: 0 1px 0 #a83a28; }
.hg { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.hc { background: var(--paper2); border-radius: 10px; padding: 8px 10px; text-align: left; display: grid; grid-template-columns: auto 1fr; gap: 0 8px; align-items: center; border: 2px solid transparent; }
.hc:hover { border-color: var(--ink2); }
.hc .n { grid-row: span 2; font: 800 26px var(--en); color: var(--red); min-width: 30px; text-align: center; }
.hc .t { font-weight: 900; font-size: 13px; line-height: 1.25; }
.hc .m { font-size: 11px; font-weight: 700; color: var(--ink2); display: flex; gap: 6px; align-items: center; }
.hc .m .star { letter-spacing: -1px; font-size: 12px; }

.pbox { max-width: 560px; margin: 0 auto; background: var(--paper); border-radius: 14px; padding: 16px; box-shadow: 0 14px 30px rgba(0,0,0,.35); }
.plist { display: flex; flex-direction: column; gap: 8px; }
.pr { display: flex; align-items: center; gap: 8px; background: var(--paper2); border-radius: 10px; padding: 8px; }
.pr .col { width: 34px; height: 34px; border-radius: 50%; flex: none; box-shadow: inset -3px -3px 5px rgba(0,0,0,.25), 0 0 0 2px rgba(0,0,0,.2); }
.pr input { flex: 1; min-width: 0; font: 900 16px var(--jp); color: var(--ink); background: #fff; border: 2px solid var(--line); border-radius: 8px; padding: 7px 10px; user-select: text; -webkit-user-select: text; }
.pr .kind { font-weight: 900; font-size: 13px; padding: 8px 10px; border-radius: 8px; background: #fff; border: 2px solid var(--line); white-space: nowrap; min-width: 92px; }
.pr .kind.cpu { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pr .rm { font: 800 20px var(--en); width: 32px; height: 32px; border-radius: 8px; color: var(--ink2); }
.add { width: 100%; margin-top: 8px; padding: 10px; border-radius: 10px; border: 2px dashed var(--ink2); font-weight: 900; color: var(--ink2); }
.lbl { margin: 16px 0 6px; font-weight: 900; font-size: 13px; color: var(--ink2); }
.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.seg button { padding: 10px; border-radius: 10px; background: var(--paper2); font-weight: 900; border: 2px solid transparent; }
.seg button small { display: block; font-weight: 700; font-size: 11px; color: var(--ink2); }
.seg button.on { border-color: var(--ink); background: #fff; }
.go { width: 100%; margin-top: 16px; padding: 14px; border-radius: 12px; background: var(--green); color: #fff; font-weight: 900; font-size: 19px; box-shadow: 0 5px 0 #1d5536; }
.go:active { transform: translateY(4px); box-shadow: 0 1px 0 #1d5536; }

/* ---------- モーダル ---------- */
.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(20,12,6,.55); padding: 16px; z-index: 5; animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } }
.sheet { background: var(--paper); border-radius: 14px; padding: 18px; width: min(340px, 92vw); box-shadow: 0 20px 50px rgba(0,0,0,.45); display: flex; flex-direction: column; gap: 8px; animation: drop .35s cubic-bezier(.2,1.3,.4,1); max-height: 92vh; overflow: auto; }
.sheet h3 { margin: 0 0 4px; font-weight: 900; text-align: center; }
.mb { padding: 12px; border-radius: 10px; background: var(--paper2); font-weight: 900; font-size: 16px; }
.mb:active { transform: translateY(2px); }
.mb.warn { color: var(--red); }
.sl { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 13px; margin-top: 4px; }
.sl input { flex: 1; accent-color: var(--red); }
.sheet.wide { width: min(760px, 96vw); }
.ctitle { display: flex; align-items: baseline; gap: 10px; border-bottom: 3px double var(--ink); padding-bottom: 6px; }
.ctitle b { font: 800 22px var(--en); letter-spacing: .08em; }
.ctitle span { font-weight: 700; color: var(--ink2); font-size: 13px; }
.tblw { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font: 800 15px var(--en); }
th, td { border: 1px solid var(--line); text-align: center; padding: 5px 3px; min-width: 30px; height: 34px; }
th { font-size: 11px; color: var(--ink2); background: var(--paper2); }
td.nm { text-align: left; padding: 4px 8px; font: 900 13px var(--jp); white-space: nowrap; min-width: 80px; }
td.nm i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; box-shadow: inset -1px -1px 2px rgba(0,0,0,.3); }
td.tot { background: var(--paper2); font-size: 17px; }
tr.par td { color: var(--ink2); font-size: 13px; }
td .sc { display: inline-grid; place-items: center; width: 26px; height: 26px; }
td .sc.b { border: 2px solid var(--red); border-radius: 50%; color: var(--red); }
td .sc.e { border: 2px solid var(--red); border-radius: 50%; box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--red); color: var(--red); }
td .sc.a { background: var(--gold); color: #fff; border-radius: 50%; }
td .sc.bo { border: 2px solid var(--ink2); }
td .sc.db { border: 2px solid var(--ink2); box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink2); }
td.cur { background: rgba(226,85,63,.1); }
.cfoot { font-weight: 700; font-size: 14px; color: var(--ink2); text-align: center; min-height: 4px; }
.cfoot .bigt { font: 800 40px var(--en); color: var(--ink); display: block; }
.cfoot .stars { font-size: 26px; letter-spacing: 2px; }
.cfoot .new { display: inline-block; background: var(--red); color: #fff; font-weight: 900; padding: 2px 10px; border-radius: 99px; font-size: 12px; margin-left: 6px; transform: rotate(-4deg); }
.cbtns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.cbtns button { flex: 1; min-width: 130px; padding: 12px; border-radius: 10px; font-weight: 900; font-size: 16px; background: var(--paper2); }
.cbtns button.pri { background: var(--red); color: #fff; box-shadow: 0 4px 0 #a83a28; }
.rank { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.rk { display: flex; align-items: center; gap: 10px; background: var(--paper2); border-radius: 10px; padding: 8px 12px; animation: up .4s both; }
.rk .pl { font: 800 24px var(--en); width: 34px; text-align: center; }
.rk.r1 { background: #fff3cf; box-shadow: 0 0 0 2px var(--gold); }
.rk.r1 .pl { color: var(--gold); }
.rk .nm { font-weight: 900; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.rk .nm i { width: 16px; height: 16px; border-radius: 50%; display: inline-block; box-shadow: inset -2px -2px 3px rgba(0,0,0,.3); }
.rk .tt { margin-left: auto; font: 800 22px var(--en); }
.rk .tt small { font-size: 13px; color: var(--ink2); margin-left: 6px; }

#fade { position: fixed; inset: 0; background: #1b120b; pointer-events: none; opacity: 0; transition: opacity .35s; z-index: 9; }
#fade.on { opacity: 1; }
