/* ============ MC Stats Viewer — Minecraft-inspired but readable ============ */
:root {
  /* dark theme — slate + dirt + grass */
  --bg-0: #14171c;
  --bg-1: #1c2027;
  --bg-2: #242a33;
  --bg-3: #2e3540;
  --bg-4: #3a4150;
  --line: #0c0e12;
  --line-soft: #2a313c;
  --bevel-light: rgba(255,255,255,0.08);
  --bevel-dark:  rgba(0,0,0,0.55);

  --ink-0: #f3f4f1;
  --ink-1: #c8ccc4;
  --ink-2: #8e958c;
  --ink-3: #5d6168;

  --grass: #6ea84a;
  --grass-deep: #4a7a30;
  --diamond: #4ec9d4;
  --redstone: #c84141;
  --gold: #e0b040;
  --xp: #8fcf3a;
  --lava: #e08840;
  --lapis: #4a6fd0;

  --pixel-font: "VT323", "Press Start 2P", "Courier New", monospace;
  --mono: "JetBrains Mono", "Menlo", monospace;
  --ui: "Inter", -apple-system, system-ui, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

[data-theme="light"] {
  --bg-0: #ece9df;
  --bg-1: #f5f3ec;
  --bg-2: #e3dfd1;
  --bg-3: #d4cfbe;
  --bg-4: #b7b1a0;
  --line: #6a6354;
  --line-soft: #c8c2b1;
  --bevel-light: rgba(255,255,255,0.6);
  --bevel-dark:  rgba(0,0,0,0.18);
  --ink-0: #1a1814;
  --ink-1: #3d3a32;
  --ink-2: #6a6354;
  --ink-3: #8e887a;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--ui);
  background: var(--bg-0);
  color: var(--ink-0);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Scrollbar */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border: 2px solid var(--bg-1);
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover { background: var(--bg-4); }

/* Pixelated bevel — Minecraft inventory style */
.bevel {
  border: 2px solid var(--line);
  background: var(--bg-2);
  box-shadow:
    inset 2px 2px 0 0 var(--bevel-light),
    inset -2px -2px 0 0 var(--bevel-dark);
}
.bevel-inset {
  border: 2px solid var(--line);
  background: var(--bg-1);
  box-shadow:
    inset -2px -2px 0 0 var(--bevel-light),
    inset 2px 2px 0 0 var(--bevel-dark);
}
.slot {
  background: var(--bg-1);
  border: 2px solid var(--line);
  box-shadow:
    inset -1px -1px 0 0 var(--bevel-light),
    inset 1px 1px 0 0 var(--bevel-dark);
  padding: 4px;
}

/* Pixel heading */
.pixel { font-family: var(--pixel-font); letter-spacing: 0.5px; line-height: 1; }
.tag { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ============ Layout ============ */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* Top header — like an inventory bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--bg-1);
  border-bottom: 2px solid var(--line);
  box-shadow: 0 2px 0 0 var(--bevel-dark);
  position: relative;
  z-index: 10;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--pixel-font); font-size: 28px;
  letter-spacing: 1px;
  padding: 4px 8px;
}
.logo-cube {
  width: 40px; height: 40px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

.tabs {
  display: flex; gap: 4px;
  padding-left: 8px;
}
.tab-btn {
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  background: var(--bg-2);
  color: var(--ink-1);
  border: 2px solid var(--line);
  box-shadow: inset 2px 2px 0 var(--bevel-light), inset -2px -2px 0 var(--bevel-dark);
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: transform .04s;
}
.tab-btn:hover { color: var(--ink-0); background: var(--bg-3); }
.tab-btn:active { transform: translateY(1px); }
.tab-btn.is-active {
  background: var(--bg-0);
  color: var(--ink-0);
  box-shadow: inset 2px 2px 0 var(--bevel-dark), inset -2px -2px 0 var(--bevel-light);
}
.tab-btn .ic { display: inline-block; margin-right: 6px; opacity: 0.8; }

.totals {
  margin-left: auto;
  display: flex; gap: 14px;
  font-family: var(--mono);
  font-size: 12px;
}
.totals .stat {
  display: flex; flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}
.totals .stat .v { color: var(--ink-0); font-size: 16px; font-weight: 600; }
.totals .stat .l { color: var(--ink-3); font-size: 9px; text-transform: uppercase; letter-spacing: 0.1em; }
.totals .dot {
  display: inline-block; width: 8px; height: 8px;
  background: var(--grass); margin-right: 6px;
  box-shadow: 0 0 6px var(--grass);
  vertical-align: middle;
}

/* Body */
.body {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  padding: 20px;
  align-items: start;
}

/* Sidebar */
.sidebar { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }
.sidebar h4 {
  font-family: var(--pixel-font);
  font-size: 16px;
  margin: 0 0 8px 0;
  color: var(--ink-1);
  letter-spacing: 0.5px;
}
.sb-card { padding: 14px; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
}
.search-box .ic { font-family: var(--pixel-font); font-size: 16px; color: var(--ink-2); }
.search-box input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: 0;
  color: var(--ink-0); font-family: var(--ui); font-size: 13px;
}
.search-box input::placeholder { color: var(--ink-3); }

.filter-list { display: flex; flex-direction: column; gap: 4px; }
.filter-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  cursor: pointer;
  border: 2px solid transparent;
  font-size: 13px;
  color: var(--ink-1);
}
.filter-item:hover { background: var(--bg-2); border-color: var(--line); }
.filter-item.is-on {
  background: var(--bg-3);
  border: 2px solid var(--line);
  box-shadow: inset 1px 1px 0 var(--bevel-light), inset -1px -1px 0 var(--bevel-dark);
  color: var(--ink-0);
}
.filter-item .ic-slot {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--line);
  background: var(--bg-1);
  font-family: var(--pixel-font);
  font-size: 12px;
}
.filter-item .count { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }

/* Main panel */
.main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.section-head {
  display: flex; align-items: end; gap: 16px;
  padding-bottom: 8px;
  border-bottom: 2px dashed var(--line-soft);
}
.section-head h2 {
  font-family: var(--pixel-font);
  font-size: 28px;
  margin: 0;
  letter-spacing: 1px;
}
.section-head .sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding-bottom: 4px;
}
.section-head .right { margin-left: auto; display: flex; gap: 8px; }

/* KPI cards row */
.kpi-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.kpi {
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.kpi .lbl {
  font-family: var(--mono);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-2);
}
.kpi .val {
  font-family: var(--pixel-font);
  font-size: 32px;
  margin-top: 4px;
  color: var(--ink-0);
}
.kpi .delta { margin-top: 4px; font-family: var(--mono); font-size: 11px; color: var(--grass); }
.kpi .delta.neg { color: var(--redstone); }
.kpi .ic-bg {
  position: absolute; right: -12px; bottom: -16px;
  font-family: var(--pixel-font); font-size: 80px;
  color: var(--bg-3); opacity: 0.6; pointer-events: none;
}

/* Table */
.table-wrap {
  overflow-x: auto;
}
table.t {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
table.t th {
  text-align: left;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 10px 12px;
  background: var(--bg-1);
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
table.t th .arrow { display: inline-block; width: 10px; color: var(--grass); }
table.t th:hover { color: var(--ink-0); }
table.t th.num, table.t td.num { text-align: right; }
table.t td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.t tbody tr {
  cursor: pointer;
  transition: background .08s;
}
table.t tbody tr:hover {
  background: var(--bg-2);
}
table.t tbody tr.is-selected {
  background: color-mix(in srgb, var(--grass) 18%, transparent);
}
table.t .rank {
  font-family: var(--pixel-font);
  font-size: 18px;
  width: 36px; color: var(--ink-2);
}
table.t .rank.top1 { color: var(--gold); }
table.t .rank.top2 { color: #cfd6dc; }
table.t .rank.top3 { color: #c87a3a; }

.pname {
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-3);
  border: 2px solid var(--line);
  font-family: var(--pixel-font);
  font-size: 14px;
  color: var(--ink-0);
  flex-shrink: 0;
}
img.avatar.avatar-img {
  background: var(--bg-3);
  object-fit: cover;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.job-icon-img {
  display: block;
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  flex-shrink: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.pname .meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.pname .nm { font-weight: 600; color: var(--ink-0); }
.pname .sub { font-size: 11px; color: var(--ink-1); font-family: var(--mono); }

.cls-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px 3px 4px;
  background: var(--bg-3);
  border: 2px solid var(--line);
  font-size: 11px;
  font-family: var(--mono);
  white-space: nowrap;
}
.cls-pill .swatch {
  width: 14px; height: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--pixel-font); font-size: 10px; color: #fff;
  border: 1px solid rgba(0,0,0,0.4);
}


.kd-good { color: var(--grass); font-weight: 600; }
.kd-mid  { color: var(--gold); }
.kd-bad  { color: var(--redstone); }

/* Inline bar (damage / pickrate) */
.bar {
  position: relative;
  height: 8px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  min-width: 80px;
  overflow: hidden;
}
.bar > i {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--grass);
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(255,255,255,0.12) 0 2px,
    transparent 2px 4px
  );
}

/* ============ Class grid (for class ranking page) ============ */
.cls-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.cls-card {
  padding: 14px;
  cursor: pointer;
  transition: transform .08s;
  position: relative;
  display: flex; flex-direction: column; gap: 8px;
}
.cls-card:hover { transform: translate(-1px, -1px); }
.cls-card .head { display: flex; align-items: center; gap: 10px; }
.cls-card .icon-slot {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--pixel-font); font-size: 22px; color: #fff;
  border: 2px solid var(--line);
}
.cls-card .nm { font-family: var(--pixel-font); font-size: 18px; line-height: 1; }
.cls-card .role { font-family: var(--mono); font-size: 10px; color: var(--ink-2); text-transform: uppercase; }
.cls-card .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 4px; }
.cls-card .stats .v { font-family: var(--mono); font-size: 14px; color: var(--ink-0); font-variant-numeric: tabular-nums; }
.cls-card .stats .l { font-family: var(--mono); font-size: 9px; color: var(--ink-1); text-transform: uppercase; letter-spacing: 0.08em; }
.cls-card .pickbar { margin-top: 4px; }

/* ============ Detail drawer ============ */
.drawer-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 50;
  display: flex; justify-content: flex-end;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  width: min(1040px, 95vw);
  height: 100%;
  background: var(--bg-1);
  border-left: 2px solid var(--line);
  box-shadow: -4px 0 0 var(--bevel-dark);
  overflow-y: auto;
  animation: slideIn .2s cubic-bezier(.2,.7,.3,1);
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer-head {
  position: sticky; top: 0;
  background: var(--bg-2);
  border-bottom: 2px solid var(--line);
  padding: 16px 20px;
  display: flex; align-items: center; gap: 14px;
  z-index: 2;
}
.drawer-head .x {
  margin-left: auto;
  width: 32px; height: 32px;
  background: var(--bg-3);
  border: 2px solid var(--line);
  box-shadow: inset 2px 2px 0 var(--bevel-light), inset -2px -2px 0 var(--bevel-dark);
  font-family: var(--pixel-font); font-size: 16px;
  cursor: pointer; color: var(--ink-1);
}
.drawer-head .x:hover { background: var(--redstone); color: #fff; }
.drawer-body { padding: 20px; display: flex; flex-direction: column; gap: 18px; }

.profile {
  display: flex; align-items: center; gap: 16px;
}
.profile .av {
  width: 64px; height: 64px;
  background: var(--bg-3);
  border: 2px solid var(--line);
  box-shadow: inset 2px 2px 0 var(--bevel-light), inset -2px -2px 0 var(--bevel-dark);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--pixel-font); font-size: 26px;
}
.profile .nm { font-family: var(--pixel-font); font-size: 26px; line-height: 1; }
.profile .meta { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-family: var(--mono); font-size: 11px; color: var(--ink-2); }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-grid .c { padding: 10px 12px; }
.stat-grid .l { font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-1); }
.stat-grid .v { font-family: var(--pixel-font); font-size: 22px; margin-top: 4px; }

.subtitle {
  font-family: var(--pixel-font);
  font-size: 16px;
  margin: 6px 0 0 0;
  letter-spacing: 0.5px;
  color: var(--ink-1);
}

.recent-row {
  display: flex; gap: 4px; flex-wrap: wrap;
}

.cls-bar {
  display: grid; grid-template-columns: 240px 1fr 60px; gap: 12px;
  align-items: center; padding: 4px 0;
  font-family: var(--mono); font-size: 12px;
}
.cls-bar > div:first-child {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cls-bar .b {
  height: 12px; background: var(--bg-1); border: 1px solid var(--line); position: relative;
}
.cls-bar .b > i { position: absolute; left: 0; top: 0; bottom: 0; }

/* ============ buttons ============ */
.btn {
  font-family: var(--ui); font-weight: 600; font-size: 12px;
  padding: 6px 12px;
  background: var(--bg-3);
  color: var(--ink-0);
  border: 2px solid var(--line);
  box-shadow: inset 2px 2px 0 var(--bevel-light), inset -2px -2px 0 var(--bevel-dark);
  cursor: pointer;
  letter-spacing: 0.02em;
}
.btn:hover { background: var(--bg-4); }
.btn:active { transform: translateY(1px); box-shadow: inset 2px 2px 0 var(--bevel-dark), inset -2px -2px 0 var(--bevel-light); }
.btn.primary { background: var(--grass-deep); }
.btn.primary:hover { background: var(--grass); }

/* Compact toggle (sort/limit) */
.seg {
  display: inline-flex;
  border: 2px solid var(--line);
  box-shadow: inset 2px 2px 0 var(--bevel-light), inset -2px -2px 0 var(--bevel-dark);
}
.seg button {
  background: var(--bg-2); color: var(--ink-1);
  border: 0; border-right: 1px solid var(--line);
  padding: 6px 10px;
  font-family: var(--mono); font-size: 11px;
  cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.seg button:last-child { border-right: 0; }
.seg button.is-on { background: var(--bg-0); color: var(--ink-0); }

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-3);
  font-family: var(--mono); font-size: 13px;
}


/* Compare strip on dashboard */
.compare-strip {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
}
.list-card { padding: 14px; }
.list-card .head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.list-card .head h3 {
  font-family: var(--pixel-font); font-size: 18px; margin: 0; letter-spacing: 0.5px;
}
.list-card .row {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 10px;
  align-items: center; padding: 6px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 13px;
  cursor: pointer;
}
.list-card .row:last-child { border-bottom: 0; }
.list-card .row:hover { background: var(--bg-2); margin: 0 -8px; padding: 6px 8px; }
.list-card .row .r { font-family: var(--pixel-font); font-size: 14px; color: var(--ink-3); }
.list-card .row .v { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--grass); font-weight: 600; }

/* Responsive */
@media (max-width: 1100px) {
  .body { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .kpi-row, .cls-grid { grid-template-columns: repeat(2, 1fr); }

  .compare-strip { grid-template-columns: 1fr; }
}

/* ============ outcome / win-rate / matches ============ */
.outcome-badge { display: inline-block; min-width: 22px; padding: 2px 6px; text-align: center; font-weight: 700; font-size: 12px; border: 1px solid var(--line); }
.outcome-badge.ob-win { background: rgba(106, 180, 100, 0.18); color: #6abf6e; }
.outcome-badge.ob-loss { background: rgba(200, 65, 65, 0.18); color: #d05d5d; }
.outcome-badge.ob-draw { background: rgba(200, 200, 80, 0.18); color: #c4c46a; }
.outcome-badge.ob-unknown { background: rgba(120, 120, 120, 0.2); color: #999; }

.recent-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 10px; border: 1px solid var(--line); background: var(--bg-2); min-width: 56px; }
.recent-cell .r { font-weight: 700; }
.recent-cell .kd { font-size: 11px; opacity: 0.85; font-family: 'JetBrains Mono', monospace; }

.recent-matches { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.recent-matches .match-card { padding: 10px 12px; cursor: pointer; }
.recent-matches .match-card .head { display: flex; align-items: center; gap: 8px; font-family: 'JetBrains Mono', monospace; font-size: 18px; }
.recent-matches .match-card .players { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.recent-matches .match-card:hover { background: var(--bg-2); }
