* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0f1420; color: #e8ecf4;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* Menu */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(8, 11, 18, .78); padding: 16px; z-index: 10; overflow-y: auto; }
.panel { width: min(560px, 100%); background: #171d2b; border: 1px solid #2a3348; border-radius: 16px; padding: 18px; text-align: center; margin: auto; }
h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: .5px; }
.sub { margin: 0 0 12px; color: #93a0b8; font-size: 13px; }
#name { width: 100%; padding: 11px; border-radius: 10px; border: 1px solid #2a3348; background: #0f1420; color: inherit; font-size: 16px; margin-bottom: 10px; }
.picks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.pick { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 4px; border-radius: 12px; border: 2px solid #2a3348; background: #0f1420; }
.pick.selected { border-color: #f5b942; background: #221f19; }
.pick b { font-size: 13px; }
.pick small { color: #93a0b8; font-size: 10px; }
.icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #10131b; }
.pickInfo { min-height: 34px; margin: 8px 0 10px; font-size: 12px; color: #c3cbe0; }
#play { width: 100%; padding: 13px; font-size: 18px; font-weight: 700; border: 0; border-radius: 12px; background: #f5b942; color: #1a1408; }
#play:disabled { opacity: .6; }
.msg { min-height: 18px; margin: 8px 0 0; font-size: 13px; color: #ff8a80; }
@media (max-width: 420px) { .picks { grid-template-columns: repeat(3, 1fr); } }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#topbar { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; background: rgba(10, 14, 22, .7); padding: 4px 14px; border-radius: 20px; font-weight: 800; font-size: 18px; }
.blue { color: #5aa9ff; } .red { color: #ff5a5a; } .vs { color: #93a0b8; font-size: 14px; }
#net { position: absolute; top: max(8px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); font-size: 11px; color: #93a0b8; background: rgba(10, 14, 22, .6); padding: 3px 8px; border-radius: 8px; }
#minimap { position: absolute; top: max(8px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); width: 200px; height: 64px; border-radius: 8px; border: 1px solid #2a3348; background: rgba(10, 14, 22, .7); }
#slots { position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + 70px); left: max(10px, env(safe-area-inset-left)); display: flex; gap: 3px; }
#slots span { width: 26px; height: 26px; border-radius: 6px; background: rgba(10, 14, 22, .7); border: 1px solid #2a3348; display: grid; place-items: center; font-size: 15px; }
#feed { position: absolute; top: 80px; right: max(10px, env(safe-area-inset-right)); display: flex; flex-direction: column; gap: 4px; align-items: flex-end; font-size: 12px; }
#feed div { background: rgba(10, 14, 22, .7); padding: 3px 8px; border-radius: 6px; }
#banner { position: absolute; top: 36%; left: 50%; transform: translate(-50%, -50%); font-size: 26px; font-weight: 800; text-align: center; text-shadow: 0 2px 8px #000; white-space: pre-line; }

#sideBtns { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + 200px); display: flex; gap: 8px; }
.pill { pointer-events: auto; border: 1px solid #f5b94288; background: rgba(30, 24, 10, .8); border-radius: 18px; padding: 6px 12px; font-weight: 800; color: #f5d27a; }
#scoreBtn { border-color: #2a3348; background: rgba(10, 14, 22, .8); color: #e8ecf4; }

#controls { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); width: 210px; height: 190px; pointer-events: none; }
#controls button { pointer-events: auto; position: absolute; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25); color: #fff; font-weight: 800; touch-action: none; overflow: hidden; }
.attack { right: 0; bottom: 0; width: 96px; height: 96px; font-size: 34px; background: rgba(220, 70, 70, .55); }
.attack.down { background: rgba(255, 90, 90, .85); }
.skill { width: 66px; height: 66px; font-size: 11px; line-height: 1.1; background: rgba(60, 90, 160, .6); padding: 4px; }
#s1 { right: 104px; bottom: 6px; }
#s2 { right: 70px; bottom: 104px; }
.skill .lbl { position: relative; z-index: 1; }
.skill .cd { position: absolute; inset: 0; display: none; place-items: center; background: rgba(0, 0, 0, .6); font-size: 20px; z-index: 2; }
.skill.cooling .cd { display: grid; }
#rotate { display: none; position: absolute; bottom: 50%; left: 50%; transform: translateX(-50%); background: rgba(10, 14, 22, .85); padding: 8px 14px; border-radius: 10px; font-size: 13px; }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: block; } }
@media (pointer: fine) { #controls { opacity: .5; } }

/* Shop and scoreboard sheets */
.sheet { position: fixed; z-index: 8; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow-y: auto; background: rgba(23, 29, 43, .97); border: 1px solid #2a3348; border-radius: 14px; padding: 12px; touch-action: pan-y; }
.sheetHead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sheetHead b { font-size: 17px; }
.goldBig { color: #f5d27a; font-weight: 800; }
.close { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; border: 1px solid #2a3348; background: #0f1420; }
.stats { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: #c3cbe0; margin-bottom: 8px; }
.stats span { background: #0f1420; border-radius: 6px; padding: 3px 7px; }
.owned { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.owned button { height: 46px; border-radius: 10px; border: 1px solid #2a3348; background: #0f1420; font-size: 22px; position: relative; }
.owned button.armed { border-color: #ff8a80; background: #2a1414; font-size: 11px; color: #ff8a80; }
.hint { font-size: 11px; color: #93a0b8; margin: 6px 0 8px; }
.itemList { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.item { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 8px; text-align: left; padding: 8px; border-radius: 10px; border: 1px solid #2a3348; background: #0f1420; }
.item .ic { grid-row: span 2; font-size: 24px; display: grid; place-items: center; }
.item b { font-size: 13px; }
.item small { font-size: 11px; color: #93a0b8; }
.item .cost { color: #f5d27a; font-weight: 700; }
.item:disabled { opacity: .45; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { padding: 5px 6px; text-align: left; }
th { color: #93a0b8; font-weight: 600; font-size: 11px; }
tr.me td { background: #2a2414; }
.teamRow td { font-weight: 800; padding-top: 10px; }
