* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

.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 {
  padding: 18px;
  background: #f7fbff;
}

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

.game-header h1 {
  color: #126a9b;
  margin: 8px 0;
}

.game-stats {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  font-size: 1rem;
}

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

.game-button {
  border: 0;
  border-radius: 7px;
  background: #167bb0;
  color: white;
  padding: 11px 18px;
  cursor: pointer;
  font-size: 0.95rem;
  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) 285px;
  gap: 16px;
  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;
}

.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 {
  padding: 16px;
  border: 1px solid #c5dce9;
  border-radius: 8px;
  background: white;
}

.tower-panel h2 {
  margin-top: 0;
  color: #126a9b;
}

.panel-instruction {
  font-size: 0.88rem;
  line-height: 1.4;
}

.tower-option {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  margin: 10px 0;
  border: 2px solid #d6e5ee;
  border-radius: 7px;
  background: #f8fcff;
  color: #17334a;
  text-align: left;
  cursor: pointer;
  line-height: 1.4;
}

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

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

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

.tower-info {
  min-height: 55px;
  margin-top: 12px;
  padding: 10px;
  background: #eef7fc;
  border-radius: 6px;
  font-size: 0.88rem;
  line-height: 1.4;
}

.game-message {
  min-height: 35px;
  margin-top: 10px;
  color: #126a9b;
  font-weight: bold;
  font-size: 0.9rem;
}

.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;
}

.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;
  padding: 12px 25px;
  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: 9px 14px;
  border: 2px solid #167bb0;
  border-radius: 6px;
  background: white;
  color: #17334a;
  font-size: 1rem;
  cursor: pointer;
}

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

.upgrade-panel {
  margin-top: 15px;
  padding: 12px;
  background: #eef7fc;
  border: 1px solid #c5dce9;
  border-radius: 7px;
}

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

.upgrade-panel p {
  font-size: 0.9rem;
  line-height: 1.5;
}

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