body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #1a1a2e;
  color: #eee;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  box-sizing: border-box;
}

h1 {
  margin: 0 0 16px 0;
  font-weight: 500;
  font-size: 1.7em;
  letter-spacing: 0.02em;
  color: #e94560;
}

h2 {
  margin: 0 0 12px 0;
  font-weight: 500;
  font-size: 1.3em;
}

h3 {
  margin: 8px 0 4px 0;
  font-size: 0.95em;
  color: #a8b8d8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== Screens ===== */
.screen { display: none; }
.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 560px;
}
#screen-game.active {
  max-width: 100%;
}

.lead {
  text-align: center;
  color: #a8b0c8;
  line-height: 1.5;
  margin: 4px 0 24px;
}

.screen-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.hint {
  color: #707898;
  font-size: 0.85em;
  margin-top: 14px;
  text-align: center;
}

.onboarding-tip {
  width: 100%;
  background: #2a3450;
  border: 1px solid #3a4868;
  border-left: 4px solid #e94560;
  padding: 12px 14px;
  border-radius: 6px;
  margin: 4px 0 16px;
  font-size: 0.9em;
  color: #c8d0e8;
  box-sizing: border-box;
  line-height: 1.5;
}

.onboarding-tip p {
  margin: 0 0 8px 0;
}

.onboarding-tip button {
  padding: 5px 12px;
  font-size: 0.85em;
}

/* ===== Buttons ===== */
button, select {
  padding: 9px 16px;
  font-size: 0.95em;
  border-radius: 6px;
  border: 1px solid #3a4868;
  background: #2a3450;
  color: #eee;
  cursor: pointer;
  font-family: inherit;
}

button:hover:not(:disabled) { background: #3a4868; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.primary-btn {
  background: #e94560;
  border-color: #ff5b76;
  font-weight: 600;
}
.primary-btn:hover:not(:disabled) { background: #ff5b76; }

.success-btn {
  background: #3a8a3a;
  border-color: #4caf4c;
}
.success-btn:hover:not(:disabled) { background: #4aaa4a; }

.danger-btn {
  background: #8a3a3a;
  border-color: #c04c4c;
}
.danger-btn:hover:not(:disabled) { background: #a04a4a; }

/* ===== Lobby / forms ===== */
.form-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
  width: 100%;
}

.form-row-stacked {
  flex-direction: column;
  align-items: flex-start;
}

.form-row label {
  color: #c8d0e8;
  font-size: 0.95em;
}

.form-row textarea, .form-row input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #3a4868;
  background: #16213e;
  color: #eee;
  font-family: inherit;
  font-size: 0.9em;
  box-sizing: border-box;
  resize: vertical;
}

.invite-row {
  display: flex;
  gap: 8px;
  width: 100%;
  margin: 8px 0 16px;
}

#invite-link {
  flex: 1;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid #3a4868;
  background: #16213e;
  color: #cce0ff;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.9em;
}

.lobby-players, .lobby-settings {
  width: 100%;
  background: #1f2942;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 8px 0;
  box-sizing: border-box;
}

#player-list {
  margin: 0;
  padding-left: 22px;
  color: #c8d0e8;
}

#player-list li {
  padding: 3px 0;
}

.knock-box {
  width: 100%;
  background: #2a3450;
  border: 1px solid #e94560;
  border-radius: 8px;
  padding: 14px 16px;
  margin: 10px 0;
  text-align: center;
  box-sizing: border-box;
}

.knock-box p { margin: 0 0 10px 0; }
.knock-box button { margin: 0 4px; }

#lobby-status, #guest-status {
  color: #a8b0c8;
  margin: 4px 0 8px;
  text-align: center;
}

/* ===== Image picker (tabs + panes) ===== */
.image-picker {
  width: 100%;
  border: 1px solid #3a4868;
  border-radius: 6px;
  background: #1f2942;
  margin-top: 6px;
  box-sizing: border-box;
  overflow: hidden;
}

.picker-tabs {
  display: flex;
  border-bottom: 1px solid #3a4868;
}

.picker-tab {
  flex: 1;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: #a8b0c8;
  font-size: 0.9em;
  border-radius: 0;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.picker-tab:hover:not(.active) {
  background: #2a3450;
}

.picker-tab.active {
  background: #16213e;
  color: #f0f4ff;
  font-weight: 600;
  border-bottom: 2px solid #e94560;
}

.picker-pane {
  padding: 10px;
}

#url-input {
  flex: 1;
  padding: 7px 10px;
  border-radius: 5px;
  border: 1px solid #3a4868;
  background: #16213e;
  color: #f0f4ff;
  font-family: inherit;
  font-size: 0.9em;
  min-width: 0;
}

#upload-input {
  color: #c8d0e8;
  font-family: inherit;
  font-size: 0.9em;
}

.picker-preview-thumb {
  width: 160px;
  aspect-ratio: 4 / 3;
  background: #16213e;
  border-radius: 4px;
  margin-top: 8px;
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
}

.picker-preview-thumb.selected {
  border-color: #e94560;
  box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.4);
}

.picker-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ===== Image gallery picker ===== */
.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  width: 100%;
  margin-top: 6px;
}

.image-gallery .gallery-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  background: #16213e;
  transition: transform 0.1s, border-color 0.1s;
}

.image-gallery .gallery-thumb:hover {
  transform: scale(1.02);
}

.image-gallery .gallery-thumb.selected {
  border-color: #e94560;
  box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.4);
}

.image-gallery .gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-gallery .gallery-thumb .thumb-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: #f0f4ff;
  font-size: 0.75em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-gallery .gallery-thumb.broken {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #3a4868;
  color: #707898;
  font-size: 0.8em;
  text-align: center;
  padding: 6px;
  box-sizing: border-box;
  cursor: not-allowed;
}

.image-gallery .gallery-thumb.broken:hover {
  transform: none;
}

.image-gallery .gallery-empty {
  grid-column: 1 / -1;
  color: #707898;
  font-size: 0.9em;
  padding: 12px;
  border: 1px dashed #3a4868;
  border-radius: 6px;
  text-align: center;
  line-height: 1.5;
}

.image-gallery .gallery-empty code {
  background: #16213e;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.9em;
  color: #cce0ff;
}
