/* ===== Pre-Lobby Top Bar ===== */
.pre-lobby-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  height: 64px;
  background: rgba(26, 41, 104, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
body:not(.pre-lobby) .pre-lobby-topbar {
  display: none;
}
.pre-lobby-topbar .topbar-left a {
  display: flex;
  align-items: center;
}
.pre-lobby-topbar .topbar-left img {
  height: 36px;
  width: auto;
  filter: brightness(0) invert(1);
}
.pre-lobby-topbar .topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.pre-lobby-topbar .theme-toggle {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.85);
}
.pre-lobby-topbar .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  color: #ffffff;
}

/* ===== Pre-Lobby Wrapper (Client Only) ===== */
.pre-lobby-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ===== Pre-Lobby Card ===== */
.pre-lobby-card {
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2xl);
  max-width: 480px;
  width: 100%;
  overflow: hidden;
}

/* ===== Card Header ===== */
.pre-lobby-card .card-header {
  background: var(--gradient-brand);
  color: #ffffff;
  padding: var(--space-8);
  text-align: center;
  border-radius: var(--radius-2xl);
}
.pre-lobby-card .card-header .logo-wrap {
  margin-bottom: var(--space-4);
}
.pre-lobby-card .card-header .logo-wrap img {
  height: 60px;
  width: auto;
  max-width: 100%;
  filter: brightness(0) invert(1);
}
.pre-lobby-card .card-header h1 {
  margin: 0 0 var(--space-2) 0;
  font-size: 1.8rem;
}
.pre-lobby-card .card-header p {
  margin: 0;
  opacity: 0.9;
  font-size: var(--text-base);
}

/* ===== Card Body ===== */
.pre-lobby-card .card-body {
  padding: var(--space-5) var(--space-8);
}

/* ===== Join Section ===== */
.pre-lobby-card .join-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.pre-lobby-card .join-section label {
  display: block;
  font-weight: 600;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
.pre-lobby-card .join-section input {
  width: 100%;
  padding: var(--space-4) var(--space-5);
  font-size: 2rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: center;
  letter-spacing: 0.35rem;
  font-weight: 700;
  font-family: var(--font-mono);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
  background: var(--color-bg);
  color: var(--color-text);
}
.pre-lobby-card .join-section input:focus {
  outline: none;
  border-color: var(--color-brand-500);
  box-shadow: var(--focus-ring);
}
.pre-lobby-card .join-section input::placeholder {
  letter-spacing: 0.35rem;
  font-weight: 400;
  font-family: var(--font-mono);
  color: var(--color-text-muted);
}

/* ===== Join Button ===== */
.pre-lobby-card .join-section button {
  width: 100%;
  padding: var(--space-4) var(--space-6);
  background: var(--gradient-brand);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}
.pre-lobby-card .join-section button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-brand-lg);
}
.pre-lobby-card .join-section button:disabled {
  background: var(--color-neutral-400);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===== Status Message ===== */
.status-message:empty {
  display: none;
}
.status-message {
  text-align: center;
  margin-top: var(--space-4);
  padding: 0 var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* ===== Back Link ===== */
.back-link {
  display: block;
  text-align: center;
  margin-top: var(--space-6);
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 0.95rem;
}
.back-link:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* ===== Header Row (Client Version) ===== */
.header-row {
  display: none;
}
.header-row.visible {
  display: flex;
}

/* ===== Display ===== */
.display {
  background: #ffffff;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  margin: var(--space-5) auto;
  max-width: 1200px;
  min-height: 150px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
/* Score display — always white */
.display,
[data-theme="dark"] .display {
  background: #ffffff !important;
}
.display svg { max-width: 100%; height: auto; }

/* ===== Instrument Selection ===== */
.instrument-selection {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: var(--space-10) var(--space-5);
  max-width: 900px;
  margin: 0 auto;
}
.instrument-selection h2 {
  margin: 0 0 var(--space-2) 0;
  font-size: 1.8rem;
  color: var(--color-text);
}
.instrument-selection-subtitle {
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-8) 0;
  font-size: 1.05rem;
}

/* ===== Instrument Grid (Client Grid Layout) ===== */
.instrument-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
  width: 100%;
}

/* ===== Instrument Buttons ===== */
.instrument-btn {
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition-normal);
  text-align: center;
}
.instrument-btn:hover {
  border-color: var(--color-brand-500);
  background: var(--color-brand-50);
  transform: translateY(-2px);
  box-shadow: var(--shadow-brand);
}
.instrument-btn:active {
  transform: translateY(0);
}

/* ===== Section Label ===== */
.section-label {
  font-weight: 600;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin: var(--space-8) 0 var(--space-3) 0;
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--color-border);
  width: 100%;
}
.section-label:first-of-type { margin-top: 0; }

/* ===== Section Label Icons ===== */
.section-label-icon {
  width: 16px;
  height: 16px;
  vertical-align: -2px;
  margin-right: var(--space-1);
}

/* ===== Waiting Message ===== */
.waiting-icon {
  width: 48px;
  height: 48px;
  color: var(--color-warning-500);
  margin-bottom: var(--space-4);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.05); }
}
.waiting-message {
  display: none;
  margin: var(--space-10) auto;
  padding: var(--space-12) var(--space-8);
  max-width: 600px;
  text-align: center;
  background: linear-gradient(135deg, var(--color-warning-100) 0%, var(--color-warning-200) 100%);
  border: 2px solid var(--color-warning-500);
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}
.waiting-message h2 {
  margin: 0 0 var(--space-3) 0;
  color: var(--color-warning-700);
  font-size: var(--text-2xl);
}
.waiting-message p {
  margin: 0;
  color: var(--color-warning-800);
  font-size: 1.1rem;
}
.waiting-dots {
  display: inline-block;
}
.waiting-dots::after {
  content: '...';
  animation: dots-content 1.5s infinite;
}
@keyframes dots-content {
  0%, 33% { content: '.'; }
  34%, 66% { content: '..'; }
  67%, 100% { content: '...'; }
}

/* ===== Client Media Query ===== */
@media (max-width: 640px) and (orientation: portrait) {
  body:not(.pre-lobby) .rotate-disclaimer {
    display: block;
  }
}
