:root {
  --bg-deep: #0a0c12;
  --bg-panel: #12182a;
  --bg-panel-alt: #1a2238;
  --border: #2a3555;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #c9a227;
  --accent-dim: #8a7020;
  --tank: #4a9eff;
  --healer: #5cd68a;
  --dps: #ff7b5c;
  --danger: #e74c3c;
  --grid-size: 72px;
  --font-display: "Cinzel", serif;
  --font-body: "Source Sans 3", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(108, 92, 231, 0.2), transparent),
    linear-gradient(180deg, #0d1018 0%, var(--bg-deep) 40%);
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-mark {
  font-size: 2rem;
  filter: drop-shadow(0 0 12px rgba(201, 162, 39, 0.5));
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.tagline {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-bar img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--accent-dim);
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.login-card {
  max-width: 480px;
  margin: 4rem auto;
  text-align: center;
}

.login-card h2 {
  font-family: var(--font-display);
  margin-top: 0;
}

.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.error {
  color: var(--danger);
  margin-top: 1rem;
}

.hidden {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform 0.12s, filter 0.12s;
}

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

.btn-discord {
  background: #5865f2;
  color: #fff;
  margin-top: 1rem;
}

.btn-primary {
  background: linear-gradient(180deg, #d4af37, var(--accent-dim));
  color: #111;
}

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

.section-head h2 {
  font-family: var(--font-display);
  margin: 0 0 0.35rem;
}

.char-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.char-card {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.char-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

.char-card img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.char-card h3 {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.char-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.char-title h2 {
  margin: 0;
  font-family: var(--font-display);
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tab {
  padding: 0.5rem 1rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
}

.tab.active {
  color: var(--text);
  border-color: var(--accent);
  background: var(--bg-panel-alt);
}

.gear-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 900px) {
  .gear-layout {
    grid-template-columns: 1fr;
  }
}

.paper-doll .portrait {
  width: 100%;
  aspect-ratio: 3/4;
  max-height: 280px;
  background: var(--bg-deep);
  border-radius: 10px;
  border: 1px solid var(--border);
  background-size: cover;
  background-position: center top;
  margin-bottom: 1rem;
}

.slots {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.slot {
  display: grid;
  grid-template-columns: 100px 1fr;
  align-items: center;
  gap: 0.5rem;
}

.slot-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.slot-body {
  min-height: var(--grid-size);
  background: rgba(0, 0, 0, 0.25);
  border: 2px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-body.drag-over {
  border-color: var(--accent);
  background: rgba(201, 162, 39, 0.08);
}

.stats {
  margin: 1rem 0 0;
  font-size: 0.88rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
}

.stats dt {
  color: var(--muted);
}

.stats dd {
  margin: 0;
}

.bags {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bags h3 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1rem;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-size), 1fr));
  gap: 8px;
  min-height: calc(var(--grid-size) * 2 + 8px);
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.item-cell {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  font-size: 0.68rem;
  line-height: 1.2;
  cursor: grab;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  user-select: none;
}

.item-cell:active {
  cursor: grabbing;
}

.item-cell.empty {
  opacity: 0.35;
  cursor: default;
  border-style: dashed;
}

.item-cell .qty {
  align-self: flex-end;
  background: rgba(0, 0, 0, 0.5);
  padding: 0 4px;
  border-radius: 4px;
  font-weight: 700;
}

.item-cell.tier-2 { border-color: #4a9eff; }
.item-cell.tier-3 { border-color: #a855f7; }
.item-cell.tier-4 { border-color: var(--accent); }

.trade-form label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.trade-form input {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.trade-row {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.25rem;
  background: var(--bg-panel-alt);
  border: 1px solid var(--accent);
  border-radius: 8px;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
