:root {
  /* App-owned palette: Telegram's host theme must not turn the white UI dark. */
  color-scheme: light;
  --bg: #ffffff;
  --text: #172b45;
  --hint: #54677e;
  --btn: #1f63c2;
  --btn-text: #ffffff;
  --card: #f4f7fc;
  --border: #dce5f0;
  --control-border: #7c8fa9;
  --accent-soft: #eaf2ff;
  --focus-ring: rgba(31,99,194,0.18);
  --shadow: 0 4px 18px rgba(23,43,69,0.07);
  --danger: #b73850;
  --mark-x: #2264af;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  height: 100%;
  overflow: hidden;
}

#app { max-width: 400px; margin: 0 auto; height: 100%; }

#hub {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px 16px 0;
}

h1 { font-size: 24px; text-align: center; margin-bottom: 4px; flex-shrink: 0; }

.subtitle {
  text-align: center;
  color: var(--hint);
  margin-bottom: 16px;
  font-size: 14px;
  flex-shrink: 0;
}

.version {
  text-align: center;
  color: var(--hint);
  font-size: 11px;
  padding: 4px 0 8px;
  flex-shrink: 0;
}

/* ── Scrollable Game Cards ──────────── */

#game-cards {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

/* ── Gift Picker (flexible height) ─── */

#gift-picker {
  flex: 0 0 auto;
  padding: 14px 0 12px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}

#gift-picker.empty {
  padding: 10px 0;
}

/* ── Game Cards ─────────────────────── */

.game-card {
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(23,43,69,0.04);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 72px;
  overflow: hidden;
  transition: transform 0.1s, opacity 0.1s;
  flex-shrink: 0;
}

.game-card:active { transform: scale(0.98); opacity: 0.85; }

.game-card .icon {
  font-size: 36px;
  width: 50px;
  text-align: center;
  flex-shrink: 0;
}

.game-card .info {
  flex: 1;
  min-width: 0;
}

.game-card .name {
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-card .desc {
  font-size: 13px;
  color: var(--hint);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Game Container ─────────────────── */

#game-container {
  width: 100%;
  padding-top: 40px;
}

.back-btn {
  background: var(--card);
  color: var(--btn);
  border: 1px solid var(--control-border);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 16px;
}

.back-btn:active { opacity: 0.7; }

#game-container .game-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

#game-container .game-header .icon { font-size: 28px; }
#game-container .game-header .name { font-size: 20px; font-weight: 700; }

/* ── Gift Picker ────────────────────── */

.gift-label {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}

.gift-hint {
  font-size: 13px;
  color: var(--hint);
  text-align: center;
}

/* ── One-row skin choices, shared by hub and room ── */

.gift-slider, .gift-grid {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 8px;
  padding: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.gift-item {
  flex: 0 0 72px;
  width: 72px;
  min-height: 76px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform 0.1s;
}

.gift-item:active { transform: scale(0.95); }
.gift-item:focus-visible, .back-btn:focus-visible { outline:2px solid var(--btn); outline-offset:2px; }

.gift-item.selected {
  border-color: var(--btn);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.gift-emoji, .gift-emoji-fallback {
  font-size: 28px;
  height: 40px;
  line-height: 40px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
}

.gift-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
}

.gift-name {
  font-size: 10px;
  color: var(--hint);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60px;
}
