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

body {
  background: #0f0f1a;
  color: #ffffff;
  font-family: 'Press Start 2P', monospace;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.game-container {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  padding: 20px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 160px;
}

.panel {
  background: #1a1a2e;
  border: 2px solid #3a3a5c;
  border-radius: 4px;
  padding: 16px;
  text-align: center;
}

.panel h2 {
  font-size: 10px;
  color: #8888aa;
  margin-bottom: 10px;
  letter-spacing: 2px;
}

.panel p {
  font-size: 18px;
  color: #00f0f0;
  text-shadow: 0 0 10px rgba(0, 240, 240, 0.5);
}

.board-wrapper {
  position: relative;
  line-height: 0;
}

#game-board {
  background: #0a0a14;
  border: 3px solid #3a3a5c;
  border-radius: 2px;
  box-shadow:
    0 0 20px rgba(0, 240, 240, 0.1),
    inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 20, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  border-radius: 2px;
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  text-align: center;
}

.overlay-content h1 {
  font-size: 24px;
  margin-bottom: 20px;
  color: #00f0f0;
  text-shadow: 0 0 20px rgba(0, 240, 240, 0.7);
}

.overlay-content p {
  font-size: 10px;
  color: #8888aa;
  margin-bottom: 10px;
}

#next-piece {
  display: block;
  margin: 0 auto;
  background: #0a0a14;
  border: 2px solid #3a3a5c;
  border-radius: 2px;
}

.controls {
  background: #1a1a2e;
  border: 2px solid #3a3a5c;
  border-radius: 4px;
  padding: 16px;
}

.controls h2 {
  font-size: 10px;
  color: #8888aa;
  margin-bottom: 12px;
  letter-spacing: 2px;
  text-align: center;
}

.controls ul {
  list-style: none;
  font-size: 8px;
  line-height: 2.2;
  color: #666688;
}

.controls kbd {
  display: inline-block;
  background: #2a2a4e;
  border: 1px solid #4a4a6e;
  border-radius: 3px;
  padding: 2px 6px;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #aaaacc;
  margin-right: 4px;
}

/* High Score button */
#btn-highscore {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  background: #2a2a4e;
  color: #00f0f0;
  border: 2px solid #00f0f0;
  border-radius: 4px;
  padding: 10px 14px;
  cursor: pointer;
  text-shadow: 0 0 8px rgba(0, 240, 240, 0.5);
  transition: background 0.2s;
  width: 100%;
}

#btn-highscore:hover {
  background: #3a3a6e;
}

/* Save score form */
#save-score-form {
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#player-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  background: #1a1a2e;
  color: #00f0f0;
  border: 2px solid #3a3a5c;
  border-radius: 4px;
  padding: 8px 12px;
  text-align: center;
  outline: none;
  width: 200px;
}

#player-name:focus {
  border-color: #00f0f0;
  box-shadow: 0 0 10px rgba(0, 240, 240, 0.3);
}

#btn-save-score {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  background: #00f0f0;
  color: #0a0a14;
  border: none;
  border-radius: 4px;
  padding: 8px 20px;
  cursor: pointer;
  transition: background 0.2s;
}

#btn-save-score:hover {
  background: #33ffff;
}

#btn-save-score:disabled {
  background: #3a3a5c;
  color: #666688;
  cursor: not-allowed;
}

#save-status {
  font-size: 8px;
  min-height: 14px;
}

.overlay-content .hint {
  font-size: 8px;
  color: #555577;
  margin-top: 12px;
}

/* High Score Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 20, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #1a1a2e;
  border: 2px solid #3a3a5c;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content h2 {
  font-size: 14px;
  color: #00f0f0;
  margin-bottom: 20px;
  text-shadow: 0 0 15px rgba(0, 240, 240, 0.5);
  letter-spacing: 2px;
}

#highscore-list {
  font-size: 9px;
  color: #8888aa;
  margin-bottom: 20px;
}

#highscore-list table {
  width: 100%;
  border-collapse: collapse;
}

#highscore-list th {
  font-size: 8px;
  color: #555577;
  padding: 6px 4px;
  border-bottom: 1px solid #3a3a5c;
  text-align: left;
}

#highscore-list td {
  padding: 8px 4px;
  border-bottom: 1px solid #2a2a4e;
  text-align: left;
}

#highscore-list tr:nth-child(-n+3) td:first-child {
  color: #f0f000;
}

#highscore-list .score-val {
  color: #00f0f0;
  text-align: right;
}

#highscore-list .score-date {
  color: #555577;
  font-size: 7px;
}

#btn-close-modal {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  background: #2a2a4e;
  color: #8888aa;
  border: 2px solid #3a3a5c;
  border-radius: 4px;
  padding: 8px 20px;
  cursor: pointer;
  transition: background 0.2s;
}

#btn-close-modal:hover {
  background: #3a3a6e;
  color: #ffffff;
}

@media (max-width: 700px) {
  .game-container {
    flex-direction: column;
    align-items: center;
  }

  .sidebar {
    flex-direction: row;
    min-width: auto;
    flex-wrap: wrap;
    justify-content: center;
  }

  .sidebar.left {
    order: -1;
  }

  .controls {
    display: none;
  }
}
