:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #5d685f;
  --line: #d8ded6;
  --panel: #fffdf7;
  --paper: #f4f0e6;
  --grass: #4f9a56;
  --leaf: #2f6f47;
  --water: #2f8fb7;
  --coral: #c85c4a;
  --gold: #c99a2d;
  --rarity-comum: #7d8580;
  --rarity-incomum: #2f8f5b;
  --rarity-raro: #2f78c6;
  --rarity-premium: #c99a2d;
  --shadow: 0 12px 28px rgba(31, 38, 32, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  min-height: 36px;
  padding: 0 12px;
}

button:hover,
a:hover {
  filter: brightness(0.97);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: 58px 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #fffaf0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--leaf);
  color: white;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
  white-space: nowrap;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.balance-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: white;
  white-space: nowrap;
}

.coin-icon,
.pixc-icon {
  display: inline-block;
  flex: 0 0 auto;
}

.coin-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffd15b;
  box-shadow: inset 0 0 0 2px rgba(151, 104, 18, 0.22);
}

.pixc-icon {
  width: 12px;
  height: 12px;
  rotate: 45deg;
  border-radius: 2px;
  background: #3ad1b0;
}

.xp-badge {
  width: 136px;
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}

.xp-badge i {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9ede7;
}

.xp-badge b {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f8fb7, #3ad1b0);
  transition: width 180ms ease;
}

.primary-button {
  border-color: var(--leaf);
  background: var(--leaf);
  color: white;
}

.wallet-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.wallet-button {
  min-height: 36px;
  padding: 0 10px;
  border-color: rgba(47, 143, 183, 0.34);
  background: #f7fffc;
  color: var(--ink);
}

.game-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
}

.game-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #1b2b24;
}

#game-root {
  width: 100%;
  height: 100%;
}

#game-root canvas {
  display: block;
}

.side-panel {
  min-width: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.tab {
  background: #ffffff;
}

.tab.is-active {
  border-color: var(--water);
  background: #e8f5f8;
}

.tab-panel {
  display: none;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.tab-panel.is-active {
  display: block;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.icon-button {
  width: 36px;
  padding: 0;
  font-size: 18px;
}

.item-list {
  display: grid;
  gap: 8px;
}

.item-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
}

.rarity-card {
  border-left-width: 4px;
}

.rarity-card.rarity-comum {
  border-left-color: var(--rarity-comum);
}

.rarity-card.rarity-incomum {
  border-left-color: var(--rarity-incomum);
}

.rarity-card.rarity-raro {
  border-left-color: var(--rarity-raro);
}

.rarity-card.rarity-premium {
  border-left-color: var(--rarity-premium);
  background: #fff9e8;
}

.item-card strong {
  display: block;
  margin-bottom: 3px;
}

.item-card small,
.muted {
  color: var(--muted);
}

.item-card footer {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  margin-top: 8px;
}

.compact-form {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.compact-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: white;
  color: var(--ink);
}

.status-box {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.external-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.external-links a {
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  text-decoration: none;
}

.toast-stack {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: grid;
  gap: 8px;
  z-index: 5;
  max-width: min(420px, calc(100% - 28px));
}

.empty-state {
  color: var(--muted);
  padding: 12px 0;
}

@media (max-width: 920px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    grid-template-rows: 58px minmax(0, 1fr);
  }

  .game-layout {
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }
  .game-stage {
    height: auto;
    min-height: 0;
  }
  .side-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 75vw;
    max-width: 320px;
    height: 100vh;
    height: 100dvh;
    border-left: 1px solid var(--line);
    border-top: 0;
    z-index: 90;
    transition: right 0.25s ease;
    overflow-y: auto;
    min-height: 0;
  }
  .side-panel.drawer-open {
    right: 0;
  }
  .topbar {
    align-items: flex-start;
  }
  .balance-badge {
    display: none;
  }
  #panel-toggle {
    display: block !important;
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 91;
    padding: 8px 18px;
    border-radius: 20px;
    background: rgba(5,13,20,0.88);
    border: 1px solid rgba(93,242,255,0.4);
    color: #5df2ff;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    backdrop-filter: blur(8px);
  }

  .xp-badge {
    display: none;
  }

  .wallet-button {
    display: none;
  }
}
