@font-face {
  font-family: "Pangolin";
  src: url("assets/fonts/Pangolin.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-family: "Pangolin", sans-serif;
}

body {
  margin: 0;
  font-family: "Pangolin", sans-serif;
  background: #ffffff;
  color: #17334a;
}

button,
input,
textarea,
select {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

.page {
  min-height: 100vh;
  width: 100%;
  background: white;
}

.home-page {
  display: block;
}

.welcome-background {
  display: block;
  width: 100%;
  height: auto;
}

.home-content {
  max-width: 900px;
  margin: 35px auto 70px;
  padding: 20px;
  text-align: center;
  font-size: 1.2rem;
  line-height: 1.7;
}

.next-caption {
  font-weight: bold;
  margin: 24px 0 8px;
}

.image-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  width: 100px;
  height: 90px;
}

.image-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.how-page {
  min-height: 100vh;
}

.how-content {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
}

.how-text {
  padding: 55px 7%;
  line-height: 1.6;
}

.how-text h1 {
  font-size: 2.5rem;
  color: #126a9b;
}

.how-text h2 {
  color: #126a9b;
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.waves-side {
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.waves-side img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.game-page {
  min-height: calc(100vh - 54px);
  padding: 10px clamp(8px, 1.2vw, 18px);
  background: #f7fbff;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  max-width: 1600px;
  margin: auto;
}

.game-header h1 {
  color: #126a9b;
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.game-stats {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 0.88rem;
}

.game-stats span {
  padding: 5px 8px;
  border: 1px solid #d5e8f2;
  border-radius: 6px;
  background: white;
  white-space: nowrap;
}

.game-controls {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  max-width: 1600px;
  margin: 8px auto;
}

.game-button {
  border: 0;
  border-radius: 7px;
  background: #167bb0;
  color: white;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: bold;
}

.game-button:hover {
  background: #105d87;
}

.game-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.start-button {
  background: #17844a;
}

.start-button:hover {
  background: #116638;
}

.exit-button {
  background: #526d80;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(275px, 24vw, 340px);
  gap: 10px;
  max-width: 1600px;
  margin: auto;
  align-items: start;
}

.game-main {
  position: relative;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 2px solid #b8d7e8;
  border-radius: 8px;
  background: #d9eff8;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
}

.boss-health-panel {
  position: absolute;
  z-index: 3;
  top: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: auto minmax(60px, 1fr) auto;
  gap: 7px;
  align-items: center;
  width: min(340px, 46%);
  padding: 7px 9px;
  border: 2px solid #8e2929;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: #6c1d1d;
  font-size: 0.8rem;
}

.boss-health-panel progress {
  width: 100%;
  height: 13px;
  accent-color: #c43131;
}

.tip-overlay {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 85%;
  padding: 9px 15px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #17435d;
  font-size: 0.9rem;
  font-weight: bold;
  text-align: center;
  pointer-events: none;
}

.tower-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 6px;
  min-width: 0;
  padding: 9px;
  border: 1px solid #c5dce9;
  border-radius: 8px;
  background: white;
}

.tower-panel h2 {
  grid-column: 1 / -1;
  margin: 0;
  color: #126a9b;
}

.panel-instruction {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.25;
}

.tower-option {
  width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 5px;
  align-items: center;
  min-width: 0;
  min-height: 60px;
  padding: 5px;
  margin: 0;
  border: 2px solid #d6e5ee;
  border-radius: 7px;
  background: #f8fcff;
  color: #17334a;
  text-align: left;
  cursor: pointer;
  font-size: 0.72rem;
  line-height: 1.2;
}

.tower-option.selected {
  border-color: #1682ba;
  background: #eaf7ff;
}

.tower-option img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.tower-option .tower-three-icon {
  transform: rotate(90deg);
}

.tower-info {
  grid-column: 1 / -1;
  min-height: 0;
  margin-top: 0;
  padding: 6px;
  background: #eef7fc;
  border-radius: 6px;
  font-size: 0.74rem;
  line-height: 1.25;
}

.game-message {
  grid-column: 1 / -1;
  min-height: 0;
  margin-top: 0;
  color: #126a9b;
  font-weight: bold;
  font-size: 0.76rem;
}

.end-panel {
  max-width: 700px;
  margin: 30px auto;
  padding: 25px;
  background: white;
  border: 2px solid #c5dce9;
  border-radius: 10px;
}

.end-panel h2,
.end-panel h3 {
  color: #126a9b;
}

.end-panel input,
.end-panel textarea {
  display: block;
  width: 100%;
  padding: 11px;
  margin: 10px 0;
  border: 1px solid #a9c6d8;
  border-radius: 6px;
  font: inherit;
}

.end-panel textarea {
  min-height: 100px;
  resize: vertical;
}

.standard-page {
  padding: 45px 7%;
  color: #17334a;
}

.standard-page h1 {
  color: #126a9b;
  font-size: 2.4rem;
}

.bibliography-image {
  display: block;
  width: min(100%, 300px);
  height: auto;
  margin: 24px auto;
}

.leaderboard-table {
  max-width: 800px;
  margin: 30px 0;
  padding: 20px;
  background: #f4faff;
  border-radius: 8px;
}

.leaderboard-heading,
.leaderboard-entry {
  display: grid;
  grid-template-columns: 1fr 80px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 5px;
}

.leaderboard-heading {
  font-weight: bold;
  border-bottom: 2px solid #9bbdce;
}

.dotted-separator {
  height: 5px;
  border-top: 2px dotted #7195a8;
}

.leaderboard-entry {
  border-bottom: 1px solid #d8e7ef;
}

.information-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 35px;
  max-width: 1100px;
  margin: 35px 0;
  align-items: center;
  line-height: 1.7;
}

.information-grid img {
  width: 100%;
  max-width: 435px;
  justify-self: center;
}

.information-grid h2 {
  color: #126a9b;
}

.site-notification {
  position: fixed;
  z-index: 1000;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  width: min(480px, calc(100% - 30px));
  padding: 16px;
  background: white;
  border: 2px solid #167bb0;
  border-radius: 9px;
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
  color: #17334a;
  text-align: center;
}

.notification-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.notification-actions button {
  padding: 8px 14px;
  border: 0;
  border-radius: 5px;
  background: #167bb0;
  color: white;
  cursor: pointer;
}

@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .tower-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .tower-panel h2,
  .panel-instruction,
  .tower-info,
  .game-message {
    grid-column: 1 / -1;
  }

  .how-content {
    grid-template-columns: 1fr;
  }

  .waves-side {
    height: 55vh;
  }
}

@media (max-width: 600px) {
  .game-stats {
    gap: 10px;
    font-size: 0.85rem;
  }

  .tower-panel {
    display: block;
  }

  .information-grid {
    grid-template-columns: 1fr;
  }

  .leaderboard-heading,
  .leaderboard-entry {
    grid-template-columns: 1fr 30px 1fr;
  }
}
.page-navigation {
  position: sticky;
  top: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  height: 54px;
  padding: 5px 18px;
  background: #ffffff;
  border-bottom: 2px solid #d5e8f2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.page-navigation label {
  font-weight: bold;
  color: #126a9b;
}

.page-navigation select {
  padding: 6px 12px;
  border: 2px solid #167bb0;
  border-radius: 6px;
  background: white;
  color: #17334a;
  font-size: 0.9rem;
  cursor: pointer;
}

.page-navigation select:focus {
  outline: 2px solid #8bc9e8;
}

.upgrade-panel {
  grid-column: 1 / -1;
  min-width: 0;
  margin-top: 0;
  padding: 7px;
  background: #eef7fc;
  border: 1px solid #c5dce9;
  border-radius: 7px;
}

.upgrade-panel h3 {
  color: #126a9b;
  margin: 0 0 5px;
}

.upgrade-progress {
  display: grid;
  gap: 4px;
  margin: 0 0 6px;
  padding: 0;
  list-style: none;
}

.upgrade-step {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 5px;
  align-items: center;
  padding: 4px 5px;
  border: 1px solid #c5dce9;
  border-radius: 6px;
  background: #f8fcff;
  color: #526d80;
  font-size: 0.7rem;
  line-height: 1.2;
}

.upgrade-step.is-next {
  border-color: #1682ba;
  background: #eaf7ff;
  color: #17334a;
}

.upgrade-step.is-complete {
  border-color: #9ac9ac;
  background: #effaf2;
  color: #245c39;
}

.upgrade-step-marker {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background: #dce8ee;
  font-weight: bold;
}

.upgrade-step.is-next .upgrade-step-marker {
  background: #1682ba;
  color: white;
}

.upgrade-step.is-complete .upgrade-step-marker {
  background: #328b53;
  color: white;
}

.upgrade-step-status {
  font-size: 0.66rem;
  font-weight: bold;
  white-space: nowrap;
}

.upgrade-panel p {
  margin: 5px 0;
  font-size: 0.72rem;
  line-height: 1.25;
}

.upgrade-panel .game-button {
  padding: 6px 10px;
  font-size: 0.78rem;
}

.upgrade-panel button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
