.app {
  padding: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
}

.game-row {
  display: flex;
  flex-direction: row;
  gap: 0;
  overflow: hidden;
  align-items: stretch;
  min-height: 200px;
}

.sidebar {
  width: 120px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 8px;
  background: var(--surface);
}

.sidebar-left  { border-right: 1px solid var(--border); }
.sidebar-right { border-left:  1px solid var(--border); }

.sidebar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.hud-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
}

.hud-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  min-width: 3ch;
  text-align: center;
}

.sidebar-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 90%;
}

.sidebar-btns .btn {
  width: 100%;
  font-size: 0.72rem;
  padding: 6px 4px;
}

.sidebar-item .select {
  width: 100%;
  font-size: 0.75rem;
  padding: 4px 6px;
}

.board-wrapper {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 18px;
}

.board {
  position: relative;
  aspect-ratio: 2 / 1;
  width: 100%;
  max-height: 100%;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  border-radius: 12px;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.55);
  background: #0a1f12;
}

#three-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.loading, .error, .overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 10;
}
.loading { background: rgba(0,0,0,0.72); color: #fff; }
.loading-text { font-size: clamp(20px, 4vmin, 28px); font-weight: 700; }
.loading-sub { font-size: 14px; opacity: 0.7; }
.loading[hidden] { display: none; }

.error { background: rgba(80,0,0,0.85); color: #fff; }
.error-text { font-size: clamp(18px, 3.6vmin, 22px); font-weight: 700; padding: 0 24px; text-align: center; }
.error[hidden] { display: none; }

.overlay { background: rgba(0,0,0,0.7); animation: fadein .3s ease-in-out; }
.overlay[hidden] { display: none; }
.overlay-text {
  font-size: clamp(28px, 6vmin, 48px);
  font-weight: 800;
  color: #fff;
  text-align: center;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.leaderboard { padding: 12px 16px; }
.lb-title { font-size: 13px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); margin: 0 0 8px; }
.lb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lb-table th, .lb-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.lb-table th { font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); }
.lb-table tbody tr:first-child td { color: var(--accent); font-weight: 700; }

@media (max-width: 640px) {
  .game-row {
    flex-direction: column;
    height: auto !important;
  }
  .sidebar {
    flex-direction: row;
    width: 100%;
    height: auto;
    padding: 6px 12px;
    justify-content: space-around;
    gap: 10px;
    flex-wrap: wrap;
  }
  .sidebar-left  { border-right: none; border-bottom: 1px solid var(--border); order: 1; }
  .sidebar-right { border-left:  none; border-top:    1px solid var(--border); order: 3; }
  .board-wrapper { order: 2; padding: 8px; }
  .sidebar-item  { flex-direction: row; align-items: baseline; gap: 6px; }
  .hud-value     { font-size: 1.1rem; }
  .sidebar-btns  { flex-direction: row; width: auto; }
}
