:root {
  --sky-top: #7fcbf0;
  --sky-bottom: #e8f7fd;
  --cream: #fffdf5;
  --cream-alt: #fff5dc;
  --ink: #2e3b4e;
  --soft-ink: #5f6e84;
  --border: #3d5a80;
  --head-top: #7cc0f0;
  --head-bottom: #3a7bc8;
  --head-outline: #1f3d66;
  --gold: #c99200;
  --orange: #e8820e;
  --green: #2f9442;
  --blue: #2577c9;
  --red: #d63c2c;
  --purple: #8549b8;
  --teal: #148a8a;
  --bar-bg: #3b4656;
  --table-head: #ffe2a8;
  --table-head-ink: #6a3d00;
  --shadow: 0 3px 0 rgba(0, 30, 60, .16);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sky-top: #0f2440;
    --sky-bottom: #1b3557;
    --cream: #1f2a3a;
    --cream-alt: #253246;
    --ink: #e8eef7;
    --soft-ink: #a7b4c7;
    --border: #0b1626;
    --head-outline: #0d1f38;
    --gold: #f2c230;
    --orange: #ffa340;
    --green: #5ccd6c;
    --blue: #5eaaf2;
    --red: #ff7462;
    --purple: #c08bf0;
    --teal: #4fd1c5;
    --table-head: #3d3320;
    --table-head-ink: #ffd88a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(var(--sky-top), var(--sky-bottom) 70%);
  background-attachment: fixed;
}

.sky { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.cloud { position: absolute; width: 180px; height: 56px; background: rgba(255, 255, 255, .55); border-radius: 40px; filter: blur(.5px); }
.cloud::before, .cloud::after { content: ""; position: absolute; background: inherit; border-radius: 50%; }
.cloud::before { width: 80px; height: 80px; left: 30px; top: -38px; }
.cloud::after { width: 64px; height: 64px; left: 92px; top: -26px; }
.c1 { left: 6%; top: 60px; }
.c2 { left: 62%; top: 28px; transform: scale(1.3); }
.c3 { left: 84%; top: 140px; transform: scale(.8); }
@media (prefers-color-scheme: dark) { .cloud { background: rgba(255, 255, 255, .05); } }

main { position: relative; max-width: 1100px; margin: 0 auto; padding: 20px 16px 32px; display: grid; gap: 16px; }

/* MapleStory-style UI window */
.window { background: var(--cream); border: 2px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.titlebar {
  --top: var(--head-top); --bottom: var(--head-bottom);
  display: flex; align-items: center; gap: 10px; padding: 6px 14px; min-height: 36px;
  background: linear-gradient(var(--top), var(--bottom));
  box-shadow: inset 0 14px 0 rgba(255, 255, 255, .18);
  border-bottom: 1.5px solid color-mix(in srgb, var(--bottom) 75%, black);
}
.window.orange .titlebar { --top: #ffc36b; --bottom: #f0801e; }
.window.green .titlebar { --top: #9bd77a; --bottom: #4e9e3a; }
.title-window .titlebar { --top: #5b6f8f; --bottom: #25344d; }
.titlebar h1, .titlebar h2 {
  margin: 0; font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 1.05rem; color: #fff; letter-spacing: .2px;
  text-shadow: -1.5px -1.5px 0 var(--head-outline), 1.5px -1.5px 0 var(--head-outline), -1.5px 1.5px 0 var(--head-outline), 1.5px 1.5px 0 var(--head-outline);
}
.titlebar h1 { font-size: 1.35rem; }
.leaf {
  width: 18px; height: 18px; flex: none;
  background: linear-gradient(#ffb347, #e8541a);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.body { padding: 14px; }
.header-body { padding: 10px 14px 12px; }
.stream-title { margin: 0; font-weight: 800; font-size: 1.05rem; overflow-wrap: anywhere; }
.muted { color: var(--soft-ink); }
.header-body .muted { margin: 4px 0 0; font-size: .9rem; }
.header-body a { color: var(--blue); }

.badge { margin-left: auto; font: 700 .8rem "Fredoka", sans-serif; padding: 3px 10px; border-radius: 999px; color: #fff; letter-spacing: .5px; }
.badge.live { background: #e0362a; box-shadow: 0 0 0 0 rgba(224, 54, 42, .6); animation: pulse 1.8s infinite; }
.badge.offline { background: #6b7a90; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(224, 54, 42, 0); } 100% { box-shadow: 0 0 0 0 rgba(224, 54, 42, 0); } }
@media (prefers-reduced-motion: reduce) { .badge.live { animation: none; } }

/* stat tiles */
.tiles { display: grid; gap: 10px; }
.tile {
  --c: var(--blue);
  border: 2px solid color-mix(in srgb, var(--c) 60%, transparent); border-radius: 10px; padding: 8px 10px 6px;
  background: linear-gradient(var(--cream), color-mix(in srgb, var(--c) 14%, var(--cream)));
  min-width: 0;
}
.tile.gold { --c: var(--gold); } .tile.orange { --c: var(--orange); } .tile.green { --c: var(--green); }
.tile.blue { --c: var(--blue); } .tile.red { --c: var(--red); } .tile.purple { --c: var(--purple); } .tile.teal { --c: var(--teal); }
.tile .cap { display: inline-block; background: var(--c); color: #fff; font-weight: 800; font-size: .72rem; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.tiles + .tiles { margin-top: 10px; }
.tiles.rates { grid-template-columns: repeat(3, 1fr); }
.tiles:not(.rates) { grid-template-columns: repeat(4, 1fr); }
.tile small { display: block; font-weight: 800; font-size: .9rem; color: color-mix(in srgb, var(--c) 75%, var(--ink)); font-variant-numeric: tabular-nums; }
.tile b { display: block; margin-top: 4px; font: 700 clamp(1.15rem, 2.3vw, 1.65rem) "Fredoka", sans-serif; color: var(--c); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 720px) { .tiles:not(.rates) { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .tiles.rates { grid-template-columns: 1fr; } }

/* in-game style EXP bar */
.expbar {
  position: relative; margin-top: 12px; height: 26px; border-radius: 13px; overflow: hidden;
  background: linear-gradient(#3b4656, #5b6878); border: 1.5px solid #1e2733;
}
.expbar .fill { position: absolute; inset: 2px auto 2px 2px; width: 0; border-radius: 11px; background: linear-gradient(#fff59d, #f5b800); transition: width .6s ease; }
.expbar span {
  position: relative; display: block; text-align: center; line-height: 23px; font: 600 .9rem "Fredoka", sans-serif; color: #fff;
  text-shadow: -1px -1px 0 #1e2733, 1px -1px 0 #1e2733, -1px 1px 0 #1e2733, 1px 1px 0 #1e2733; font-variant-numeric: tabular-nums;
}
@media (max-width: 480px) { .expbar span { font-size: .78rem; } }

.chart-wrap { position: relative; height: 300px; }

/* history table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { background: var(--table-head); color: var(--table-head-ink); text-align: left; padding: 8px 10px; font-weight: 800; white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid color-mix(in srgb, var(--soft-ink) 22%, transparent); }
tbody tr:nth-child(even) td { background: var(--cream-alt); }
tbody tr[data-id] { cursor: pointer; }
tbody tr[data-id]:hover td, tbody tr.selected td { background: color-mix(in srgb, var(--orange) 22%, var(--cream)); }
.num { text-align: right; }
td.rate { color: var(--gold); font-weight: 800; }

footer { font-size: .85rem; text-align: center; padding: 0 8px; }
footer p { margin: 4px 0; }
