:root {
  --bg: #12090a;
  --bg-elevated: #1c1012;
  --ink: #f7ecec;
  --muted: #b89a9d;
  --line: rgba(247, 236, 236, 0.12);
  --accent: #e11d2e;
  --accent-soft: rgba(225, 29, 46, 0.16);
  --ok: #2f9e6b;
  --err: #e11d2e;
  --radius: 10px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Outfit", "DM Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(225, 29, 46, 0.28), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(120, 40, 50, 0.35), transparent 50%),
    linear-gradient(180deg, #1a0c0e 0%, var(--bg) 45%, #0c0708 100%);
  background-attachment: fixed;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand img {
  border-radius: 6px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.avatar {
  border-radius: 50%;
}

.main {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.5rem 0 4rem;
  flex: 1;
}

.hero {
  padding: 4rem 0 2rem;
  max-width: 34rem;
  animation: rise 0.6s ease both;
}

.eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin: 0 0 0.75rem;
  font-weight: 600;
}

h1 {
  font-family: var(--display);
  font-weight: 650;
  font-size: clamp(2rem, 4.5vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
}

.lede {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
  margin: 0 0 1.5rem;
}

.section h1 {
  font-size: clamp(1.8rem, 3.5vw, 2.4rem);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.7rem 1.25rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #c41626;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.btn-ghost:hover {
  color: var(--ink);
  border-color: rgba(247, 236, 236, 0.3);
}

.flash {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  margin: 0 0 1.25rem;
  border: 1px solid var(--line);
}

.flash-success {
  background: rgba(47, 158, 107, 0.15);
  border-color: rgba(47, 158, 107, 0.35);
}

.flash-error {
  background: var(--accent-soft);
  border-color: rgba(225, 29, 46, 0.4);
}

.btn-small {
  padding: 0.45rem 0.9rem;
  font-size: 0.88rem;
  white-space: nowrap;
}

.guild-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0.65rem;
}

.guild-tile {
  min-width: 0;
}

.guild-tile-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 0.75rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(28, 16, 18, 0.7);
  color: inherit;
  text-decoration: none;
  text-align: center;
  height: 100%;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.guild-tile--ready .guild-tile-link:hover {
  border-color: rgba(225, 29, 46, 0.5);
  background: var(--bg-elevated);
  transform: translateY(-2px);
}

.guild-tile--missing .guild-tile-link {
  opacity: 0.85;
}

.guild-tile--missing .guild-tile-link:hover {
  opacity: 1;
  border-color: rgba(247, 236, 236, 0.28);
}

.guild-icon,
.guild-fallback {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  flex-shrink: 0;
}

.guild-fallback {
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 1.2rem;
}

.guild-name {
  font-weight: 600;
  font-size: 0.78rem;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  width: 100%;
  word-break: break-word;
}

.guild-action {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: auto;
}

.guild-action--invite {
  color: var(--muted);
}

.empty {
  color: var(--muted);
}

@media (max-width: 1100px) {
  .guild-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .guild-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .guild-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.settings-head {
  margin-bottom: 1.75rem;
}

.back {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.back:hover {
  color: var(--ink);
}

.settings-title {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
}

.settings-title img {
  border-radius: 12px;
}

.settings-title .lede {
  margin: 0;
}

.settings-form fieldset {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.25rem 1.25rem 0.5rem;
  margin: 0 0 1.25rem;
  background: rgba(28, 16, 18, 0.55);
}

.settings-form legend {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  padding: 0 0.35rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1.15rem;
}

.field .label {
  font-weight: 600;
}

.field .hint {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.field select,
.field input[type="number"],
.field input[type="color"] {
  width: 100%;
  max-width: 28rem;
  background: #0f0809;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font: inherit;
}

.field input[type="color"] {
  padding: 0.25rem;
  height: 2.5rem;
  max-width: 6rem;
}

.field select[multiple] {
  max-width: 100%;
}

.field.switch {
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.75rem;
}

.field.switch input {
  margin-top: 0.25rem;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}

.form-actions {
  display: flex;
  justify-content: flex-start;
  padding-top: 0.5rem;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section,
.settings {
  animation: rise 0.45s ease both;
}

@media (max-width: 640px) {
  .topbar-user span {
    display: none;
  }
}
