#onlineOverlay { position: fixed; inset: 0; z-index: 200000; overflow: auto; padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); display: grid; place-items: center; background: rgba(38, 28, 25, .72); backdrop-filter: blur(12px); font-family: ui-rounded, "PingFang SC", system-ui, sans-serif; }
#onlineOverlay * { box-sizing: border-box; }
.online-card { width: min(880px, 100%); display: grid; grid-template-columns: .85fr 1.15fr; overflow: hidden; border-radius: 30px; background: #fff3d8; border: 3px solid #fff; box-shadow: 0 17px 0 #b87947, 0 30px 75px #24150e99; }
.online-art { min-height: 450px; background: url('/assets/c200c7f36eb37dd5.webp') center / cover no-repeat, linear-gradient(#fff0bd,#ffcf92); }
.online-main { padding: 27px; min-width: 0; }
.online-kicker { color: #aa6730; background: #ffe0a4; border-radius: 99px; padding: 6px 11px; display: inline-block; font-weight: 900; font-size: 12px; }
.online-main h2 { margin: 12px 0 9px; color: #683a23; font-size: clamp(28px, 4vw, 44px); line-height: 1.1; }
.online-main p { color: #896648; line-height: 1.5; font-weight: 750; font-size: 14px; }
.online-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 5px; }
.online-btn { min-height: 46px; min-width: 125px; padding: 10px 16px; border: 2px solid #fff7dc; border-radius: 15px; background: linear-gradient(#ffd36e,#fb9a45); color: #633713; box-shadow: 0 5px 0 #c37d39; font-weight: 950; font-size: 16px; }
.online-btn:disabled { opacity: .45; cursor: not-allowed; }
.online-btn.secondary { background: linear-gradient(#fff,#ffeed1); box-shadow: 0 5px 0 #dbc392; }
.online-btn.green { background: linear-gradient(#a6ed9b,#5bcc70); box-shadow: 0 5px 0 #479759; }
.online-input { min-height: 48px; width: min(100%, 260px); border: 2px solid #e1ad70; border-radius: 15px; padding: 9px 13px; text-align: center; letter-spacing: 4px; font-weight: 900; font-size: 23px; text-transform: uppercase; color: #73451f; }
.online-discover-choice { display: flex; align-items: center; gap: 8px; margin-top: 14px; color: #704b2e; font-size: 14px; font-weight: 700; }
.online-discover-choice input { width: 18px; height: 18px; accent-color: #d98837; }
.online-discovery { display: flex; flex-wrap: wrap; gap: 8px; color: #79563c; font-size: 13px; }
.online-discovery-room { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 12px; border: 2px solid #e7bb79; border-radius: 12px; background: #fffaf0; color: #73451f; cursor: pointer; }
.online-discovery-room:hover { background: #ffe6a9; }
.online-code { display: inline-block; padding: 8px 17px; margin: 7px 0; background: #fff; border: 2px dashed #e1a85c; border-radius: 13px; color: #754618; letter-spacing: 5px; font-size: 25px; font-weight: 1000; }
.online-player-list { display: grid; gap: 7px; margin: 15px 0; }
.online-player { display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 9px 11px; border-radius: 13px; background: #fffaf0; border: 1px solid #e9d3ae; font-size: 13px; color: #6d4d2e; }
.online-player strong { overflow-wrap: anywhere; }
.online-badge { border-radius: 99px; padding: 4px 9px; background: #f8e4c4; white-space: nowrap; font-weight: 900; }
.online-badge.ready { background: #dcf4db; color: #2d913d; }
.online-role-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin: 15px 0; }
.online-role { padding: 9px 5px; border: 2px solid #ead1ab; border-radius: 16px; background: #fffaf0; color: #704321; font-weight: 900; }
.online-role.selected { border-color: #ff9d37; background: #fff0c7; }
.online-role img { display: block; width: min(100%, 95px); height: 93px; object-fit: contain; margin: auto; }
.online-message { min-height: 22px; color: #a04d28; font-size: 13px; font-weight: 800; }

#onlineBattle { position: fixed; inset: 0; z-index: 210000; overflow: hidden; background: #9bc9e7; font-family: ui-rounded, "PingFang SC", system-ui, sans-serif; touch-action: none; }
#onlineBattle canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.online-hud { position: absolute; left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); top: max(8px, env(safe-area-inset-top)); display: flex; align-items: flex-start; justify-content: space-between; gap: 9px; pointer-events: none; }
.online-hud > * { pointer-events: auto; }
.online-hud-main { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.online-hud-chip { padding: 7px 10px; border-radius: 12px; background: #fff7e7eb; border: 2px solid white; color: #6d4728; box-shadow: 0 3px 0 #bd8e5b; font-weight: 900; font-size: 12px; }
.online-hud-chip strong { color: #e16f2b; }
.online-scores { position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + 49px); left: 10px; right: 10px; display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; pointer-events: none; }
.online-score { max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 5px 8px; border-radius: 99px; background: #fff7dfe8; border: 1px solid white; color: #643c21; font-size: 11px; font-weight: 900; }
.online-score.mine { outline: 2px solid #ff9629; }
.online-controls { position: absolute; left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); display: flex; align-items: end; justify-content: space-between; pointer-events: none; }
.online-joystick, .online-charge { pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.online-joystick { width: 112px; height: 112px; border-radius: 50%; border: 3px solid #fff9e5; background: #fff8e0ac; box-shadow: 0 6px 18px #58351c55; display: grid; place-items: center; }
.online-joystick-knob { width: 43px; height: 43px; border-radius: 50%; background: linear-gradient(#ffda79,#f7a141); border: 3px solid white; box-shadow: 0 4px 0 #bd7836; }
.online-charge { width: 118px; height: 118px; border-radius: 50%; border: 4px solid #fff; background: radial-gradient(circle at 35% 25%,#fff7ae,#ffc04c 65%,#f48436); color: #653519; box-shadow: 0 8px 0 #b8602f, 0 13px 20px #512b2455; font-size: 19px; font-weight: 1000; }
.online-charge.charging { transform: scale(.95); background: radial-gradient(circle,#fff5a8,#ff9047); }
@media (hover: hover) and (pointer: fine) {
  .online-controls { display: none; }
}
.online-connection { position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + 90px); left: 50%; transform: translateX(-50%); background: #fff8e9d9; border-radius: 99px; padding: 4px 10px; color: #9d5633; font-size: 11px; font-weight: 900; pointer-events: none; }
.online-result { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; background: #422a22b8; backdrop-filter: blur(7px); }
.online-result-card { width: min(420px,100%); padding: 25px; border-radius: 24px; background: #fff3d8; border: 3px solid white; text-align: center; color: #704321; }
.online-result-list { text-align: left; margin: 17px 0; line-height: 1.8; }

@media (max-width: 700px) and (orientation: portrait) {
  #onlineOverlay { display: block; padding: calc(env(safe-area-inset-top) + 8px) 9px calc(env(safe-area-inset-bottom) + 16px); }
  .online-card { display: flex; flex-direction: column; width: min(100%, 480px); margin: 0 auto; border-radius: 23px; }
  .online-art { min-height: 0; height: clamp(145px, 24dvh, 195px); flex: none; background-position: center 46%; }
  .online-main { padding: 16px 14px 20px; }
  .online-main h2 { font-size: 30px; }
  .online-main p { font-size: 12px; }
  .online-actions { gap: 7px; }
  .online-btn { flex: 1 1 130px; min-width: 0; font-size: 14px; padding: 9px; }
  .online-role img { height: 68px; }
  .online-role { font-size: 13px; }
  .online-hud { gap: 4px; }
  .online-hud-chip { font-size: 10px; padding: 5px 6px; }
  .online-hud .online-btn { min-height: 34px; flex: none; font-size: 11px; padding: 4px 7px; }
  .online-scores { top: calc(max(8px, env(safe-area-inset-top)) + 40px); }
  .online-connection { top: calc(max(8px, env(safe-area-inset-top)) + 85px); }
  .online-joystick { width: 100px; height: 100px; }
  .online-charge { width: 106px; height: 106px; font-size: 16px; }
}
