:root {
  color-scheme: light;
  --bg: #87ceeb;
  --bg-deep: #5ba8d4;
  --grass: #5cb85c;
  --grass-dark: #449d44;
  --dirt: #8b6914;
  --card: #fff;
  --card-shadow: 0 8px 24px rgba(30, 60, 90, .18);
  --text: #1a2e1a;
  --muted: #5a6b5a;
  --line: rgba(0,0,0,.08);
  --orange: #f0ad4e;
  --orange-dark: #ec971f;
  --blue: #4a90d9;
  --blue-dark: #357abd;
  --red: #d9534f;
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
}

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(180deg, #7ec8e8 0%, #87ceeb 40%, #98d8a0 100%);
  pointer-events: none;
}

.sky::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(180deg, transparent, #6ab04c 30%, #5cb85c);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  border: 3px solid rgba(255,255,255,.9);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 1.15rem;
}

.logo__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: var(--dirt);
  border-radius: 8px;
  font-size: 1.2rem;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.2);
}

.header__user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .95rem;
}

.hello strong { color: var(--grass-dark); }

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--card-shadow);
  border: 3px solid rgba(255,255,255,.95);
  margin-bottom: 16px;
}

.card--login {
  text-align: center;
  max-width: 420px;
  margin: 0 auto;
}

.card--highlight {
  border-color: var(--grass);
  background: linear-gradient(135deg, #fff 0%, #f0fff0 100%);
}

.card__emoji {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 8px;
}

h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 800;
}

h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
  font-weight: 800;
}

.lead, .hint {
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 16px;
}

.hint.small { font-size: .88rem; margin-top: 8px; }

.card--intro {
  border-color: var(--grass);
  background: linear-gradient(135deg, #fff 0%, #f5fff5 100%);
}

.steps {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--muted);
  line-height: 1.6;
}

.steps li { margin-bottom: 8px; }
.steps li:last-child { margin-bottom: 0; }

.steps--compact {
  margin-top: 8px;
  font-size: .9rem;
}

.steps--compact li { margin-bottom: 6px; }

.info-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #eef8ff;
  border: 2px solid #b8dcff;
  font-size: .92rem;
  line-height: 1.5;
  color: #2a4a6a;
}

.info-box strong { display: block; margin-bottom: 6px; color: #1a3a5a; }
.info-box p { margin: 0; }
.info-box code { font-size: .85em; background: rgba(255,255,255,.7); padding: 1px 5px; border-radius: 4px; }

.info-box--compact { margin-top: 0; margin-bottom: 14px; }

.info-box--warn {
  margin-bottom: 14px;
  background: #fff8e6;
  border-color: #e6c200;
  color: #5a4500;
}

.info-box--warn strong { color: #4a3600; }

.info-box--ok {
  margin-bottom: 14px;
  background: #e8f8ee;
  border-color: #4caf50;
  color: #1b4d2a;
}

.info-box--ok strong { color: #145a28; }

.copy-label {
  font-size: .78rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  width: 100%;
}

.copy-row--secondary {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 2px dashed var(--line);
}

.copy-row--playit {
  background: #e8f4ff;
  border: 2px solid #5eb3ff;
  border-radius: 12px;
  padding: 12px;
}

.preset-grid .gift-btn {
  min-height: 48px;
  font-size: 1rem;
}

.note-warn {
  color: #8a5a00;
  background: #fff8e6;
  padding: 8px 12px;
  border-radius: 8px;
  border-left: 4px solid #e6a800;
}

.field__hint {
  display: block;
  font-size: .82rem;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.35;
}

.saved-loot__title {
  margin: 16px 0 6px;
  font-size: 1rem;
  font-weight: 800;
}

.cmd-card {
  padding: 12px;
  border-radius: 10px;
  background: #f8faf8;
  border: 2px solid #e0ebe0;
}

.cmd-card__head { margin-bottom: 8px; }

.cmd-card__label {
  display: block;
  font-weight: 700;
  margin-bottom: 2px;
}

.cmd-card__desc {
  display: block;
  font-size: .88rem;
  color: var(--muted);
  line-height: 1.4;
}

.cmd-row__label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .02em;
}

.gate {
  padding-top: 24px;
}

/* Tabs */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 8px;
  background: rgba(255,255,255,.75);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}

.tab {
  flex: 1 1 auto;
  min-width: 100px;
  padding: 12px 14px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: .92rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: .15s;
}

.tab:hover {
  background: rgba(92,184,92,.12);
  color: var(--text);
}

.tab--active {
  background: var(--grass);
  color: #fff;
  border-color: var(--grass-dark);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.15);
}

.tab-panel { display: none; }
.tab-panel--active { display: block; }

/* Status hero */
.status-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  margin-bottom: 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  border: 3px solid rgba(255,255,255,.95);
}

.status-hero__dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ccc;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(0,0,0,.06);
}

.status-hero--online .status-hero__dot {
  background: var(--grass);
  box-shadow: 0 0 12px var(--grass);
  animation: pulse 2s infinite;
}

.status-hero--offline .status-hero__dot {
  background: var(--red);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}

.status-hero__title {
  font-size: 1.25rem;
  font-weight: 800;
}

.status-hero__sub {
  color: var(--muted);
  font-size: .95rem;
  margin-top: 2px;
}

/* Stats row */
.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  text-align: center;
  padding: 16px;
  margin-bottom: 0;
}

.stat__label {
  display: block;
  font-size: .82rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.stat__value {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  color: var(--grass-dark);
  word-break: break-word;
}

/* Copy row */
.copy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px;
  background: rgba(92,184,92,.1);
  border-radius: var(--radius-sm);
  border: 2px dashed var(--grass);
}

.copy-row code {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--grass-dark);
}

.copy-port {
  color: var(--muted);
  font-size: .9rem;
}

/* Form */
.form { display: grid; gap: 14px; }

.form--settings {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field__label {
  font-weight: 700;
  font-size: .92rem;
  color: var(--text);
}

.field__hint {
  font-size: .8rem;
  color: var(--muted);
  font-weight: 600;
  margin-top: -2px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  background: #fafafa;
  color: var(--text);
  transition: border-color .15s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--grass);
  background: #fff;
}

/* Buttons */
.btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.15);
}

.btn:active { transform: translateY(1px); }

.btn--big {
  width: 100%;
  padding: 14px 20px;
  font-size: 1.05rem;
  border-radius: 12px;
}

.btn--small {
  padding: 8px 14px;
  font-size: .88rem;
}

.btn--green {
  background: var(--grass);
  color: #fff;
}

.btn--green:hover { background: var(--grass-dark); }

.btn--blue {
  background: var(--blue);
  color: #fff;
}

.btn--blue:hover { background: var(--blue-dark); }

.btn--orange {
  background: var(--orange);
  color: #fff;
}

.btn--orange:hover { background: var(--orange-dark); }

.btn--ghost {
  background: #eee;
  color: var(--muted);
  box-shadow: none;
  border: 2px solid var(--line);
}

.btn--danger {
  background: #fff;
  color: var(--red);
  border: 2px solid var(--red);
  box-shadow: none;
  padding: 8px 12px;
}

.help-link {
  display: inline-block;
  margin-top: 16px;
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.help-link:hover { text-decoration: underline; }

/* Toggle */
.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  margin: 16px 0;
  padding: 12px;
  background: #f5f5f5;
  border-radius: var(--radius-sm);
}

.toggle input { display: none; }

.toggle__ui {
  width: 52px;
  height: 28px;
  background: #ccc;
  border-radius: 999px;
  position: relative;
  flex-shrink: 0;
  transition: background .2s;
}

.toggle__ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.toggle input:checked + .toggle__ui {
  background: var(--grass);
}

.toggle input:checked + .toggle__ui::after {
  transform: translateX(24px);
}

.toggle__text { font-weight: 600; }

/* List editor */
.list-editor {
  display: grid;
  gap: 8px;
  margin: 16px 0 12px;
}

.list-item {
  display: flex;
  gap: 8px;
  align-items: center;
}

.list-item input {
  flex: 1;
}

.list-empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  background: #f9f9f9;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--line);
  font-weight: 600;
}

/* Log */
.log {
  background: #1e2a1e;
  color: #b8e6b8;
  border-radius: var(--radius-sm);
  padding: 14px;
  max-height: 360px;
  overflow: auto;
  font-size: .78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 12px;
}

code {
  background: rgba(92,184,92,.15);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: .9em;
}

/* Messages & toast */
.msg {
  margin: 10px 0 0;
  font-weight: 700;
  font-size: .92rem;
}

.msg--err { color: var(--red); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 24px;
  background: var(--text);
  color: #fff;
  border-radius: 999px;
  font-weight: 800;
  font-size: .95rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  z-index: 100;
  animation: toastIn .25s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 600px) {
  .tab { min-width: calc(50% - 8px); font-size: .85rem; padding: 10px 8px; }
  .header { flex-direction: column; align-items: stretch; text-align: center; }
  .header__user { justify-content: center; }
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.preset-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fafafa;
  text-align: left;
}

.preset-card strong { font-size: 1rem; }
.preset-card span { color: var(--muted); font-size: .85rem; line-height: 1.35; }

.loot-builder { display: grid; gap: 8px; margin: 12px 0; }

.loot-row {
  display: grid;
  grid-template-columns: 1fr 70px 70px 70px auto;
  gap: 8px;
  align-items: end;
}

.loot-row label { font-size: .75rem; color: var(--muted); font-weight: 700; }

.rolls-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.cmd-grid { display: grid; gap: 8px; }

.cmd-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f5f5f5;
  border-radius: var(--radius-sm);
}

.cmd-row code {
  flex: 1;
  min-width: 160px;
  font-size: .82rem;
  word-break: break-all;
}

.saved-loot { margin-top: 16px; display: grid; gap: 8px; }

.saved-loot-item {
  padding: 12px;
  border: 2px dashed var(--grass);
  border-radius: var(--radius-sm);
  background: rgba(92,184,92,.06);
}

.saved-loot-item strong { display: block; margin-bottom: 6px; }

.backup-list {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 700px) {
  .loot-row {
    grid-template-columns: 1fr 1fr;
  }
  .loot-row .btn--danger { grid-column: 1 / -1; }
}
