* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; touch-action: none; background: #9cc3d8; font-family: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Meiryo", system-ui, sans-serif; color: #2b2118; user-select: none; -webkit-user-select: none; }
#app, #app canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
kbd { display: inline-block; font: 600 10px/1 system-ui, sans-serif; padding: 2px 4px; border-radius: 4px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35); margin: 0 1px; }

/* pin number labels */
#labels { position: fixed; inset: 0; pointer-events: none; }
.pinLabel { position: absolute; transform: translate(-50%, -100%); min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: rgba(255, 250, 238, .92); color: #2b2118; font: 800 11px/18px "Arial Rounded MT Bold", "Segoe UI", sans-serif; text-align: center; box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: background .2s, color .2s, transform .2s; }
.pinLabel.down { background: #e8473b; color: #fff; transform: translate(-50%, -100%) scale(1.25); }
.pinLabel.dim { opacity: .45; }
body.nolabels .pinLabel { display: none; }

/* HUD — designed for a portrait phone, also works on desktop */
:root { --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px); }
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent; }
.glass { background: rgba(30, 24, 18, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

#scoreboard { position: absolute; left: 8px; right: 8px; top: calc(8px + var(--st)); display: flex; gap: 6px; max-width: 560px; margin: 0 auto; }
.ps { flex: 1; min-width: 0; background: rgba(30, 24, 18, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); color: #fff; border-radius: 12px; padding: 6px 9px 7px; border: 2px solid transparent; transition: transform .25s, border-color .25s; }
.ps.active { border-color: var(--c); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 55%, transparent); transform: translateY(2px); }
.ps.out { opacity: .45; filter: grayscale(1); }
.ps .top { display: flex; align-items: center; gap: 6px; }
.ps .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.ps .name { flex: 1; min-width: 0; font-weight: 700; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps .name small { display: none; }
.ps .score { font: 900 22px/1 "Arial Black", sans-serif; }
.ps .bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,.18); margin-top: 5px; overflow: hidden; }
.ps .bar i { display: block; height: 100%; background: var(--c); transition: width .5s; }
.ps .misses { display: flex; gap: 3px; margin-top: 5px; font-size: 10px; align-items: center; opacity: .9; }
.ps .misses b { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.6); }
.ps .misses b.x { background: #e8473b; border-color: #e8473b; }
.ps .need { margin-left: auto; font-size: 10px; opacity: .8; white-space: nowrap; }

#turnBanner { position: absolute; top: calc(78px + var(--st)); left: 8px; max-width: calc(100% - 230px); overflow: hidden; text-overflow: ellipsis; padding: 6px 14px; border-radius: 999px; background: rgba(30,24,18,.6); color: #fff; font-weight: 800; font-size: 14px; border-bottom: 3px solid var(--c, #fff); white-space: nowrap; }
#sideBtns { position: absolute; right: 8px; top: calc(76px + var(--st)); display: flex; gap: 5px; }
#sideBtns button { width: 38px; height: 38px; border: 0; border-radius: 12px; background: rgba(30,24,18,.6); color: #fff; font-size: 16px; }
#sideBtns button.on { background: #f2b134; }
#help { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--sb)); width: calc(100% - 236px); text-align: center; color: #fff; font-size: 11px; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.7); opacity: .85; }
body.cpuTurn #help, body.cpuTurn #throwBtn { opacity: .35; }

#toast { position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%) scale(.8); opacity: 0; width: 92vw; text-align: center; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.35), 0 0 24px rgba(0,0,0,.35); transition: opacity .25s, transform .35s cubic-bezier(.2,1.6,.4,1); pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#toast .big { font: 900 52px/1.05 "Arial Black", "Hiragino Maru Gothic ProN", sans-serif; }
#toast .sub { font-weight: 800; font-size: 17px; margin-top: 6px; }
#toast.good .big { color: #ffe066; }
#toast.bad .big { color: #ff8a7a; }
#toast.win .big { color: #ffd23f; font-size: 64px; }

/* side columns: left = how to throw, right = power + throw (the middle stays clear for the lane) */
#leftCol, #rightCol { position: absolute; bottom: calc(10px + var(--sb)); display: flex; flex-direction: column; gap: 6px; color: #fff; }
#leftCol { left: 8px; width: 104px; }
#rightCol { right: 8px; width: 96px; align-items: center; }
.box { background: rgba(30,24,18,.6); border-radius: 14px; padding: 6px 6px 7px; text-align: center; }
.cap { font-size: 10px; opacity: .8; margin-bottom: 3px; white-space: nowrap; }
.seg { display: flex; gap: 4px; background: rgba(30,24,18,.6); border-radius: 14px; padding: 4px; }
.seg.vert { flex-direction: column; }
.seg button { flex: 1; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 10px; padding: 7px 4px; font-weight: 800; font-size: 15px; line-height: 1.1; }
.seg button small { display: block; font-size: 10px; font-weight: 400; opacity: .8; }
.seg button.on { background: #f2b134; color: #2b2118; }
#yawVal, #loftVal { font: 900 19px/1.1 "Arial Black", "Hiragino Maru Gothic ProN", sans-serif; white-space: nowrap; }
#loftBox { display: flex; flex-direction: column; align-items: center; gap: 3px; }
#loftSvg { width: 84px; height: 40px; }
button.round { width: 40px; height: 30px; border-radius: 10px; border: 0; background: rgba(255,255,255,.16); color: #fff; font-size: 13px; }
button.round:active { background: rgba(255,255,255,.32); }
#guideBtn { background: rgba(30,24,18,.6); color: #fff; border: 0; border-radius: 10px; padding: 6px 4px; font-size: 11px; font-weight: 700; }

#gaugeWrap { display: flex; flex-direction: column; align-items: center; gap: 4px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
#gaugeLabel { font-weight: 800; font-size: 12px; }
#gauge { position: relative; width: 30px; height: min(32vh, 240px); border-radius: 16px; background: rgba(30,24,18,.55); border: 2px solid rgba(255,255,255,.8); overflow: hidden; }
#gaugeFill { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; background: linear-gradient(to top, #4fc25a, #f2d33b 55%, #ef5a3c); }
#gaugeMark { position: absolute; left: 0; right: 0; height: 3px; background: #fff; bottom: 0; opacity: 0; }
#gaugePct { font: 900 16px/1 "Arial Black", sans-serif; }
#throwBtn { width: 92px; height: 92px; border-radius: 50%; border: 3px solid rgba(255,255,255,.9); background: radial-gradient(circle at 35% 30%, #f59a5c, #e0602c); box-shadow: 0 5px 0 #a8431b, 0 8px 18px rgba(0,0,0,.35); color: #fff; padding: 0; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#throwBtn:active { transform: translateY(3px); box-shadow: 0 2px 0 #a8431b, 0 4px 10px rgba(0,0,0,.35); }
#throwBtn .lbl { display: block; font-size: 11px; line-height: 1.2; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
#throwBtn .lbl b { font-size: 20px; }

/* short phones: tighten the left column */
@media (max-height: 700px) {
  .seg button small { display: none; }
  #loftSvg { height: 28px; }
  #gauge { height: min(26vh, 200px); }
}

/* overlays */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(20,30,20,.15), rgba(20,25,20,.55)); }
.panel { background: rgba(255, 250, 240, .96); border-radius: 22px; padding: 26px 30px; width: min(520px, 92vw); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
h1 { margin: 0 0 6px; font: 900 56px/1 "Arial Black", sans-serif; letter-spacing: 2px; color: #2b2118; text-align: center; }
h1 span { display: block; font: 800 18px/1.6 "Hiragino Maru Gothic ProN", "Meiryo", sans-serif; letter-spacing: 6px; color: #a2733f; }
h2 { margin: 0 0 12px; text-align: center; font-size: 30px; }
.lead { text-align: center; margin: 4px 0 18px; font-size: 14px; }
.prow { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.prow .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.prow input { flex: 1; min-width: 0; font: inherit; padding: 8px 10px; border-radius: 10px; border: 1.5px solid #d8cbb5; background: #fff; }
.prow select { font: inherit; font-size: 14px; max-width: 46%; padding: 8px 4px; border-radius: 10px; border: 1.5px solid #d8cbb5; background: #fff; }
.prow .rm { border: 0; background: #eee3d0; border-radius: 10px; width: 36px; height: 36px; font-weight: 900; }
.row-btns { display: flex; gap: 10px; justify-content: center; margin: 10px 0; }
.row-btns button, #startBtn { border: 0; border-radius: 12px; padding: 10px 18px; background: #eee3d0; font-weight: 800; }
button.big { display: block; width: 100%; padding: 14px; font-size: 20px; background: #e8743b !important; color: #fff; box-shadow: 0 4px 0 #b4532a; margin-top: 6px; }
.row-btns button.big { width: auto; flex: 1; }
button.big:active { transform: translateY(2px); box-shadow: 0 2px 0 #b4532a; }
details { margin-top: 16px; font-size: 14px; background: #f3ead9; border-radius: 12px; padding: 10px 14px; }
summary { font-weight: 800; cursor: pointer; }
details li { margin: 4px 0; }
.tip { font-size: 12px; color: #6b5843; margin: 6px 0 0; }
#resultStats { font-size: 15px; }
#resultStats table { width: 100%; border-collapse: collapse; }
#resultStats td { padding: 6px 8px; border-bottom: 1px solid #eadfcb; }
#resultStats td.s { text-align: right; font: 900 20px "Arial Black", sans-serif; }

#loading { background: #9cc3d8; z-index: 10; }
.spinner { width: 48px; height: 48px; border-radius: 50%; border: 5px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.confetti { position: fixed; top: -20px; width: 10px; height: 16px; pointer-events: none; z-index: 5; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }


/* title sections / online lobby */
.panel section { background: #f6eedf; border-radius: 16px; padding: 12px 14px; margin: 10px 0; }
.panel h3 { margin: 0 0 8px; font-size: 16px; }
.panel h3 small { font-weight: 400; font-size: 12px; color: #7a6650; margin-left: 4px; }
button.big.blue { background: #2f86d6 !important; box-shadow: 0 4px 0 #1d5e9c; }
button.big.blue:active { box-shadow: 0 2px 0 #1d5e9c; }
.prow.join { margin-top: 10px; }
.prow.join input { text-transform: uppercase; letter-spacing: 3px; font-weight: 800; }
.prow.join button { border: 0; border-radius: 10px; padding: 8px 16px; background: #2b2118; color: #fff; font-weight: 800; }
.invite-hint { display: none; margin: 0 0 8px; font-size: 13px; font-weight: 700; color: #b4532a; }
#onlineBox.invited { outline: 3px solid #e8743b; }
#onlineBox.invited .invite-hint { display: block; }
.stageRow { display: flex; align-items: center; gap: 8px; margin: 8px 0 2px; font-weight: 800; font-size: 14px; }
.stageRow select { flex: 1; min-width: 0; font: inherit; font-weight: 400; font-size: 14px; padding: 8px 6px; border-radius: 10px; border: 1.5px solid #d8cbb5; background: #fff; }
.code { font: 900 30px "Arial Black", sans-serif; letter-spacing: 4px; color: #b4532a; }
.share { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0 12px; }
.share button, .share a { display: block; text-align: center; border: 0; border-radius: 10px; padding: 10px 6px; font-weight: 800; font-size: 14px; text-decoration: none; color: #2b2118; background: #eee3d0; }
.share a#lbX { background: #111; color: #fff; }
.share a#lbLine { background: #06c755; color: #fff; }
#lbSeats { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 10px; }
.lbSeat { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 12px; background: #fff; border: 1.5px solid #e6dac4; }
.lbSeat .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.lbSeat b { flex: none; }
.lbSeat small { font-size: 11px; background: #f3ead9; border-radius: 6px; padding: 2px 6px; }
.lbSeat .rm { margin-left: auto; border: 0; background: #eee3d0; border-radius: 8px; width: 30px; height: 30px; font-weight: 900; }
.lbSeat.empty { color: #a8977f; border-style: dashed; background: transparent; }
.lbSeat.off { opacity: .55; }
#lbHostBox select { font: inherit; padding: 8px; border-radius: 10px; border: 1.5px solid #d8cbb5; background: #fff; }
#netBadge { position: absolute; left: 50%; top: calc(120px + var(--st)); transform: translateX(-50%); background: #b4532a; color: #fff; font-weight: 800; font-size: 13px; padding: 6px 14px; border-radius: 999px; }
#stageBadge { position: absolute; left: 8px; top: calc(118px + var(--st)); font-size: 12px; font-weight: 800; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
button:disabled { opacity: .55; cursor: default; }
.panel { touch-action: pan-y; overscroll-behavior: contain; }
