:root {
  --towerd-ink: #191a2b;
  --towerd-muted: #6b6c7d;
  --towerd-brand: #17182b;
  --towerd-blue: #4f88d4;
  --towerd-blue-dark: #376db7;
  --towerd-paper: #f6f6fb;
  --towerd-line: #e3e2ed;
}

body.towerd-body {
  min-height: 100vh;
  color: var(--towerd-ink);
  background: var(--towerd-paper);
  -webkit-font-smoothing: antialiased;
}

.towerd-page {
  flex: 1 0 auto;
  overflow: hidden;
  background: var(--towerd-paper);
}

.towerd-mobile-bar { display: none; }

.towerd-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
}

.towerd-kicker {
  margin: 0;
  font-size: .68rem;
  font-weight: 850;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.towerd-title-icon {
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #5c9de6, #406fc2);
  box-shadow: 0 9px 20px rgba(24, 23, 50, .25), inset 0 1px 0 rgba(255, 255, 255, .25);
  font-weight: 850;
}

.towerd-game-section { padding: 26px 0 58px; }

.towerd-game-panel {
  overflow: hidden;
  border: 1px solid rgba(48, 44, 91, .09);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(41, 36, 93, .075), 0 2px 7px rgba(31, 28, 69, .035);
}

.towerd-game-toolbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 13px 16px 13px 18px;
  border-bottom: 1px solid var(--towerd-line);
}

.towerd-title-lockup { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }

.towerd-title-icon {
  width: 43px;
  height: 43px;
  border-radius: 12px;
  font-size: .92rem;
}

.towerd-kicker { margin-bottom: 2px; color: var(--towerd-blue-dark); font-size: .58rem; }

.towerd-title-lockup h2 {
  margin: 0;
  color: var(--towerd-ink);
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.035em;
  text-align: left;
}

.towerd-score-wrap { min-width: 0; }

.towerd-scoreboard {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 7px;
}

.towerd-stat {
  min-width: 62px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 7px 11px;
  border: 1px solid #e6e5ef;
  border-radius: 10px;
  background: linear-gradient(180deg, #fbfbfd, #f4f3f9);
}

.towerd-stat span {
  color: #838495;
  font-size: .52rem;
  font-weight: 800;
  letter-spacing: .09em;
  line-height: 1;
  text-transform: uppercase;
}

.towerd-stat strong {
  color: var(--towerd-ink);
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
  font-weight: 820;
  line-height: 1.1;
}

.towerd-stat-time {
  min-width: 72px;
  border-color: #d8e5f5;
  background: linear-gradient(180deg, #f3f8fe, #eaf2fb);
}

.towerd-stat-time strong { color: var(--towerd-blue-dark); }

.towerd-icon-button {
  width: 42px;
  min-width: 42px;
  display: grid;
  place-items: center;
  color: var(--towerd-blue-dark);
  border: 1px solid #d8e5f5;
  border-radius: 10px;
  background: #edf4fc;
  font-size: 1rem;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.towerd-icon-button:hover,
.towerd-icon-button:focus-visible {
  color: #fff;
  border-color: var(--towerd-blue-dark);
  background: var(--towerd-blue-dark);
}

#game.towerd-game-frame {
  margin: 0;
  padding: 15px;
  background: linear-gradient(145deg, #17182b, #20223a);
}

#game .game-container {
  width: 100%;
  max-width: 1536px;
  aspect-ratio: 4 / 3;
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 13px;
  background: #1a1a1a;
  box-shadow: 0 18px 44px rgba(2, 3, 16, .32);
}

#game .game-container canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.towerd-game-note {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 11px 18px;
  color: var(--towerd-muted);
  border-top: 1px solid var(--towerd-line);
  font-size: .72rem;
  font-weight: 620;
}

.towerd-game-note > span { display: inline-flex; align-items: center; gap: 8px; }
.towerd-game-note > span .bi { color: var(--towerd-blue-dark); }

.towerd-help-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  color: var(--towerd-blue-dark);
  border: 0;
  background: transparent;
  font-size: .72rem;
  font-weight: 780;
}

.towerd-help-button:hover { color: #284f88; text-decoration: underline; text-underline-offset: 4px; }

.towerd-body .modal-content {
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(23, 24, 43, .22);
}

.towerd-body .modal-header { padding: 18px 20px; border-bottom-color: var(--towerd-line); }
.towerd-body .modal-title { color: var(--towerd-ink); font-weight: 800; letter-spacing: -.025em; }
.towerd-body .modal-body { padding: 20px; color: var(--towerd-muted); font-size: .9rem; line-height: 1.6; }
.towerd-body .modal-body p:last-child { margin-bottom: 0; }

@media (max-width: 1050px) {
  .towerd-game-toolbar { align-items: flex-start; flex-direction: column; }
  .towerd-score-wrap { width: 100%; }
  .towerd-scoreboard { justify-content: flex-start; overflow-x: auto; padding-bottom: 3px; }
  .towerd-stat, .towerd-icon-button { flex: 0 0 auto; }
}

@media (max-width: 820px) {
  .towerd-shell { width: min(100% - 36px, 680px); }
  .towerd-game-section { padding-top: 15px; }
  .towerd-game-panel { border-radius: 17px; }
  #game.towerd-game-frame { padding: 8px; }
  #game .game-container { border-radius: 10px; }
}

@media (max-width: 560px) {
  .towerd-shell { width: calc(100% - 20px); }

  .towerd-game-section { padding-bottom: 32px; }
  .towerd-game-toolbar { gap: 11px; padding: 12px; }
  .towerd-title-icon { width: 38px; height: 38px; }
  .towerd-stat { min-width: 57px; padding: 6px 9px; }
  .towerd-stat-time { min-width: 68px; }
  .towerd-icon-button { width: 38px; min-width: 38px; }
  #game.towerd-game-frame { padding: 5px; }
  .towerd-game-note { padding: 11px 12px; }
  .towerd-game-note > span { display: none; }
  .towerd-help-button { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .towerd-icon-button { transition: none; }
}

@media (max-width: 820px), (max-height: 560px) and (pointer: coarse) {
  body.towerd-body { height: 100dvh; min-height: 0; overflow: hidden; background: #0c1425; }
  .towerd-body > .app-navbar,
  .towerd-body #playsible-leaderboard-widget,
  .towerd-body #playsible-leaderboard-reopen { display: none; }
  .towerd-page { position: fixed; inset: 0; background: #0c1425; }
  .towerd-game-section { height: 100%; padding: 0; }
  .towerd-shell { width: 100%; height: 100%; }
  .towerd-game-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 0;
    border-radius: 0;
    background: #0c1425;
    box-shadow: none;
  }
  .towerd-game-toolbar, .towerd-game-note { display: none; }
  .towerd-mobile-bar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 16px;
    min-height: calc(48px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) max(8px, env(safe-area-inset-right, 0px)) 0 max(8px, env(safe-area-inset-left, 0px));
    color: #e6edf8;
    border-bottom: 1px solid #24334b;
    font-size: .95rem;
    font-weight: 750;
  }
  .towerd-home-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 84px;
    min-height: 44px;
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    touch-action: manipulation;
  }
  .towerd-home-button span { font-size: 1.5rem; line-height: 1; }
  .towerd-home-button:hover, .towerd-home-button:focus-visible { color: #fff; background: #24334b; }
  #game.towerd-game-frame {
    display: flex;
    flex: 1 1 0;
    min-height: 0;
    align-items: center;
    justify-content: center;
    padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    background: #0c1425;
  }
  #game .game-container { flex: 0 0 auto; border: 0; border-radius: 0; box-shadow: none; }
}
