:root {
  --bg:          #0f172a;
  --panel:       #1e293b;
  --surface:     #334155;
  --surface-2:   #3b4b63;
  --border:      #475569;
  --border-soft: #334155;
  --fg:          #e2e8f0;
  --muted:       #94a3b8;
  --faint:       #64748b;
  --accent:      #f34f6d;
  --accent-dark: #d83f5a;
  --play:        #16a34a;
  --play-dark:   #15803d;
  --guess:       #3b6df3;
  --guess-dark:  #2f57d8;
  --skip:        #e0852b;
  --skip-dark:   #c46f1c;
  --share:       #8b5cf6;
  --share-dark:  #7c45e6;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, sans-serif; margin: 0;
  background: var(--bg); color: var(--fg);
  min-height: 100vh; padding: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px;
}

.app {
  position: relative;
  width: 100%; max-width: 680px;
  background: var(--panel); border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  padding: 24px 26px 30px;
}

.page-head { display: flex; flex-direction: column; align-items: center; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 700; }
.day-number { color: var(--muted); font-weight: 600; }
.next-timer { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

.mode-nav { display: flex; gap: 12px; margin-top: 10px; font-size: 14px; }
.mode-link { color: var(--muted); text-decoration: none; transition: color .15s; }
.mode-link:hover { color: var(--fg); }
.mode-link.active { color: var(--fg); font-weight: 600; }
.mode-sep { color: var(--faint); }

.panel {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.35);
  padding: 20px;
}
.panel + .panel { margin-top: 16px; }

.game-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.attempt-row { display: flex; gap: 5px; }
.attempt-square { border: 1px solid var(--border); border-radius: 8px;
                  width: 28px; height: 28px; background: #4b5563; transition: all .3s; }
.toolbar-spacer { flex: 1; }
.toolbar-options { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.toolbar-option { display: flex; align-items: center; gap: 8px; }
.toolbar-option > span { font-size: 13px; color: var(--muted); }

select, input[type="text"] {
  background: var(--surface-2); color: var(--fg);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 8px; font-size: 14px; font-family: inherit;
}
select { cursor: pointer; padding: 5px 8px; }
input[type="text"]::placeholder { color: var(--faint); }
input[type="text"]:focus { outline: none; border-color: var(--accent); }

input[type="range"] {
  width: 96px; height: 8px; border-radius: 8px; cursor: pointer;
  background: var(--surface-2); appearance: none; -webkit-appearance: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px;
  border-radius: 50%; background: var(--accent); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border: none; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}

.game-controls { display: flex; flex-direction: column; gap: 14px; }
.play-row { display: flex; justify-content: center; }
.guess-row { display: flex; gap: 10px; }
.guess-field { position: relative; }
.guess-field input[type="text"] { width: 100%; padding: 9px 14px; border-radius: 8px;
                                  background: var(--surface-2); }

.btn {
  border: none; border-radius: 8px; padding: 9px 18px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  color: #fff; cursor: pointer; transition: background .15s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .6; cursor: default; filter: none; }
.btn-lg { padding: 12px 22px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-grow { flex: 1; }

.btn-play  { background: var(--play); }
.btn-play:hover  { background: var(--play-dark); filter: none; }
.btn-guess { background: var(--guess); }
.btn-guess:hover { background: var(--guess-dark); filter: none; }
.btn-skip  { background: var(--skip); }
.btn-skip:hover  { background: var(--skip-dark); filter: none; }
.btn-share { background: var(--share); }
.btn-share:hover { background: var(--share-dark); filter: none; }
.btn-next  { background: var(--play); }
.btn-next:hover  { background: var(--play-dark); filter: none; }

.suggestions-container {
  position: absolute; left: 0; right: 0; top: 100%; margin-top: 6px; z-index: 10;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 10px 26px rgba(0,0,0,.5);
  max-height: 220px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--faint) var(--surface-2);
}
.suggestions-container::-webkit-scrollbar { width: 8px; }
.suggestions-container::-webkit-scrollbar-track { background: var(--surface-2); border-radius: 4px; }
.suggestions-container::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 4px; }
.suggestion-item {
  padding: 9px 14px; cursor: pointer; color: var(--fg);
  border-bottom: 1px solid var(--border-soft);
}
.suggestion-item:last-child { border-bottom: 0; }
.suggestion-item:hover,
.suggestion-item.selected { background: var(--surface); }

.full-song-controls { display: flex; flex-direction: column; align-items: center; gap: 16px; margin-top: 16px; }
.cover-container { width: 192px; height: 192px; background: var(--surface-2);
                   border-radius: 10px; overflow: hidden; opacity: 0; transition: opacity .5s; }
.cover-container img { width: 100%; height: 100%; object-fit: cover; }

.attempts-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.note { margin: 12px 0 0; font-size: 12px; color: var(--faint); }

.results-screen { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.results-share { width: 100%; }

#userCard .user-card-top { display: flex; align-items: center; gap: 14px; }
.user-card-avatar { display: flex; flex-direction: column; align-items: center; gap: 4px;
                    flex-shrink: 0; width: 72px; }
.user-card-avatar img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.user-card-name { font-size: 13px; font-weight: 600; max-width: 72px; text-align: center;
                  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; flex: 1; }
.metric-box { padding: 12px; background: var(--surface-2); border: 1px solid var(--border);
              border-radius: 10px; text-align: center; }
.metric-label { margin: 0; color: var(--muted); font-size: 12px; }
.metric-value { margin: 4px 0 0; font-size: 24px; font-weight: 700; }

.user-card-streak { margin-top: 16px; }
.streak-count { margin: 0 0 8px; text-align: center; font-size: 13px; color: var(--muted); }
.streak-container { display: flex; justify-content: center; gap: 8px; align-items: flex-end; }
.streak-day { display: flex; flex-direction: column; align-items: center; font-size: 13px; }
.streak-box { width: 28px; height: 28px; border: 1px solid var(--border);
              border-radius: 8px; background: #4b5563; transition: all .3s; }
.streak-box-label { margin-top: 4px; font-size: 11px; color: var(--muted); }

.user-card-auth { margin-top: 16px; display: flex; justify-content: center; }
.btn-logout {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 8px;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; transition: background .15s, color .15s;
}
.btn-logout:hover { background: var(--surface); color: var(--fg); }
.discord-login-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 10px 20px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; color: #fff; cursor: pointer;
  background: #5865f2; transition: background .15s;
}
.discord-login-btn:hover { background: #4752c4; }

.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.stats-title { margin: 0; font-size: 18px; font-weight: 600; }
.stat-box { padding: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.stat-box p:first-child { margin: 0; color: var(--muted); font-size: 13px; }
.stat-box .stat-value { margin: 4px 0 0; font-size: 24px; font-weight: 700; }
.stats-distribution { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.dist-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.dist-label { width: 56px; text-align: right; color: var(--muted); }
.dist-track { flex: 1; height: 26px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.dist-fill { height: 100%; background: var(--play); transition: width .3s; }
.dist-count { width: 84px; }

.discord-promo { display: flex; flex-direction: column; gap: 16px; }
.discord-promo-content { display: flex; flex: 1; flex-direction: column;
                         justify-content: center; align-items: center; text-align: center; gap: 12px; }
.discord-promo-title { margin: 0; font-size: 19px; font-weight: 600; }
.discord-promo-button {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 20px; border-radius: 8px; font-weight: 600; color: #fff;
  text-decoration: none; background: #5865f2; transition: background .15s;
}
.discord-promo-button:hover { background: #4752c4; }
.discord-promo-image { width: 100%; border-radius: 12px; object-fit: cover; }

#loadingOverlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--panel); border-radius: inherit; z-index: 20;
}
.loading-spinner { width: 80px; height: 80px; border-radius: 16px; animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

@media (min-width: 768px) {
  .discord-promo { flex-direction: row; align-items: stretch; justify-content: space-between; }
  .discord-promo-media { margin-left: 24px; width: 224px; flex-shrink: 0; }
  .discord-promo-image { height: 100%; }
}

@media (max-width: 640px) {
  body { padding: 0; }
  .app { border-radius: 0; min-height: 100vh; padding: 18px 16px 28px; }
  .game-toolbar { flex-wrap: wrap; }
  .toolbar-options { width: 100%; align-items: stretch; }
  .toolbar-option { justify-content: space-between; }
  #userCard .user-card-top { align-items: stretch; }
  .user-card-metrics { gap: 8px; }
}
