/* FROSTHOLD – HUD & Layout. Navy / Eiscyan / Gold. */

:root {
  --navy-0: #060d1a;
  --navy-1: #0b1526;
  --navy-2: #101f38;
  --navy-3: #16294a;
  --ice: #8fe4ff;
  --ice-deep: #3fa9c9;
  --ice-soft: #d6f4ff;
  --gold: #f5c96b;
  --gold-deep: #b98a2e;
  --danger: #ff6b6b;
  --good: #7ee08a;
  --text: #e8f4ff;
  --muted: #9fb6cf;
  --line: rgba(143, 228, 255, 0.22);
  --panel: rgba(13, 27, 48, 0.86);
  --radius: 14px;
  --tap: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--navy-0);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body { overflow: hidden; }

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100vw;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(63, 169, 201, 0.16), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(199, 155, 255, 0.10), transparent 60%),
    var(--navy-1);
}

/* ------------------------------- Top HUD ------------------------------- */

#hud-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  min-height: 64px;
  background: linear-gradient(180deg, rgba(16, 31, 56, 0.96), rgba(9, 18, 33, 0.96));
  border-bottom: 2px solid var(--line);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  flex-wrap: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 12px;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}
.brand-mark {
  font-size: 26px;
  color: var(--ice);
  text-shadow: 0 0 12px rgba(143, 228, 255, 0.8);
}
.brand-name {
  font-size: 20px;
  letter-spacing: 2px;
  font-weight: 700;
  background: linear-gradient(180deg, #ffffff, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stats { display: flex; gap: 10px; }
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 74px;
  padding: 4px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
}
.stat-label { font-size: 11px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.stat-value { font-size: 20px; font-weight: 700; }
.stat-lives .stat-value { color: var(--danger); }
.stat-gold .stat-value { color: var(--gold); }
.stat-wave .stat-value { color: var(--ice); }

.nextwave {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  min-width: 190px;
}
.nextwave-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.nextwave-title { font-size: 11px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.countdown { font-size: 17px; font-weight: 700; color: var(--gold); min-width: 46px; text-align: right; }
.nextwave-icons { display: flex; gap: 6px; flex-wrap: wrap; min-height: 18px; }
.nextwave-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(143, 228, 255, 0.12);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.nextwave-chip.boss { background: rgba(255, 107, 107, 0.18); border-color: rgba(255, 107, 107, 0.5); color: #ffd0d0; }
.nextwave-chip .swatch { width: 8px; height: 8px; border-radius: 50%; }

.controls { margin-left: auto; display: flex; gap: 8px; }

/* ------------------------------- Buttons ------------------------------- */

.btn {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--navy-3), var(--navy-2));
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: transform 0.06s ease, filter 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-gold {
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  color: #2a1c04;
  border-color: rgba(255, 235, 180, 0.7);
  box-shadow: 0 0 16px rgba(245, 201, 107, 0.28);
}
.btn-ice { color: var(--ice-soft); }
.btn-ice.active {
  background: linear-gradient(180deg, var(--ice), var(--ice-deep));
  color: #05202b;
  box-shadow: 0 0 16px rgba(143, 228, 255, 0.35);
}
.btn-big { font-size: 18px; padding: 0 30px; min-height: 52px; }
.btn-danger { color: #ffd9d9; border-color: rgba(255, 107, 107, 0.5); }

/* ------------------------------- Stage -------------------------------- */

#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

#canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  display: block;
  border-radius: 12px;
  border: 2px solid rgba(143, 228, 255, 0.25);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), inset 0 0 60px rgba(63, 169, 201, 0.12);
  touch-action: none;
  max-width: 100%;
  max-height: 100%;
  background: #0a1424;
}

/* ------------------------------- Banner ------------------------------- */

.banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  border-radius: 999px;
  background: rgba(6, 13, 26, 0.88);
  border: 1px solid var(--line);
  color: var(--ice-soft);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  white-space: nowrap;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
.banner.show { opacity: 1; }
.banner.warn { color: #ffd9d9; border-color: rgba(255, 107, 107, 0.5); }

/* ------------------------------- Overlays ----------------------------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(900px 500px at 50% 30%, rgba(16, 40, 70, 0.72), rgba(3, 8, 16, 0.92));
  backdrop-filter: blur(3px);
  z-index: 20;
  overflow: auto;
}
.overlay.hidden { display: none; }

.panel {
  background: linear-gradient(180deg, rgba(18, 36, 62, 0.98), rgba(8, 16, 30, 0.98));
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 20px 26px;
  max-width: 780px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), inset 0 0 40px rgba(63, 169, 201, 0.08);
  text-align: center;
}

.title-crest { font-size: 40px; color: var(--ice); text-shadow: 0 0 24px rgba(143, 228, 255, 0.9); }
.title-panel h1 {
  margin: 2px 0 4px;
  font-size: 42px;
  letter-spacing: 8px;
  background: linear-gradient(180deg, #ffffff, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.subtitle { margin: 0 0 14px; color: var(--muted); font-size: 15px; }

.tutorial-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
  text-align: left;
}
.tutorial-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
}
.tutorial-card h3 { margin: 0 0 4px; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.tutorial-card h3 em { margin-left: auto; font-style: normal; color: var(--gold); font-size: 13px; }
.tutorial-card p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, #fff); box-shadow: 0 0 8px var(--c, #fff); display: inline-block; }

.rules {
  text-align: left;
  margin: 0 0 16px;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.rules strong { color: var(--ice-soft); }

.end-icon { font-size: 46px; }
.end-panel h2 { margin: 6px 0; font-size: 34px; letter-spacing: 3px; }
.end-panel h2.win { color: var(--gold); text-shadow: 0 0 20px rgba(245, 201, 107, 0.5); }
.end-panel h2.lose { color: var(--danger); text-shadow: 0 0 20px rgba(255, 107, 107, 0.4); }
.end-stats { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin: 14px 0; }
.end-stats .stat { min-width: 96px; }

.rotate-panel { max-width: 420px; }
.rotate-icon { font-size: 42px; }

/* ------------------------------- Bottom HUD --------------------------- */

#hud-bottom {
  display: flex;
  gap: 12px;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom, 0px));
  min-height: 132px;
  background: linear-gradient(0deg, rgba(16, 31, 56, 0.97), rgba(9, 18, 33, 0.97));
  border-top: 2px solid var(--line);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.45);
}

.palette {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  flex: 1 1 58%;
  min-width: 0;
}

.tower-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(22, 41, 74, 0.9), rgba(11, 21, 38, 0.9));
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: transform 0.06s ease, border-color 0.15s, box-shadow 0.15s;
}
.tower-card:active { transform: translateY(1px); }
.tower-card.selected { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(245, 201, 107, 0.35), 0 0 18px rgba(245, 201, 107, 0.25); }
.tower-card.cant { opacity: 0.5; }
.tower-card .tc-head { display: flex; align-items: center; gap: 6px; width: 100%; }
.tower-card .tc-name { font-size: 13.5px; font-weight: 700; }
.tower-card .tc-cost { margin-left: auto; color: var(--gold); font-size: 13px; font-weight: 700; }
.tower-card .tc-stats { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.tower-card .tc-key { font-size: 10px; color: rgba(159, 182, 207, 0.7); }
.tc-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); flex: none; }

.selection {
  flex: 1 1 42%;
  min-width: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 12px;
  display: flex;
  align-items: center;
}
.sel-empty { color: var(--muted); font-size: 13px; }

.sel-body { width: 100%; display: flex; gap: 12px; align-items: center; }
.sel-info { flex: 1 1 auto; min-width: 0; }
.sel-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.sel-title .lv { font-size: 12px; color: var(--gold); border: 1px solid var(--gold-deep); border-radius: 999px; padding: 0 8px; }
.sel-line { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.sel-line b { color: var(--ice-soft); }
.sel-line .up { color: var(--good); }
.sel-special { font-size: 12px; color: #cbb8ff; }
.sel-actions { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.sel-actions .btn { min-height: var(--tap); font-size: 13.5px; padding: 0 14px; }
.sel-actions .row { display: flex; gap: 6px; }

/* ------------------------------- Responsive --------------------------- */

@media (max-width: 1080px) {
  .brand-name { display: none; }
  .nextwave { min-width: 150px; }
  .stat { min-width: 62px; padding: 4px 8px; }
  .tower-card .tc-stats { font-size: 11px; }
}

@media (max-width: 900px) {
  #hud-top { gap: 8px; padding: 6px 10px; min-height: 58px; }
  .stat-value { font-size: 17px; }
  .nextwave-title { display: none; }
  #hud-bottom { flex-direction: column; min-height: 0; gap: 8px; }
  .palette { flex: none; }
  .selection { flex: none; }
  .sel-body { flex-wrap: wrap; }
}

@media (orientation: portrait) and (max-width: 900px) {
  .tutorial-grid { grid-template-columns: 1fr; }
  .title-panel h1 { font-size: 34px; letter-spacing: 5px; }
}

/* Tablet review: readable combat information and scroll-safe short screens. */
.stat-label, .nextwave-title { font-size: 12px; }
.tower-card .tc-name, .tower-card .tc-cost,
.tower-card .tc-stats, .sel-line, .sel-special, .sel-empty,
.tutorial-card p, .rules, .sel-actions .btn { font-size: 14px; }
.tower-card .tc-head { flex-wrap: wrap; }
.tower-card .tc-key { font-size: 12px; }
.overlay { align-items: flex-start; }
.panel { margin: auto; flex-shrink: 0; }
@media (pointer: coarse) { .tower-card .tc-key { display: none; } }
@media (max-height: 780px) and (orientation: landscape) {
  .title-crest { display: none; }
  .title-panel { padding: 12px 20px; }
  .title-panel h1 { font-size: 30px; letter-spacing: 5px; }
  .title-panel .subtitle { margin-bottom: 8px; }
  .title-panel .rules { margin: 8px 0; }
  .title-panel .tutorial-grid { gap: 6px; margin-bottom: 6px; }
  .title-panel .tutorial-card { padding: 6px 10px; }
  .title-panel .btn-big { min-height: 44px; }
}
