/* ============================================================
   TANK BATTLE — HUD, menus, panels, buttons (arcade UI skin)
   ============================================================ */

/* ---------------- HUD pieces ---------------- */
.hp-plate {
  flex: 1 1 0;
  min-width: 0;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 2px solid var(--panel-edge);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 3px 8px rgba(0, 0, 0, .35);
}

.plate-enemy {
  max-width: 340px;
}

.plate-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
}

.plate-head.right {
  justify-content: flex-end;
}

.plate-name {
  font-size: clamp(10px, 1.4vw, 13px);
  font-weight: 900;
  letter-spacing: .18em;
  color: var(--text);
  text-shadow: 0 1px 0 #000;
}

.enemy-count {
  color: var(--accent);
}

.tank-dot {
  width: 14px;
  height: 14px;
  border-radius: 50% 50% 42% 42%;
  border: 2px solid rgba(0, 0, 0, .55);
  box-shadow: inset -2px -2px 3px rgba(0, 0, 0, .4), inset 2px 2px 3px rgba(255, 255, 255, .35);
}

.dot-player {
  background: radial-gradient(circle at 34% 30%, #9fe06f, #4c9a2e);
}

.dot-enemy {
  background: radial-gradient(circle at 34% 30%, #86b9ff, #2d63b8);
}

.hp-bar {
  position: relative;
  height: clamp(16px, 2.6vmin, 22px);
  border-radius: 999px;
  background: #0a0f15;
  border: 2px solid rgba(0, 0, 0, .75);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, .65);
  overflow: hidden;
}

.hp-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transition: transform .25s ease-out, filter .25s ease;
  will-change: transform;
}

.fill-player {
  background: linear-gradient(180deg, #b8ef85 0%, #67c93e 45%, #2f7d1c 100%);
}

.fill-enemy {
  background: linear-gradient(180deg, #a9cdff 0%, #4f97ec 45%, #2358ad 100%);
  transform-origin: right center;
}

.hp-fill.low {
  filter: saturate(.4) brightness(.8) sepia(.4) hue-rotate(-40deg);
}

.hp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(9px, 1.5vw, 12px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .9);
  letter-spacing: .05em;
}

.hud-center {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.score-chip,
.round-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: clamp(64px, 9vw, 108px);
  padding: 4px 12px;
  background: linear-gradient(180deg, #243447, #16222f);
  border: 2px solid var(--panel-edge);
  border-radius: var(--radius-md);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .09), 0 3px 8px rgba(0, 0, 0, .35);
}

.chip-label {
  font-size: clamp(8px, 1.1vw, 10px);
  font-weight: 900;
  letter-spacing: .28em;
  color: var(--muted);
}

.chip-value {
  font-size: clamp(15px, 2.4vw, 24px);
  font-weight: 900;
  color: var(--accent-2);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .55);
  line-height: 1.1;
}

#hud-score.bump {
  animation: scoreBump .3s ease;
}

@keyframes scoreBump {
  40% {
    transform: scale(1.28);
    color: #fff;
  }
}

.icon-btn {
  display: grid;
  place-items: center;
  width: clamp(36px, 5vw, 44px);
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  border: 2px solid var(--panel-edge);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .45);
  transition: transform .06s ease, filter .15s ease;
}

.icon-btn:hover {
  filter: brightness(1.2);
}

.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .45);
}

/* ---------------- Buttons ---------------- */
.btn {
  font-family: inherit;
  font-weight: 900;
  letter-spacing: .1em;
  color: #fff;
  border: 3px solid rgba(0, 0, 0, .55);
  border-radius: 14px;
  padding: 12px 26px;
  font-size: clamp(13px, 1.8vw, 17px);
  cursor: pointer;
  position: relative;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .4);
  transition: transform .07s ease, box-shadow .07s ease, filter .15s ease;
}

.btn::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 7%;
  height: 30%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .42), rgba(255, 255, 255, .05));
  pointer-events: none;
}

.btn:hover {
  filter: brightness(1.1);
}

.btn:active {
  transform: translateY(3px);
}

.btn:focus-visible,
button:focus-visible,
.setting-row:focus-visible,
.diff-opt:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: 2px;
}

.btn-primary {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .35), transparent 40%),
    linear-gradient(180deg, #7ed957 0%, #4caf33 48%, #2e7d1c 100%);
  box-shadow: 0 6px 0 #1d5711, 0 10px 20px rgba(0, 0, 0, .4), inset 0 2px 6px rgba(255, 255, 255, .35);
}

.btn-primary:active {
  box-shadow: 0 2px 0 #1d5711, 0 5px 12px rgba(0, 0, 0, .4);
}

.btn-secondary {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .3), transparent 40%),
    linear-gradient(180deg, #5f7d99 0%, #3d5a77 48%, #274058 100%);
  box-shadow: 0 6px 0 #182c3e, 0 10px 20px rgba(0, 0, 0, .4), inset 0 2px 6px rgba(255, 255, 255, .3);
}

.btn-secondary:active {
  box-shadow: 0 2px 0 #182c3e, 0 5px 12px rgba(0, 0, 0, .4);
}

.btn-danger {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .3), transparent 40%),
    linear-gradient(180deg, #ff7a5c 0%, #e04a2f 48%, #9c2413 100%);
  box-shadow: 0 6px 0 #6d150c, 0 10px 20px rgba(0, 0, 0, .4), inset 0 2px 6px rgba(255, 255, 255, .3);
}

.btn-danger:active {
  box-shadow: 0 2px 0 #6d150c, 0 5px 12px rgba(0, 0, 0, .4);
}

.btn-big {
  font-size: clamp(17px, 2.6vw, 24px);
  padding: 16px 44px;
}

.mini-btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  border: 2px solid var(--panel-edge);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  cursor: pointer;
  white-space: nowrap;
}

.mini-btn:hover {
  filter: brightness(1.25);
}

/* ---------------- Overlay & screens ---------------- */
#overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

#overlay>.screen {
  pointer-events: auto;
}

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vmin, 32px);
  background: rgba(5, 10, 16, .66);
  backdrop-filter: blur(3px);
  animation: screenFade .25s ease;
}

@keyframes screenFade {
  from {
    opacity: 0;
  }
}

.screen.hidden {
  display: none;
}

/* Main menu gets its own painted backdrop */
#screen-menu {
  background:
    linear-gradient(180deg, #3f97dd 0%, #74bdef 46%, #b5e2fb 68%, #8fbf62 69%, #79aa4e 100%);
  overflow: hidden;
}

.menu-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.sun {
  position: absolute;
  top: 7%;
  left: 12%;
  width: clamp(90px, 16vw, 190px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 244, 180, .95) 0%, rgba(255, 214, 102, .55) 45%, transparent 70%);
  filter: blur(2px);
  animation: sunPulse 6s ease-in-out infinite;
}

@keyframes sunPulse {
  50% {
    transform: scale(1.08);
    opacity: .85;
  }
}

.cloud {
  position: absolute;
  width: clamp(120px, 22vw, 260px);
  height: clamp(38px, 6vw, 70px);
  background: rgba(255, 255, 255, .92);
  border-radius: 999px;
  box-shadow:
    40px -18px 0 -6px rgba(255, 255, 255, .92),
    90px -6px 0 -10px rgba(255, 255, 255, .92),
    -30px 6px 0 -12px rgba(255, 255, 255, .85);
  animation: drift 46s linear infinite;
  opacity: .9;
}

.cloud-a {
  top: 12%;
  animation-duration: 52s;
}

.cloud-b {
  top: 30%;
  transform: scale(.7);
  animation-duration: 38s;
  animation-delay: -19s;
}

@keyframes drift {
  from {
    left: -30%;
  }

  to {
    left: 110%;
  }
}

.hill {
  position: absolute;
  border-radius: 50%;
}

.hill-back {
  bottom: 24%;
  left: -14%;
  width: 70%;
  aspect-ratio: 2.4;
  background: #5f8f43;
  opacity: .8;
}

.hill-front {
  bottom: -34%;
  right: -20%;
  width: 90%;
  aspect-ratio: 2.2;
  background: #4f7c39;
}

.menu-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2.4vh, 22px);
  z-index: 2;
  width: min(94vw, 560px);
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: .92;
  transform: rotate(-2deg);
  margin-bottom: clamp(2px, 1vh, 8px);
  animation: logoBob 4s ease-in-out infinite;
}

@keyframes logoBob {
  50% {
    transform: rotate(-2deg) translateY(-6px);
  }
}

.logo-tank,
.logo-battle {
  font-weight: 900;
  font-size: clamp(52px, 13vw, 118px);
  letter-spacing: .04em;
  -webkit-text-stroke: 2px rgba(10, 16, 24, .9);
}

.logo-tank {
  color: #7ed957;
  text-shadow: 0 4px 0 #245310, 0 8px 0 rgba(0, 0, 0, .35), 0 18px 34px rgba(0, 0, 0, .4);
}

.logo-battle {
  color: #ffb02e;
  font-size: clamp(58px, 15vw, 138px);
  text-shadow: 0 4px 0 #7a4a00, 0 9px 0 rgba(0, 0, 0, .35), 0 20px 38px rgba(0, 0, 0, .45);
}

.tagline {
  font-weight: 800;
  letter-spacing: .3em;
  font-size: clamp(9px, 1.9vw, 14px);
  color: #12300a;
  background: rgba(255, 255, 255, .72);
  padding: 5px 16px;
  border-radius: 999px;
  border: 2px solid rgba(10, 30, 5, .25);
  text-align: center;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(100%, 360px);
}

.menu-buttons .btn {
  width: 100%;
}

.menu-buttons .btn-big {
  width: 100%;
}

.best-chip {
  margin-top: clamp(2px, 1.4vh, 10px);
  font-weight: 900;
  letter-spacing: .18em;
  font-size: clamp(11px, 2vw, 15px);
  color: #fff;
  background: linear-gradient(180deg, rgba(20, 32, 46, .9), rgba(12, 20, 30, .9));
  border: 2px solid rgba(255, 255, 255, .18);
  padding: 8px 22px;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .35);
}

.best-chip span {
  color: var(--accent-2);
}

/* ---------------- Panels (pause / results / modals) ---------------- */
.panel {
  position: relative;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(84, 124, 164, .25), transparent 60%),
    linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 3px solid rgba(0, 0, 0, .6);
  outline: 2px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: clamp(18px, 4vmin, 36px);
  width: min(94vw, 480px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  animation: panelPop .3s cubic-bezier(.2, 1.5, .4, 1);
}

@keyframes panelPop {
  from {
    transform: scale(.82);
    opacity: 0;
  }
}

.panel-narrow {
  width: min(94vw, 420px);
}

.panel-wide {
  width: min(96vw, 780px);
}

.panel-result {
  text-align: center;
}

.panel-title {
  font-size: clamp(26px, 5.4vw, 44px);
  font-weight: 900;
  letter-spacing: .08em;
  color: var(--accent-2);
  text-shadow: 0 3px 0 rgba(0, 0, 0, .55);
  margin-bottom: 14px;
  text-align: center;
}

.title-win {
  color: #ffd23e;
}

.title-lose {
  color: #ff6a52;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row-wrap {
  margin-top: 16px;
}

.result-emblem {
  font-size: clamp(54px, 11vw, 92px);
  line-height: 1;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, .5));
  animation: emblemPop .55s cubic-bezier(.2, 1.8, .4, 1);
}

@keyframes emblemPop {
  from {
    transform: scale(0) rotate(-30deg);
  }
}

.emblem-win {
  animation-delay: .05s;
}

.emblem-lose {
  animation-delay: .05s;
}

.result-sub {
  color: var(--muted);
  font-weight: 700;
  letter-spacing: .12em;
  font-size: clamp(12px, 2.2vw, 16px);
  margin: -6px 0 12px;
}

.breakdown {
  list-style: none;
  margin: 0 auto 12px;
  width: min(100%, 320px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-weight: 800;
  font-size: clamp(11px, 2vw, 14px);
  color: var(--muted);
  background: rgba(0, 0, 0, .25);
  border-radius: 8px;
  padding: 7px 12px;
  animation: rowIn .4s ease backwards;
}

.breakdown li b {
  color: var(--accent-2);
}

@keyframes rowIn {
  from {
    transform: translateX(-14px);
    opacity: 0;
  }
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 4px;
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 110px;
  background: rgba(0, 0, 0, .3);
  border: 2px solid var(--panel-edge);
  border-radius: var(--radius-md);
  padding: 10px 18px;
}

.stat span {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .26em;
  color: var(--muted);
}

.stat b {
  font-size: clamp(20px, 4vw, 30px);
  font-weight: 900;
  color: #fff;
}

.victory-panel {
  border-color: rgba(255, 210, 62, .4);
  box-shadow: var(--shadow-pop), 0 0 60px rgba(255, 196, 40, .25);
}

.defeat-panel {
  border-color: rgba(232, 80, 58, .45);
  box-shadow: var(--shadow-pop), 0 0 60px rgba(220, 60, 30, .25);
}

/* ---------------- Modals ---------------- */
.modal {
  align-items: end;
  justify-items: center;
}

.modal .panel {
  margin-bottom: 0;
}

@media (min-width: 700px) {
  .modal {
    align-items: center;
  }

  .modal .panel {
    margin-bottom: auto;
    margin-top: auto;
  }
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 2px solid var(--panel-edge);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  z-index: 2;
}

.close-btn:hover {
  filter: brightness(1.3);
}

.howto-body {
  margin-top: 4px;
}

.howto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 12px;
}

.howto-card {
  background: rgba(0, 0, 0, .28);
  border: 2px solid var(--panel-edge);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.howto-card h3 {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .14em;
  color: var(--accent-2);
  margin-bottom: 8px;
}

.howto-card ul,
.howto-card p {
  list-style: none;
  color: var(--text);
  font-size: clamp(11px, 1.9vw, 13px);
  line-height: 1.55;
}

.howto-card li {
  padding-left: 14px;
  position: relative;
}

.howto-card li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--accent);
}

.howto-card b {
  color: #fff;
}

.modal-footer {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.diff-list,
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diff-opt,
.setting-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  font-family: inherit;
  background: rgba(0, 0, 0, .28);
  border: 2px solid var(--panel-edge);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .07s ease;
}

.diff-opt b {
  color: #fff;
  font-size: 15px;
  letter-spacing: .12em;
}

.diff-opt span,
.diff-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.diff-note {
  text-align: center;
  margin-top: 12px;
}

.diff-opt:hover,
.setting-row:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.diff-opt.selected {
  border-color: var(--accent-2);
  background: linear-gradient(180deg, rgba(255, 176, 46, .18), rgba(0, 0, 0, .28));
}

.diff-opt.selected b {
  color: var(--accent-2);
}

.setting-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  font-weight: 800;
  font-size: clamp(12px, 2.2vw, 14px);
  letter-spacing: .08em;
}

.switch-state {
  font-weight: 900;
  font-size: 12px;
  letter-spacing: .14em;
  color: #0d1a0d;
  background: linear-gradient(180deg, #8fe06a, #4da32c);
  border-radius: 999px;
  padding: 5px 14px;
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, .25);
}

.setting-row[aria-checked="false"] .switch-state,
.setting-row.off .switch-state {
  color: #fff;
  background: linear-gradient(180deg, #7d8ea0, #46586b);
}

.danger-row .switch-state {
  background: linear-gradient(180deg, #ffb84d, #d97a1a);
}

/* ---------------- Level select ---------------- */
.menu-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.level-chip span {
  color: #7ed957;
}

.levels-note {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  font-size: clamp(11px, 2vw, 14px);
  letter-spacing: .08em;
  margin-top: -6px;
}

.levels-note b {
  color: var(--accent-2);
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.lvl-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  aspect-ratio: 1;
  border-radius: 14px;
  border: 2px solid var(--panel-edge);
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, .12), transparent 45%),
    linear-gradient(180deg, rgba(0, 0, 0, .18), rgba(0, 0, 0, .38));
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  transition: transform .07s ease, filter .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.lvl-tile:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.25);
  border-color: var(--accent);
}

.lvl-num {
  font-size: clamp(17px, 3.4vw, 24px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .5);
}

.lvl-flag {
  font-size: clamp(7px, 1.4vw, 9px);
  font-weight: 900;
  letter-spacing: .1em;
  color: var(--muted);
}

/* cleared levels */
.lvl-tile.done {
  border-color: rgba(126, 217, 87, .55);
}

.lvl-tile.done .lvl-flag {
  color: #7ed957;
}

.lvl-tile.done::after {
  content: "✓";
  position: absolute;
  top: -8px;
  right: -6px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: linear-gradient(180deg, #8fe06a, #4da32c);
  color: #0d1a0d;
  font-size: 13px;
  font-weight: 900;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}

/* the level where the player stopped */
.lvl-tile.here {
  border-color: var(--accent-2);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 210, 62, .28), transparent 65%),
    linear-gradient(180deg, rgba(255, 176, 46, .2), rgba(0, 0, 0, .32));
  box-shadow: 0 0 16px rgba(255, 210, 62, .35);
  animation: herePulse 1.6s ease-in-out infinite;
}

@keyframes herePulse {
  50% {
    box-shadow: 0 0 26px rgba(255, 210, 62, .6);
  }
}

.lvl-tile.here .lvl-flag {
  color: var(--accent-2);
}

/* locked levels */
.lvl-tile.locked {
  opacity: .42;
  cursor: not-allowed;
}

.lvl-tile.locked:hover {
  transform: none;
  filter: none;
  border-color: var(--panel-edge);
}

@media (prefers-reduced-motion: reduce) {
  .lvl-tile.here {
    animation: none;
  }
}