/* General Styles & Variables */
:root {
  --bg-color: #20242b;
  --primary-color: #3a414d;
  --secondary-color: #8b9bb4;
  --accent-color: #ffc800;
  --text-color: #ffffff;
  --success-color: #4caf50;
  --fail-color: #f44336;
  --disabled-color: #555;
  --path-color: #00e5ff;
  --font-pixel: "Press Start 2P", cursive;
}

/* Mobile First Base Styles */
html {
  font-size: 14px;
}

body {
  /* background-color: var(--bg-color); */
  background: url("../assets/pikalink-animated-bg.gif") no-repeat right;
  background-size: cover;
  color: var(--text-color);
  font-family: var(--font-pixel);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  user-select: none;
  image-rendering: pixelated;
}

.game-container {
  width: 100vw;
  height: 100vh;
  /* background-color: var(--primary-color); */
  border: none;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  padding: 10px;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

/* Scene Management */
.scene {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.scene.active {
  display: flex;
}

h1,
h2 {
  text-shadow: 2px 2px #000;
  text-align: center;
}
h1 {
  font-size: 2rem;
}
h2 {
  font-size: 1.5rem;
}

/* Pixelated Button Style */
.pixel-btn {
  font-family: var(--font-pixel);
  background: #4a5463;
  color: var(--text-color);
  border: 2px solid var(--secondary-color);
  padding: 8px 12px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 4px 4px 0px #000;
  transition: all 0.1s ease-in-out;
  position: relative;
  font-size: 1rem;
}

.pixel-btn:hover {
  background: #5a6473;
}

.pixel-btn:active {
  box-shadow: 1px 1px 0px #000;
  transform: translate(3px, 3px);
}

.pixel-btn.primary {
  background: var(--accent-color);
  color: #000;
}
.pixel-btn.primary:hover {
  background: #ffdb4d;
}
.pixel-btn.secondary {
  background: var(--success-color);
}
.pixel-btn.secondary:hover {
  background: #5cb85c;
}
.pixel-btn.path {
  background: var(--path-color);
  color: #000;
}
.pixel-btn.path:hover {
  background: #00e5ff;
}
.pixel-btn:disabled {
  background: var(--disabled-color);
  color: #999;
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

#claim-normal-rookie-btn,
#claim-x2-rookie-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

#claim-x2-rookie-btn {
  background-color: var(--path-color);
}

/* Login Scene */
#login-scene h1 {
  font-size: 2.5rem;
  color: var(--accent-color);
  margin-bottom: 50px;
}

/* Lobby Scene */
#lobby-scene {
  /* padding-top: 100px; */
  justify-content: flex-start;
}
.resource-bar {
  width: 100%;
  display: flex;
  flex-direction: column;
  row-gap: 20px;
  /* justify-content: space-between; */
  align-items: center;
  padding: 10px;
  background: #111;
  border-bottom: 2px solid var(--secondary-color);
  margin-bottom: 15px;
  box-sizing: border-box;
}
.coin-display {
  font-size: 1.1rem;
}
.lobby-actions {
  display: flex;
  justify-content: space-between;
  align-self: stretch;
  gap: 10px;
}

#level-select-container {
  width: 100%;
  flex-grow: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
  gap: 10px;
  padding: 10px;
  /* background: #181c22; */
  /* border: 2px solid var(--secondary-color); */
}

.level-button {
  aspect-ratio: 1/1;
  /* background: #4a5463; */
  background: #cdad2f;
  border: 2px solid var(--secondary-color);
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: background 0.2s;
  position: relative;
}
.level-button.locked {
  /* background: #333; */
  background: #867115;
  color: #ffffff;
  font-weight: bold;
  cursor: not-allowed;
}
.level-button.unlocked:hover {
  background: #5a6473;
}
.level-button span {
  font-size: 1.2rem;
}
.level-stars {
  margin-top: 5px;
  font-size: 1.3rem;
  /* color: var(--accent-color); */
  color: #000;
  height: 12px;
}

#game-coin-display {
  color: white;
  text-shadow: 2px 2px #000;
}

#game-scene {
  /* padding-top: 100px; */
}
/* Game Scene */
.game-header {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 0 5px 10px 5px;
  gap: 10px;
}
#countdown-bar-container {
  flex-grow: 1;
  height: 20px;
  background-color: #111;
  border: 2px solid var(--secondary-color);
  min-width: 150px;
}
#countdown-bar {
  height: 100%;
  width: 100%;
  background-color: var(--success-color);
  transition: width 1s linear, background-color 0.5s;
}

#shuffle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

#game-board-container {
  width: 100%;
  flex-grow: 1;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 10px;
}

#game-board {
  display: grid;
  gap: 4px;
  padding: 5px;
  background: #181c22aa;
  /* border: 2px solid var(--secondary-color); */
  box-sizing: border-box;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  /* scale: 1.5; */
}
#path-canvas {
  position: absolute;
  pointer-events: none;
}
.tile {
  /* background-color: var(--primary-color); */
  background: #ffffffdd;
  border: 6px solid transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.tile.selected {
  border-color: var(--success-color);
  border-width: 6px;
  box-sizing: border-box;
}

.tile.hidden {
  background: var(--secondary-color);
  cursor: default;
  border: transparent;
}

.tile.hidden img {
  opacity: 0;
}

/* Modals */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 10px;
  box-sizing: border-box;
}
.modal.active {
  display: flex;
}
.modal-content {
  background: var(--primary-color);
  padding: 20px;
  border: 4px solid var(--secondary-color);
  box-shadow: 8px 8px 0px #000;
  text-align: center;
  width: 90%;
  max-width: 400px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-body {
  overflow-y: auto;
  margin-bottom: 15px;
}

.modal-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 15px;
}
.modal-content h2 {
  margin-top: 0;
}

/* Shop Modal */
#shop-item-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  text-align: left;
}
.shop-item {
  background: #181c22;
  border: 2px solid var(--secondary-color);
  padding: 10px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}
.theme-info h3 {
  margin: 0 0 5px 0;
  font-size: 1rem;
}
.theme-preview {
  display: flex;
  gap: 5px;
  margin-top: 10px;
  justify-content: center;
}
.theme-preview img {
  border: 2px solid var(--secondary-color);
  border-radius: 4px;
  transition: transform 0.2s ease;
}
.theme-preview img:hover {
  transform: scale(1.1);
}
.theme-action .pixel-btn {
  padding: 8px 12px;
  font-size: 0.8rem;
}

/* Other Modals */
#daily-checkin-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.calendar-day {
  background: #2a3038;
  border: 2px solid var(--secondary-color);
  aspect-ratio: 1/1;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.8rem;
  position: relative;
}
.calendar-day.past {
  background: #222;
  color: #666;
}
.calendar-day.today {
  border-color: var(--accent-color);
  cursor: pointer;
}
.calendar-day.checked::after {
  content: "✔";
  color: var(--success-color);
  font-size: 1.5rem;
  position: absolute;
  text-shadow: 1px 1px #000;
}
#leaderboard-list {
  list-style: none;
  padding: 10px;
  text-align: left;
  background: #181c22;
}
#leaderboard-list li {
  padding: 5px;
  display: flex;
  justify-content: space-between;
}
#leaderboard-list li:nth-child(odd) {
  background: #2a3038;
}
.result-stars {
  font-size: 2.5rem;
  margin: 10px 0;
  color: var(--accent-color);
}
.result-coins {
  font-size: 1.2rem;
  margin: 10px 0;
  color: var(--success-color);
}

/* Loading Modal */
#loading-modal {
  z-index: 1000;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--secondary-color);
  border-top: 4px solid var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

#loading-message {
  margin-top: 15px;
  font-size: 0.9rem;
  color: var(--secondary-color);
}

/* Coming Soon Tag */
.coming-soon-tag {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: var(--accent-color);
  color: white;
  font-size: 8px;
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: bold;
  text-transform: uppercase;
}

#leaderboard-btn {
  position: relative;
  opacity: 0.6;
  pointer-events: none;
}

/* Larger screens */
@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
  .game-container {
    width: 100%;
    max-width: 800px;
    height: 95vh;
    max-height: 700px;
    border: 4px solid var(--secondary-color);
  }
}
