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

body {
  font-family: Arial, sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  background-color: #222;
  --sb-track-color: #232E33;
  --sb-thumb-color: #e95c51;
  --sb-size: 10px;
}

body::-webkit-scrollbar {
  width: var(--sb-size)
}

body::-webkit-scrollbar-track {
  background: var(--sb-track-color);
  border-radius: 5px;
}

body::-webkit-scrollbar-thumb {
  background: var(--sb-thumb-color);
  border-radius: 5px;
  border: 2px solid #232E33;
}

@supports not selector(::-webkit-scrollbar) {
  body {
    scrollbar-color: var(--sb-thumb-color)
                     var(--sb-track-color);
  }
}

/* Screens */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: none;
  overflow: hidden;
}

.screen.active {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* Main Menu Screen */
#mainMenuScreen {
  background-image: url("assets/backgrounds/bg-1-blur-opt.png");
  background-size: cover;
  background-position: center;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.menu-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  /* gap: 2rem; */
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  height: 100%;
  max-height: 435px;
}

.logo {
  margin-top: 4rem;
  max-width: 80%;
}

.logo img {
  width: 190px;
  height: auto;
  object-fit: contain;
}

.menu-main-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  width: 100%;
}

.menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.3s ease;
  width: 100%;
  max-width: 300px;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.menu-btn img {
  width: 100%;
  height: auto;
}

.menu-btn:hover {
  transform: scale(1.05);
}

.menu-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 3rem;
  width: 100%;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.3s ease;
  width: 50px;
  height: 50px;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.icon-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.icon-btn:hover {
  transform: scale(1.1);
}

/* Settings Screen */
#settingsScreen {
  background-image: url("assets/backgrounds/bg-1-blur-opt.png");
  background-size: cover;
  background-position: center;
  width: 100%;
  height: 100%;
}

.settings-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

.settings-panel {
  position: relative;
  width: 90%;
  max-width: 400px;
  height: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.settings-panel-bg {
  width: 100%;
  height: 220px;
}

.settings-title {
  position: absolute;
  top: 4%;
  font-family: "Montserrat", sans-serif;
  font-weight: 900;
  font-size: 34px;
  color: #ffffff;
  text-align: center;
  letter-spacing: 3px;
}

.settings-options {
  position: absolute;
  width: 80%;
  top: 25%;
  height: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.settings-sound-container {
  display: flex;
  gap: 12px;
}

.settings-option {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 5px;
}

.settings-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease;
  width: 60px;
  max-width: 280px;
  position: relative;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.settings-toggle-btn:hover {
  transform: scale(1.05);
}

.settings-toggle-btn img {
  width: 100%;
  height: auto;
}

.settings-toggle-btn .inactive-img {
  display: none;
}

.settings-toggle-btn.active .active-img {
  display: block;
}

.settings-toggle-btn.active .inactive-img {
  display: none;
}

.settings-toggle-btn:not(.active) .active-img {
  display: none;
}

.settings-toggle-btn:not(.active) .inactive-img {
  display: block;
}

.settings-language {
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 10px 0;
}

.language-container {
  position: relative;
  width: 80%;
  height: 57px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.language-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 0;
}

.language-nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 30px;
  height: 30px;
  z-index: 2;
  transition: transform 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: center;
}

.language-nav-btn:hover {
  transform: scale(1.1);
}

.language-nav-btn img {
  width: 100%;
  height: auto;
}

.language-nav-btn.next img {
  transform: rotate(180deg);
}

.current-language {
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 2;
}

#languageIcon {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

#languageName {
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  color: #ffffff;
  font-size: 32px;
}

.settings-help,
.settings-ok {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.settings-help-btn,
.settings-ok-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 70%;
  max-width: 280px;
  transition: transform 0.2s ease;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.settings-help-btn:hover,
.settings-ok-btn:hover {
  transform: scale(1.05);
}

.settings-help-btn img,
.settings-ok-btn img {
  width: 100%;
}

.settings-ok-btn img {
  width: 100px;
}

/* Game Screen */
#gameScreen {
  background-image: url("assets/backgrounds/bg-ingame-withoutlogo-opt.png");
  background-size: cover;
  background-position: center;
}

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 400px;
  height: 100vh;
  padding: 1rem;
}

/* Game Header */
.game-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
}

.score-container,
.next-container {
  position: relative;
  width: 65px;
  max-width: 180px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;

  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.score-bg,
.next-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.score-text {
  position: relative;
  color: #e6e6e3;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: "Montserrat", sans-serif;
  font-size: 12px;
  letter-spacing: 1px;
  font-weight: 600;
}

.score-text #score {
  font-size: 20px;
  font-weight: 900;
  color: white;
  opacity: 1;
}

.next-piece-display {
  position: relative;
  width: 60px;
  height: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-collapse: collapse;
  font-size: 0;
  line-height: 0;
  z-index: 10;
  margin-left: 15px;
  transform: scale(0.8);
  margin-top: 15px;
}

/* Game Board */
.game-board-container {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
}

.board-bg {
  position: absolute;
  top: -8px;
  left: 8px;
  width: 95%;
  height: 100%;
  object-fit: fill;

  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.game-board {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 92%;
  height: 96%;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-collapse: collapse;
  z-index: 5;
  font-size: 0;
  line-height: 0;
}

.cell {
  background-color: transparent;
  width: calc(100% / 10);
  height: calc(100% / 17);
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: none;
  font-size: 0;
  line-height: 0;
  display: block;
}

.cell.filled {
  overflow: hidden;
}

/* Tetrimino Tiles */
.piece-I,
.piece-J,
.piece-L,
.piece-O,
.piece-S,
.piece-T,
.piece-Z {
  background-size: 120% 120%;
  background-position: center;
  background-repeat: no-repeat;
  margin: 0;
  padding: 0;
  border: 1px solid #e6e6e3;
  border-radius: 2px;
}

/* Tetrimino Tiles - Like in the photo */
.piece-I {
  background-image: url("assets/tetromino-assets/I.svg");
}

.piece-J {
  background-image: url("assets/tetromino-assets/J.svg");
}

.piece-L {
  background-image: url("assets/tetromino-assets/L.svg");
}

.piece-O {
  background-image: url("assets/tetromino-assets/O.svg");
}

.piece-S {
  background-image: url("assets/tetromino-assets/S.svg");
}

.piece-T {
  background-image: url("assets/tetromino-assets/T.svg");
}

.piece-Z {
  background-image: url("assets/tetromino-assets/Z.svg");
}

/* Game Controls */
.game-controls {
  width: 94%;
  display: flex;
  justify-content: center;
  /* background-image: url("assets/buttons/yön-tuşları-01.png"); */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  margin-bottom: 2rem;
}

.control-container {
  width: 100%;
  background-color: rgba(68, 68, 68, 0.8);
  padding: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.controls-bg {
  display: none;
}

.control-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  width: 60px;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 5px;
  transition: transform 0.1s ease;
  margin: 0 2px;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.control-btn:active {
  transform: scale(0.9);
}

.control-btn img {
  width: 60px;
  height: 60px;
  object-fit: contain;
}

.control-btn:hover {
  opacity: 0.8;
}

/* Game Over & Pause Screen */
.game-over,
.pause-screen {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.9);
  padding: 2rem;
  border-radius: 10px;
  text-align: center;
  color: white;
  display: none;
  z-index: 100;
  width: 90%;
  max-width: 350px;
}

.game-over.active,
.pause-screen.active {
  display: block;
}

.game-over h2,
.pause-screen h2 {
  margin-bottom: 1.5rem;
  color: white;
  font-size: 1.8rem;
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
}

.game-over p {
  margin-bottom: 1.5rem;
  font-size: 1.2rem;
}

.game-over-buttons,
.pause-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.game-over button,
.pause-screen button {
  background-color: #e63946;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  margin: 5px;
  transition: background-color 0.3s;
}

#resumeButton {
  background-color: transparent;
  border: 2px solid white;
  outline: none;
  outline-offset: 0;
}

.game-over button:hover,
.pause-screen button:hover {
  background-color: #c1121f;
}

/* Improve next piece display */
#nextPiece .cell {
  width: 25%;
  height: 25%;
  margin: 0;
  padding: 0;
  border: none;
}

/* Responsive Design */
@media (max-width: 400px) {
  .level-value,
  .score-value {
    font-size: 1.2rem;
  }

  .level-label,
  .next-label {
    font-size: 0.7rem;
  }

  .next-piece-display {
    height: 50px;
  }

  .game-over,
  .pause-screen {
    padding: 1.5rem;
  }

  .game-over h2,
  .pause-screen h2 {
    font-size: 1.5rem;
  }
}

@media (min-height: 800px) {
  .game-container {
    /* justify-content: center; */
    /* gap: 2rem; */
  }

  .game-board-container {
    max-height: 75%;
  }
}

@media (min-width: 768px) {
  .menu-container {
    max-width: 500px;
  }

  .game-container {
    max-width: 500px;
  }

  .level-container,
  .score-container,
  .next-container {
    padding: 0.75rem;
  }

  .level-value,
  .score-value {
    font-size: 1.8rem;
  }

  .control-btn {
    width: 12%;
  }
}

/* Complete Screen */
#completeScreen {
  background-image: url("assets/backgrounds/bg-1-opt.png");
  background-size: cover;
  background-position: center;
  width: 100%;
  height: 100%;
}

.complete-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 400px;
  /* height: 100%; */
  padding: 3rem;
}

.complete-panel {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 2rem;
}

.complete-panel-bg {
  width: 100%;
  /* height: auto; */
}

.complete-title {
  position: absolute;
  top: 5%;
  font-family: "Montserrat", sans-serif;
  font-weight: 900;
  font-size: 34px;
  color: #ffffff;
  text-align: center;
  letter-spacing: 2px;
}

.stars-container {
  position: absolute;
  top: 25%;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 80%;
}

.star-icon {
  width: 60px;
  height: auto;
  margin: 0 5px;
}

.center-star {
  width: 70px; /* Slightly larger center star */
}

.complete-score-container {
  position: absolute;
  bottom: 4%;
  width: 55%;
  max-width: 250px;
}

.complete-score-bg {
  width: 100%;
  height: auto;
}

.complete-score-text {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  color: white;
  font-family: "Montserrat", sans-serif;
  font-weight: 600;
  text-align: center;
  width: 100%;
}

.complete-score-text span:first-child {
  font-size: 22px;
}

#completeScore {
  font-size: 40px;
  font-weight: 900;
  margin-top: 8px;
}

.replay-button-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

.replay-btn {
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.3s ease;
  width: 100%;
  max-width: 300px;
  font-size: 0; /* Metni gizle, sadece resmi göster */
}

.replay-btn img {
  width: 70%;
  height: auto;
}

.replay-btn:hover {
  transform: scale(1.05);
}

.navigation-buttons {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 20px;
}

.nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.3s ease;
  width: 45%;
  max-width: 180px;
  font-size: 0; /* Metni gizle, sadece resmi göster */
}

.nav-btn img {
  width: 100%;
  height: auto;
}

.nav-btn:hover {
  transform: scale(1.05);
}

.complete-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 2rem;
  width: 100%;
}

@media (max-height: 700px) {
  .complete-container {
    padding: 1rem;
  }

  .star-icon {
    width: 45px;
  }

  .center-star {
    width: 55px;
  }

  .complete-title {
    font-size: 28px;
  }

  #completeScore {
    font-size: 34px;
  }
}

/* Leaderboard Screen */
#leaderboardScreen {
  background-image: url("assets/backgrounds/bg-1-blur-opt.png");
  background-size: cover;
  background-position: center;
  width: 100%;
  height: 100%;
}

.leaderboard-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 500px;
  height: 100%;
  padding: 2rem;
}

.leaderboard-header {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  width: 100%;
  margin-bottom: 1.5rem;
}

.leaderboard-title {
  font-family: "Montserrat", sans-serif;
  font-weight: 900;
  font-size: 32px;
  color: #ffffff;
  text-align: center;
  letter-spacing: 2px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.close-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.leaderboard-content {
  width: 100%;
  height: 75%;
  overflow-y: auto;
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  --sb-track-color: #232E33;
  --sb-thumb-color: #e95c51;
  --sb-size: 8px;
}

.leaderboard-content::-webkit-scrollbar {
  width: var(--sb-size)
}

.leaderboard-content::-webkit-scrollbar-track {
  background: var(--sb-track-color);
  border-radius: 5px;
}

.leaderboard-content::-webkit-scrollbar-thumb {
  background: var(--sb-thumb-color);
  border-radius: 5px;
  border: 2px solid #232E33;
}

@supports not selector(::-webkit-scrollbar) {
  .leaderboard-content {
    scrollbar-color: var(--sb-thumb-color)
                     var(--sb-track-color);
  }
}

.leaderboard-list {
  width: 100%;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  padding: 12px 10px;
  margin-bottom: 10px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  transition: all 0.3s ease;
  border-left: 4px solid transparent;
}

.leaderboard-item:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Style for top 3 players */
.leaderboard-item:nth-child(1) {
  border-left-color: gold;
  background-color: rgba(255, 215, 0, 0.15);
}

.leaderboard-item:nth-child(2) {
  border-left-color: silver;
  background-color: rgba(192, 192, 192, 0.15);
}

.leaderboard-item:nth-child(3) {
  border-left-color: #cd7f32; /* bronze */
  background-color: rgba(205, 127, 50, 0.15);
}

/* Special styling for top 3 ranks */
.leaderboard-item:nth-child(1) .leaderboard-rank {
  color: gold;
}

.leaderboard-item:nth-child(2) .leaderboard-rank {
  color: silver;
}

.leaderboard-item:nth-child(3) .leaderboard-rank {
  color: #cd7f32; /* bronze */
}

.leaderboard-rank {
  flex: 0 0 30px;
  font-family: "Montserrat", sans-serif;
  font-weight: 900;
  font-size: 18px;
  color: #ffffff;
  text-align: center;
}

.leaderboard-avatar {
  flex: 0 0 40px;
  height: 40px;
  border-radius: 50%;
  margin: 0 10px;
  overflow: hidden;
  background-color: #444;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.leaderboard-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.leaderboard-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.leaderboard-name {
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: #ffffff;
  margin-bottom: 2px;
}

.leaderboard-score {
  font-family: "Montserrat", sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: #cccccc;
}

.leaderboard-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

.leaderboard-no-data {
  color: #ffffff;
  text-align: center;
  padding: 20px;
  font-family: "Montserrat", sans-serif;
  font-size: 16px;
  opacity: 0.7;
}

@media (max-height: 700px) {
  .leaderboard-container {
    padding: 1rem;
  }
  
  .leaderboard-title {
    font-size: 28px;
  }
  
  .leaderboard-content {
    height: 70%;
  }
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.spinner {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 5px solid transparent;
  border-top-color: #e63946;
  border-left-color: #e63946;
  animation: spin 1s linear infinite;
}

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

/* Common button styles */
.menu-btn, .icon-btn, .settings-toggle-btn, .settings-help-btn, .settings-ok-btn, .control-btn, .replay-btn, .nav-btn {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Add styles for buttons being dragged */
.dragging {
  pointer-events: none;
}

/* Add touch active state for buttons */
.control-btn:active {
  transform: scale(0.9);
  opacity: 0.8;
}

.menu-btn:active, .icon-btn:active, .settings-toggle-btn:active, 
.settings-help-btn:active, .settings-ok-btn:active, .replay-btn:active, .nav-btn:active {
  transform: scale(0.95);
  opacity: 0.9;
}
