body {
  margin: 0;
  min-height: 100vh;

  color: #eee;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-image: url("../../images/minecraft-rainy-cabin.gif");

  overflow-x: hidden;

  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  display: flex;
  justify-content: center;
  align-items: center;
}

/* Title */
h1 {
  margin: 8px 0 16px;
  font-size: 20px;
  text-align: center;
}

#side-left {
  display: flex;
  flex-direction: column;
  gap: 12px;           /* space between Hold & Next */
  align-items: center; /* center them vertically under each other */
}

/* Game container */
#tetris-wrap {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr auto 1fr;
  align-items: flex-start;
  padding: 10px 10px;
  border-radius: 15px;
  position: relative;
  width: fit-content;

  overflow: hidden;
  border: 1px solid rgba(124, 158, 255, .12);

  background: rgba(0, 0, 0, 0.25); /* dark glass effect */
  backdrop-filter: blur(6px);

  box-shadow: 0 6px 20px rgba(0, 0, 0, 1.0), 0 24px 70px rgba(0, 0, 0, .38);
}

#tetris-wrap::after {
  content: "";
  position: absolute;
  inset: 10px;
  pointer-events: none;
  border-radius: 10px;
  background: linear-gradient(
    rgba(255, 255, 255, .035) 50%,
    rgba(0, 0, 0, .035) 50%
  );
  background-size: 100% 4px;
  mix-blend-mode: screen;
  opacity: .20;
}

/* Canvas styling */
#tetris-canvas {
  border: 2px solid #555;
  display: block;
  background: #000;
  image-rendering: auto;
  grid-column: 2;
}

/* Info panel */
#tetris-info {
  font-size: 14px;
  line-height: 1.5;
  max-width: 300px;
  grid-column: 3;
}

.score {
  margin: 4px 0 12px;
  font-size: 16px;
  font-weight: 600;
}

.score.small {
  font-size: 13px;
  color: #ccc;
}

.preview-block {
  background: #191919;
  border-radius: 6px;
  padding: 6px;
  border: 1px solid #333;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #aaa;
  margin-bottom: 4px;
}

#hold-canvas,
#next-canvas {
  background: #000;
  border-radius: 4px;
  image-rendering: pixelated;
}

/* List styling */
#tetris-info ul {
  padding-left: 18px;
  margin: 6px 0 0;
}

.hint {
  margin-top: 6px;
  font-size: 12px;
  color: #bbb;
}

.game-over {
  color: #ff6161;
  font-weight: bold;
  margin-top: 8px;
}

#restart-btn {
  margin-top: 8px;
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  background: #3a86ff;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: none; /* hidden until game over */
}

#restart-btn:hover {
  background: #2563d6;
}

.tetris-layout {
  display: grid;
  grid-template-columns: auto 240px;
  gap: 20px;
  align-items: start;
  justify-content: center;
}

.tetris-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#pause-btn {
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.08);
  color: white;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 800;
}

#home-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  background: #0000007c;
}

#home-btn a {
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-weight: 800;
  border-radius: 999px;
}

.tetris-scoreboard {
  min-height: 320px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(5,7,12,.78);
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
}

.tetris-scoreboard h3 {
  margin: 0 0 14px;
  color: rgba(255,255,255,.72);
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

#tetris-leaderboard {
  margin: 0;
  padding-left: 22px;
  color: white;
}

#tetris-leaderboard li {
  margin-bottom: 10px;
  color: rgba(255,255,255,.75);
}

#tetris-leaderboard strong {
  color: white;
}

.gameover-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(8px);
}

.gameover-modal[hidden] {
  display: none;
}

.gameover-card {
  width: min(360px, calc(100% - 32px));
  padding: 28px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(8,11,20,.96);
  box-shadow: 0 30px 100px rgba(0,0,0,.45);
  text-align: center;
  color: white;
}

.gameover-card h2 {
  margin: 0 0 10px;
  font-size: 34px;
}

#player-name-input {
  width: 100%;
  margin-top: 16px;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.08);
  color: white;
  outline: none;
  font: inherit;
}

.gameover-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.gameover-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.08);
  color: white;
  cursor: pointer;
}

@media (max-width: 760px) {
  .tetris-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .tetris-side {
    width: min(360px, 100%);
  }
}

.level-box {
  text-align: center;
  padding: 18px;
  border-radius: 18px;
}

.level-title {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1;
  color: white;
  text-transform: uppercase;
}

.level-number {
  margin-top: 8px;
  font-size: 18px;
  font-weight: 800;
  color: rgba(255,255,255,.65);
}

.scoreboard-title {
  color: rgba(255,255,255,.6);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

#tetris-leaderboard {
  margin: 0;
  padding-left: 20px;
  color: white;
}

#tetris-leaderboard li {
  margin-bottom: 8px;
  color: rgba(255,255,255,.72);
}

#tetris-leaderboard strong {
  color: white;
}

.global-leaderboard-box {
  margin-top: 24px;
  padding: 22px;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: white;
}

.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.leaderboard-header h2 {
  margin: 0;
  font-size: 28px;
  line-height: .95;
  letter-spacing: -0.05em;
}

#refreshLeaderboardBtn {
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.08);
  color: white;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

#refreshLeaderboardBtn:hover {
  background: rgba(255,255,255,.14);
}

.global-leaderboard {
  margin: 0;
  padding-left: 24px;
}

.global-leaderboard li {
  margin: 10px 0;
  color: rgba(255,255,255,.72);
  font-weight: 750;
}

.global-leaderboard strong {
  color: white;
}

.global-leaderboard .score {
  color: #8bffb0;
  font-weight: 950;
}

.global-leaderboard .meta {
  color: rgba(255,255,255,.45);
  font-size: 13px;
}

.score-submit-box {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(120,185,255,.22);
  background: rgba(120,185,255,.08);
}

.score-submit-box h3 {
  margin: 0 0 8px;
  color: white;
  font-size: 22px;
}

#finalScoreText {
  margin: 0 0 12px;
  color: rgba(255,255,255,.68);
  font-weight: 850;
}

.score-submit-row {
  display: flex;
  gap: 10px;
}

#tetrisUsernameInput {
  min-width: 0;
  flex: 1;

  padding: 12px 13px;
  border-radius: 13px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.18);
  color: white;

  font: inherit;
  font-weight: 800;
  outline: none;
}

#tetrisUsernameInput::placeholder {
  color: rgba(255,255,255,.38);
}

#submitTetrisScoreBtn {
  padding: 12px 14px;
  border-radius: 13px;
  border: 1px solid rgba(139,255,176,.22);
  background: rgba(139,255,176,.12);
  color: white;

  font: inherit;
  font-weight: 950;
  cursor: pointer;
}

#submitTetrisScoreBtn:hover:not(:disabled) {
  background: rgba(139,255,176,.20);
}

#submitTetrisScoreBtn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

#scoreSubmitMessage {
  margin: 10px 0 0;
  color: rgba(255,255,255,.58);
  font-size: 13px;
  font-weight: 850;
}

#scoreSubmitMessage.success {
  color: #8bffb0;
}

#scoreSubmitMessage.error {
  color: #ff8fa5;
}

@media (max-width: 760px) {
  .score-submit-row {
    flex-direction: column;
  }
}