* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
:root { color-scheme: dark; }
body {
  background: #16181d; color: #eee;
  font: 13px/1.3 system-ui, sans-serif;
  overscroll-behavior: none; touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}
#app { display: flex; flex-direction: column; height: 100%; min-height: 300px; }

#hud {
  display: flex; align-items: center; gap: 10px;
  padding: 6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
}
.track { height: 10px; background: #0008; border-radius: 5px; overflow: hidden; }
.track i { display: block; height: 100%; width: 100%; }
.hp { flex: 1 1 0; min-width: 0; }
.hp span { font-size: 11px; opacity: .8; }
.hp.police { text-align: right; }
.hp.riot i { background: #ffa53d; }
.hp.police i { background: #2f6fed; margin-left: auto; }
#mana { flex: 1.4 1 0; display: flex; align-items: center; gap: 6px; min-width: 0; }
#mana .track { flex: 1; height: 14px; }
#mana i { background: #b56cff; }
#mana b { width: 2.2em; text-align: right; color: #d7b3ff; }
#clock { font-variant-numeric: tabular-nums; opacity: .7; }
#pause, #speed, #settings { background: #2c3038; color: #eee; border: 0; border-radius: 6px; width: 34px; height: 30px; font-weight: bold; }

#stage { position: relative; flex: 1 1 auto; min-height: 0; }
#field { display: block; width: 100%; height: 100%; }
#hint {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  background: #000a; padding: 4px 10px; border-radius: 12px; pointer-events: none; white-space: nowrap;
}
#overlay {
  position: fixed; z-index: 2; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #000d; padding: 16px;
}
.panel { max-width: 560px; max-height: 100%; overflow-y: auto; text-align: center; }
.panel h1 { margin: 0 0 8px; font-size: 26px; }
.panel p { margin: 0 0 14px; opacity: .85; }
.panel button { background: #ffa53d; color: #111; border: 0; border-radius: 8px; padding: 10px 28px; font-size: 16px; font-weight: bold; }

#bar {
  display: flex; gap: 6px; justify-content: center;
  padding: 6px max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.card {
  position: relative; flex: 1 1 0; max-width: 120px; min-width: 0; height: 62px; padding: 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  background: #2c3038; color: #eee; border: 2px solid transparent; border-radius: 8px;
  font: inherit; font-size: 11px; overflow: hidden;
}
.card.spell { background: #33293d; }
.card canvas { width: 36px; height: 36px; }
.card .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.card .cost { position: absolute; top: 2px; right: 4px; color: #d7b3ff; font-weight: bold; }
.card .cool { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: #000a; pointer-events: none; }
.card.off { opacity: .6; }
.card.armed { border-color: #ffe14d; }

#legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 4px 14px; margin-top: 14px; text-align: left; font-size: 11px; }
#legend div { display: flex; align-items: center; gap: 6px; }
#legend canvas { width: 22px; height: 22px; flex: none; }
#legend b { display: block; }
/* second-rank button on the menu, pause and game-over screens */
.panel button.quiet { background: #2c3038; color: #eee; font-weight: normal; margin-left: 8px; }
#settings-panel {
  position: fixed; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center;
  background: #000d; padding: 16px;
}
#settings-panel .panel { width: min(360px, 100%); text-align: left; }
#settings-panel h1 { text-align: center; }
#settings-panel label { display: flex; justify-content: space-between; margin-top: 12px; font-size: 14px; }
#settings-panel input[type=range], #settings-panel select { width: 100%; margin-top: 4px; accent-color: #ffa53d; }
#settings-panel select { background: #2c3038; color: #eee; border: 0; border-radius: 6px; padding: 8px; font-size: 14px; }
#settings-panel p { margin: 4px 0 0; font-size: 12px; opacity: .75; }
#settings-close { display: block; margin: 18px auto 0; }
#rotate-note { display: none; margin: 12px 0 0; color: #ffe14d; }
@media (orientation: portrait) and (max-width: 600px) { #rotate-note { display: block; } }
