:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  color: #333;
  background: #dcdcdc;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
#arena { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
.hud { position: fixed; z-index: 2; }
.panel-title { font-size: 13px; font-weight: 800; letter-spacing: .02em; }
.eyebrow { color: #41778c; font-size: 12px; font-weight: 800; letter-spacing: .08em; }

.population-label { left: 14px; top: 12px; padding: 6px 10px; border-radius: 5px; background: rgba(255,255,255,.78); color: #4b5a61; font-size: 13px; font-weight: 700; box-shadow: 0 1px 2px #0002; }

.leaderboard-panel { top: 12px; right: 14px; width: 230px; }
.leaderboard-panel .panel-title { margin-bottom: 5px; text-align: center; color: #333; text-shadow: 0 1px #fff9; font-size: 20px; }
.leaderboard-panel ol { list-style: none; display: grid; gap: 3px; margin: 0; padding: 0; }
.leaderboard-panel li { position: relative; display: grid; grid-template-columns: 23px minmax(0,1fr) auto; gap: 4px; align-items: center; height: 19px; padding: 0 8px; overflow: hidden; border-radius: 12px; background: #343434; color: #fff; font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px #000b; }
.leaderboard-panel li::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--score-ratio, 0%); background: #54d495; }
.leaderboard-panel li.me::before { background: #2ebde4; }
.leaderboard-panel li span { position: relative; z-index: 1; }
.leaderboard-panel .place { color: #e4e4e4; }
.leaderboard-panel .name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.leaderboard-panel .score { font-variant-numeric: tabular-nums; }

.shards-panel { left: 14px; top: 51px; width: 236px; padding: 9px; border: 1px solid #8888; border-radius: 6px; background: rgba(245,245,245,.82); box-shadow: 0 2px 6px #0002; }
.shards-panel .panel-title { display: flex; justify-content: space-between; margin: 0 3px 6px; color: #474747; }
.shard { display: grid; grid-template-columns: 19px minmax(0,1fr) 34px; gap: 5px; align-items: center; padding: 4px 5px; margin-top: 3px; border: 1px solid #aaa; border-radius: 4px; background: #e1e1e1; color: #777; }
.shard strong { display: block; font-size: 12px; color: #515151; }
.shard small { display: block; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shard b { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
#exploreProgress { font-size: 16px; font-weight: 800; color: #3c3c3c; }
.shard-icon { font-size: 16px; }
.shard.earned { border-color: #4eab83; background: #c9eddb; }
.shard.earned strong, .shard.earned b, .shard.earned .shard-icon { color: #26865e; }
.shard.earned #exploreProgress { color: #26865e; }
.signal { margin: 6px 3px 0; color: #555; font-size: 11px; }

.stats-panel { left: 14px; bottom: 16px; width: 270px; padding: 7px; border-radius: 5px; background: rgba(242,242,242,.74); border: 1px solid #9997; }
.stats-panel .panel-title { display: flex; justify-content: space-between; margin-bottom: 5px; color: #555; }
.stat-rows { display: grid; gap: 3px; }
.stat-button { --stat-color: #67cfa2; display: grid; grid-template-columns: 18px 94px 1fr; align-items: center; gap: 4px; width: 100%; height: 26px; padding: 2px 5px; border: 1px solid #7778; border-radius: 3px; background: #f3f3f3; color: #333; text-align: left; font-size: 11px; font-weight: 700; }
.stat-button:nth-child(1) { --stat-color: #f1709a; }
.stat-button:nth-child(2) { --stat-color: #9868cc; }
.stat-button:nth-child(3) { --stat-color: #e9a353; }
.stat-button:nth-child(4) { --stat-color: #e9cf5f; }
.stat-button:nth-child(5) { --stat-color: #5ec9d8; }
.stat-button:nth-child(6) { --stat-color: #e96e6e; }
.stat-button:nth-child(7) { --stat-color: #7cc971; }
.stat-button:nth-child(8) { --stat-color: #6db0e3; }
.stat-button:hover:not(:disabled) { background: #fff; border-color: #555; }
.stat-button:disabled { cursor: default; opacity: .72; }
.stat-key { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 2px; background: #606060; color: white; font-size: 10px; }
.stat-bar { display: flex; gap: 2px; }
.stat-bar i { flex: 1; height: 13px; border: 1px solid #7777; background: #d0d0d0; }
.stat-bar i.filled { background: var(--stat-color); }

.class-panel { top: 12px; left: 265px; padding: 8px; max-width: calc(100vw - 540px); border: 1px solid #8889; border-radius: 5px; background: rgba(240,240,240,.92); }
.class-panel .panel-title { margin-bottom: 6px; font-size: 12px; color: #555; }
.class-choices { display: flex; gap: 5px; }
.class-choices button { display: grid; justify-items: center; align-items: center; min-width: 88px; min-height: 82px; padding: 6px; border: 1px solid #777; border-radius: 4px; background: #fff; color: #333; font-size: 12px; font-weight: 700; }
.class-choices button:hover { border-color: #2593b6; background: #e0f7ff; }
.class-choices canvas { width: 48px; height: 48px; }

.minimap-panel { right: 14px; bottom: 14px; padding: 4px; border: 3px solid #777; background: #b8b8b8; }
#minimap { display: block; width: 150px; height: 150px; background: #cfcfcf; }
.score-panel { left: 50%; bottom: 15px; transform: translateX(-50%); width: 390px; text-align: center; }
.tank-info { width: 100%; height: 20px; padding-top: 2px; border-radius: 12px; background: #363636; color: white; font-size: 13px; font-weight: 700; text-shadow: 0 1px #000; }
.xp-track { height: 17px; margin-top: 4px; overflow: hidden; border: 2px solid #333; border-radius: 12px; background: #424242; }
.xp-fill { height: 100%; width: 0; border-radius: 10px; background: #e8ce62; transition: width .12s; }
.controls-hint { bottom: 58px; left: 50%; transform: translateX(-50%); color: #444; font-size: 11px; font-weight: 700; white-space: nowrap; text-shadow: 0 1px #fffa; }
.death-notice { position: fixed; z-index: 3; top: 50%; left: 50%; transform: translate(-50%,-50%); padding: 14px 22px; border: 2px solid #9d5555; border-radius: 4px; background: #f1d1d1; color: #9b3232; font-size: 18px; font-weight: 800; }

.overlay { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 20px; background: rgba(30,30,30,.48); }
.start-card, .flag-card { width: min(100%, 500px); padding: 28px; border: 3px solid #777; border-radius: 7px; background: #ececec; box-shadow: 0 10px 35px #0005; text-align: center; }
.hero-tank { display: block; width: 96px; height: 96px; margin: 6px auto 0; }
.start-card h2, .flag-card h2 { margin: 12px 0; font-size: clamp(34px,5vw,58px); letter-spacing: -.055em; line-height: 1; color: #343434; text-shadow: 0 2px white; }
.start-card label { display: block; margin: 0 0 7px; color: #555; font-size: 13px; font-weight: 700; text-align: left; }
.join-row { display: flex; gap: 7px; }
.join-row input { flex: 1; min-width: 0; padding: 11px; border: 2px solid #888; border-radius: 4px; background: white; color: #333; font-size: 16px; }
.join-row input:focus { outline: 2px solid #54bdd9; }
.join-row button { padding: 10px 20px; border: 2px solid #3386a0; border-radius: 4px; background: #4dc4e5; color: #173c49; font-size: 15px; font-weight: 800; }
.join-row button:hover { background: #73d5f0; }
.join-status { margin-top: 10px; color: #666; font-size: 12px; }
.join-status:empty { display: none; }
.flag-card code { display: block; margin: 20px 0; padding: 15px; border: 2px solid #4eaf89; background: #dff5e8; color: #255b41; font-size: 18px; overflow-wrap: anywhere; }

@media (max-width: 820px) {
  .leaderboard-panel { width: 170px; }
  .leaderboard-panel li { font-size: 10px; }
  .shards-panel { width: 205px; }
  .class-panel { left: 225px; max-width: calc(100vw - 415px); }
  .stats-panel { width: 220px; }
  .stat-button { grid-template-columns: 17px 80px 1fr; font-size: 10px; }
  .minimap-panel { right: 8px; bottom: 8px; }
  #minimap { width: 105px; height: 105px; }
  .score-panel { width: 300px; }
}

@media (max-width: 600px) {
  .population-label { left: 7px; top: 7px; font-size: 10px; }
  .leaderboard-panel { right: 7px; top: 7px; width: 130px; }
  .leaderboard-panel .panel-title { font-size: 14px; }
  .leaderboard-panel li:nth-child(n+6) { display: none; }
  .leaderboard-panel li { height: 17px; grid-template-columns: 17px minmax(0,1fr); padding: 0 5px; }
  .leaderboard-panel .score { display: none; }
  .shards-panel { top: 36px; left: 7px; width: 160px; padding: 5px; }
  .shards-panel .panel-title { font-size: 10px; }
  .shard { grid-template-columns: 14px 1fr 28px; gap: 2px; padding: 2px; }
  .shard strong { font-size: 10px; }
  .shard small { display: none; }
  .shard-icon { font-size: 12px; }
  #exploreProgress { font-size: 13px; }
  .signal { font-size: 10px; }
  .stats-panel { left: 7px; bottom: 7px; width: 160px; padding: 4px; }
  .stats-panel .panel-title { font-size: 10px; }
  .stat-button { height: 21px; grid-template-columns: 15px 56px 1fr; gap: 2px; font-size: 9px; padding: 1px 2px; }
  .stat-key { width: 14px; height: 14px; font-size: 8px; }
  .stat-bar { gap: 1px; }
  .stat-bar i { height: 10px; }
  .class-panel { top: 34px; left: 50%; transform: translateX(-50%); max-width: 95vw; }
  .class-choices button { min-width: 55px; min-height: 66px; font-size: 10px; }
  .class-choices canvas { width: 36px; height: 36px; }
  .minimap-panel { right: 7px; bottom: 7px; padding: 2px; border-width: 2px; }
  #minimap { width: 82px; height: 82px; }
  .score-panel { bottom: 7px; width: min(45vw, 210px); }
  .tank-info { height: 17px; font-size: 9px; }
  .xp-track { height: 12px; }
  .controls-hint { display: none; }
  .join-row { flex-direction: column; }
}
