* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0a1420;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #eaf6ff;
}

.hidden {
  display: none !important;
}

#back-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 30;
  background: rgba(6, 14, 22, 0.65);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  color: #eaf6ff;
  text-decoration: none;
}

#back-link:hover {
  background: rgba(6, 14, 22, 0.85);
}

button {
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #34e89e, #3b9dff);
  color: #04121c;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: inherit;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

#game {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

#top-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  padding-left: 9rem;
  background: rgba(6, 14, 22, 0.75);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

@media (max-width: 480px) {
  #top-bar {
    padding-left: 1rem;
    padding-top: 3rem;
    flex-wrap: wrap;
  }
}

#score-label {
  flex: 1;
  font-weight: 600;
}

#best-label {
  color: #a7bdd1;
  font-size: 0.85rem;
}

#board-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 1rem;
}

#board {
  background: #0d1826;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  max-width: 100%;
  max-height: 100%;
  touch-action: none;
}

#start-overlay, #gameover-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(0, 0, 0, 0.55);
  text-align: center;
  padding: 1rem;
}

#touch-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem;
}

#touch-row {
  display: flex;
  gap: 0.4rem;
}

#touch-controls button {
  width: 3rem;
  height: 3rem;
  font-size: 1.2rem;
  padding: 0;
}

@media (hover: none) and (pointer: coarse) {
  #touch-controls {
    display: flex;
  }
}

#players-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(20, 40, 60, 0.6), rgba(4, 10, 16, 0.9));
}

.panel {
  background: rgba(8, 18, 28, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2rem 2.5rem;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  text-align: center;
  max-width: 420px;
  width: min(90vw, 420px);
  max-height: 90vh;
  overflow-y: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.player-list {
  list-style: none;
  margin: 0.5rem 0 1rem;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.player-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font-size: 0.9rem;
}

.player-list .score {
  color: #a7bdd1;
  font-variant-numeric: tabular-nums;
}
