@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

html {
  font-size: 130%;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Press Start 2P", monospace;
  background-color: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  touch-action: pan-y;
  user-select: none;
}

/* --- Header --- */

.game-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background-color: #16213e;
  border-bottom: 4px solid #0f3460;
}

.game-header .nav-link {
  font-size: 0.55rem;
  color: #7a7aaf;
  text-decoration: none;
}

.game-header .nav-link:hover {
  color: #e94560;
}

.game-title {
  font-size: 1rem;
  color: #e94560;
  text-shadow: 2px 2px 0 #0f3460;
}

/* --- Music controls --- */

.music-credit {
  font-size: 0.45rem;
  color: #6a6a8a;
  text-align: center;
}

.music-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mute-button {
  background: none;
  border: 1px solid #0f3460;
  border-radius: 4px;
  color: #7a7aaf;
  font-size: 0.6rem;
  cursor: pointer;
  padding: 4px 8px;
  font-family: inherit;
  line-height: 1;
}

.mute-button:hover {
  color: #e94560;
  border-color: #e94560;
}

.mute-button.muted {
  color: #4a4a6a;
  text-decoration: line-through;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 60px;
  height: 4px;
  background: #0f3460;
  border-radius: 2px;
  outline: none;
  width: 50%;
  min-width: 159px;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #7a7aaf;
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #7a7aaf;
  cursor: pointer;
  border: none;
}

.auth-info {
  font-size: 0.55rem;
  color: #7a7aaf;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-bottom: 10px;
}

.auth-info a {
  color: #e94560;
  text-decoration: none;
}

.auth-why {
  font-size: 0.45rem;
  color: #7a7aaf;
  cursor: pointer;
  text-decoration: underline;
  padding-bottom: 20px;
}

.auth-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

/* --- Popup --- */

.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.popup-box {
  background: #16213e;
  border: 2px solid #0f3460;
  border-radius: 8px;
  padding: 24px;
  max-width: 400px;
  text-align: center;
}

.popup-title {
  color: #e94560;
  font-size: 0.8rem;
  font-weight: bold;
}

.popup-hr {
  border: none;
  border-top: 1px solid #0f3460;
  margin: 10px 0;
}

.popup-message {
  color: #e0e0ff;
  font-size: 0.6rem;
  margin-bottom: 16px;
  line-height: 1.4;
}

.popup-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.popup-btn {
  background: #0f3460;
  color: #e0e0ff;
  border: 1px solid #7a7aaf;
  border-radius: 4px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.6rem;
  cursor: pointer;
}

.popup-btn:hover {
  background: #e94560;
  border-color: #e94560;
  color: #fff;
}

/* --- Main area --- */

.game-container {
  width: 100%;
  max-width: 600px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.game-goal {
  font-size: 0.4rem;
  color: #6a6a8a;
  text-align: center;
  line-height: 1.8;
}

.game-help {
  font-size: 0.35rem;
  color: #4a4a6a;
  text-align: center;
  line-height: 2;
  max-width: 600px;
  padding: 20px;
}

/* --- Counter --- */

.counter-section {
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
  width: 100%;
  background-color: #1a1a2e;
  padding: 8px 0;
  border-top: 2px solid #0f3460;
  border-bottom: 2px solid #0f3460;
}

.message-count {
  font-size: 1.7rem;
  color: #e94560;
  text-shadow: 2px 2px 0 #0f3460;
}

.message-count-short {
  font-size: 0.5rem;
  color: #e94560;
  opacity: 0.7;
  margin-top: 2px;
}

.messages-label {
  font-size: 0.6rem;
  color: #7a7aaf;
  margin-top: 8px;
}

.mps-display {
  font-size: 0.55rem;
  color: #53a653;
  margin-top: 6px;
}

.mpc-display {
  font-size: 0.45rem;
  color: #ffb86c;
  margin-top: 4px;
}

/* --- Cheese / Prestige --- */

.cheese-display {
  font-size: 0.45rem;
  color: #f1c40f;
  margin-top: 6px;
}

.prestige-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.prestige-next {
  font-size: 0.35rem;
  color: #8a7a3a;
  text-align: center;
}

.prestige-button {
  padding: 14px 28px;
  background-color: #1a1a2e;
  color: #f1c40f;
  border: 2px solid #f1c40f;
  border-radius: 6px;
  font-family: "Press Start 2P", monospace;
  font-size: 0.55rem;
  cursor: pointer;
  transition:
    background-color 0.15s,
    box-shadow 0.15s;
  animation: prestige-pulse 2s ease-in-out infinite;
}

.prestige-button:hover {
  background-color: #2a2517;
  box-shadow: 0 0 12px #f1c40f66;
}

@keyframes prestige-pulse {
  0%,
  100% {
    box-shadow: 0 0 10px #f1c40f33;
  }
  50% {
    box-shadow: 0 0 20px #f1c40f66;
  }
}

/* --- Cheese shop --- */

.cheese-title {
  color: #f1c40f !important;
  text-shadow: 1px 1px 0 #5a4500 !important;
}

.upgrade-card.cheese-card .upgrade-cost {
  color: #f1c40f;
}

.upgrade-card.cheese-card .upgrade-owned {
  color: #f1c40f;
}

.upgrade-card.cheese-affordable {
  border-color: #f1c40f;
}

.upgrade-card.cheese-affordable:hover {
  border-color: #f5d442;
  background-color: #2a2517;
}

/* --- Click area (Discord-like input bar) --- */

.click-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.message-box {
  width: 100%;
  padding: 12px 16px;
  background-color: #383a40;
  border-radius: 8px;
  border: 2px solid #4a4a6a;
}

.message-text {
  display: block;
  font-family: "Press Start 2P", monospace;
  font-size: 0.5rem;
  color: #bbbbbb;
  line-height: 1.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}

.message-channel {
  display: block;
  font-family: "Press Start 2P", monospace;
  font-size: 0.35rem;
  color: #8a8a9a;
  margin-top: 6px;
  user-select: none;
}

.send-button {
  width: 60%;
  padding: 30px;
  background-color: #5865f2;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 0.7rem;
  cursor: pointer;
  transition: background-color 0.1s;
  user-select: none;
}

.send-button:hover {
  background-color: #4752c4;
}

.send-button:active {
  background-color: #3c45a5;
  transform: scale(0.96);
}

/* --- Upgrades --- */

.upgrades-section {
  width: 100%;
}

.upgrades-title {
  font-size: 0.7rem;
  color: #e94560;
  margin-bottom: 12px;
  text-shadow: 1px 1px 0 #0f3460;
}

.upgrades-subtitle {
  font-size: 0.4rem;
  color: #6a6a8a;
  text-shadow: none;
}

.upgrades-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upgrade-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background-color: #16213e;
  border: 2px solid #0f3460;
  border-radius: 4px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    opacity 0.15s;
  user-select: none;
}

.upgrade-card:hover {
  border-color: #5865f2;
}

.upgrade-card.affordable {
  border-color: #53a653;
}

.upgrade-card.affordable:hover {
  border-color: #6fcf6f;
  background-color: #1a2a4e;
}

.upgrade-card.unaffordable {
  opacity: 0.5;
  cursor: default;
}

.upgrade-card.unaffordable:hover {
  border-color: #0f3460;
}

.upgrade-card.purchased {
  opacity: 1;
  border-color: #53a653;
  background-color: #162e1a;
  cursor: default;
}

.upgrade-card.purchased .upgrade-name {
  color: #53a653;
}

.upgrade-card.purchased .upgrade-owned {
  color: #53a653;
  font-size: 0.6rem;
}

.upgrade-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.upgrade-name {
  font-size: 0.65rem;
  color: #e0e0e0;
}

.upgrade-rate {
  font-size: 0.45rem;
  color: #53a653;
}

.upgrade-desc {
  font-size: 0.45rem;
  color: #6a6a8a;
  line-height: 1.8;
  margin-top: 2px;
}

.upgrade-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
  margin-left: 12px;
}

.upgrade-cost {
  font-size: 0.6rem;
  color: #e94560;
}

.upgrade-owned {
  font-size: 0.7rem;
  color: #ffb86c;
}

/* --- Achievement log --- */

.upgrade-card.achievement-unlocked {
  border-color: #f1c40f;
  background-color: #2a2517;
  cursor: default;
}

.upgrade-card.achievement-unlocked .achievement-log-name {
  color: #f1c40f;
}

.upgrade-card.achievement-unlocked .achievement-log-condition {
  color: #f1c40f;
  font-size: 0.35rem;
}

.upgrade-card.achievement-locked {
  opacity: 0.4;
  cursor: default;
}

.upgrade-card.achievement-locked:hover {
  border-color: #0f3460;
}

/* --- Mystery upgrade --- */

.upgrade-mystery {
  padding: 12px 14px;
  background-color: #16213e;
  border: 2px dashed #0f3460;
  border-radius: 4px;
  text-align: center;
  font-size: 0.6rem;
  color: #4a4a6a;
  user-select: none;
}

/* --- Click ping --- */

.click-ping {
  position: fixed;
  background-color: #ed4245;
  color: #fff;
  font-family: "Press Start 2P", monospace;
  font-size: 0.45rem;
  padding: 4px 8px;
  border-radius: 10px;
  pointer-events: none;
  animation: ping-float 1.5s linear forwards;
  z-index: 100;
}

@keyframes ping-float {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-100px);
  }
}

/* --- Achievement popup --- */

.achievement-container {
  position: fixed;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  max-width: 280px;
}

.achievement-popup {
  background-color: #16213e;
  border: 2px solid #f1c40f;
  border-radius: 6px;
  padding: 12px 16px;
  font-family: "Press Start 2P", monospace;
  animation: achievement-slide 5s ease-in-out forwards;
}

.achievement-title {
  font-size: 0.6rem;
  color: #f1c40f;
  margin-bottom: 6px;
}

.achievement-name {
  font-size: 0.6rem;
  color: #e0e0e0;
  margin-bottom: 4px;
}

.achievement-desc {
  font-size: 0.4rem;
  color: #6a6a8a;
  line-height: 1.8;
}

.achievement-condition {
  font-size: 0.35rem;
  color: #f1c40f;
  margin-top: 6px;
  line-height: 1.8;
}

@keyframes achievement-slide {
  0% {
    transform: translateX(120%);
    opacity: 0;
  }
  15% {
    transform: translateX(0);
    opacity: 1;
  }
  75% {
    transform: translateX(0);
    opacity: 1;
  }
  100% {
    transform: translateX(120%);
    opacity: 0;
  }
}

/* --- Reset button --- */

.reset-button {
  font-family: "Press Start 2P", monospace;
  font-size: 0.4rem;
  color: #4a4a6a;
  cursor: pointer;
  user-select: none;
  text-align: right;
  padding: 20px;
  width: 100%;
  max-width: 600px;
}

.reset-button:hover {
  color: #e94560;
}

/* --- Leaderboard --- */

.leaderboard-container {
  width: 100%;
  max-width: 800px;
  padding: 20px;
  margin: 0 auto;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.45rem;
}

.leaderboard-table th {
  color: #e94560;
  text-align: left;
  padding: 10px 8px;
  border-bottom: 2px solid #0f3460;
}

.leaderboard-table td {
  padding: 8px;
  border-bottom: 1px solid #0f3460;
  vertical-align: middle;
}

.leaderboard-table tr:hover td {
  background-color: #16213e;
}

.lb-rank {
  color: #f1c40f;
  font-size: 0.55rem;
  width: 30px;
}

.lb-player {
  display: flex;
  align-items: center;
  gap: 3px;
}

.lb-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
}

.lb-avatar-placeholder {
  background-color: #0f3460;
}

.lb-username {
  color: #e0e0e0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-messages {
  color: #e94560;
  font-size: 90%;
}

.lb-mps {
  color: #53a653;
}

.lb-cheese {
  color: #f1c40f;
  font-size: 90%;
}

.lb-achievement {
  color: #7a7aaf;
}

.lb-loading {
  text-align: center;
  color: #7a7aaf;
  padding: 40px 8px !important;
}

.leaderboard-link {
  font-size: 0.4rem;
  color: #7a7aaf;
  text-decoration: none;
}

.leaderboard-link:hover {
  color: #e94560;
}

/* --- Responsive --- */

@media (max-width: 600px) {
  html {
    font-size: 100%;
  }
  .game-header .nav-link {
    font-size: 0.4rem;
  }

  .game-title {
    font-size: 0.6rem;
  }

  .achievement-container {
    top: auto;
    bottom: 10px;
    flex-direction: column-reverse;
  }

  .leaderboard-container {
    padding: 20px 0px;
  }

  .lb-username {
    max-width: 90px;
  }

  .lb-hide-mobile {
    display: none;
  }

  .lb-achievement {
    max-width: 80px;
    word-break: break-word;
  }
}
