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

body {
  background: #202124;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #e8eaed;
  user-select: none;
  -webkit-user-select: none;
}

#back-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  color: #fff;
  text-decoration: none;
  font-size: 22px;
  font-weight: 700;
  z-index: 20;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #5f6368;
  transition: background 0.2s;
  line-height: 1;
}

#back-btn:hover {
  background: #80868b;
}

#game-container {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

#main-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
}

#toolbar {
  display: flex;
  gap: 24px;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#toolbar > div {
  color: #9aa0a6;
}

#toolbar span {
  color: #e8eaed;
}

#high-score-display {
  color: #5f6368 !important;
}

#board-canvas {
  display: block;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* Side panels */
#side-left,
#side-right {
  padding-top: 36px;
}

.panel {
  background: #292a2d;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.panel-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #9aa0a6;
}

.panel canvas {
  display: block;
}

/* Overlay */
#overlay {
  position: absolute;
  top: 28px;
  left: 0;
  width: 100%;
  height: calc(100% - 28px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10;
  border-radius: 4px;
}

#overlay.visible {
  display: flex;
}

#overlay-content {
  text-align: center;
  background: rgba(32, 33, 36, 0.92);
  padding: 40px 48px;
  border-radius: 20px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

#overlay-content h1 {
  font-size: 44px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #42a5f5;
}

#overlay-message {
  font-size: 14px;
  color: #9aa0a6;
  margin-bottom: 24px;
  line-height: 1.5;
}

#start-btn {
  background: #42a5f5;
  color: #fff;
  border: none;
  padding: 12px 44px;
  font-size: 18px;
  font-weight: 600;
  border-radius: 28px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

#start-btn:hover {
  background: #1e88e5;
  transform: scale(1.04);
}

#start-btn:active {
  transform: scale(0.97);
}

/* Mobile controls */
#mobile-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
}

.ctrl-row {
  display: flex;
  gap: 6px;
}

.ctrl-btn {
  width: 64px;
  height: 56px;
  border-radius: 12px;
  border: none;
  background: #3c4043;
  color: #e8eaed;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s;
}

.ctrl-btn.wide {
  width: 100px;
  font-size: 16px;
}

.ctrl-btn:active {
  background: #5f6368;
}

@media (pointer: coarse) {
  #mobile-controls {
    display: flex;
  }
}

@media (max-width: 700px) {
  #side-left,
  #side-right {
    display: none;
  }

  #overlay-content {
    padding: 28px 32px;
  }

  #overlay-content h1 {
    font-size: 32px;
  }
}
