:root {
  color-scheme: dark;
  --ink: #26313a;
  --panel: rgba(255, 253, 243, 0.91);
  --panel-strong: #fff9e8;
  --line: rgba(55, 64, 72, 0.16);
  --coral: #f06d5f;
  --gold: #f4b941;
  --mint: #49b77f;
  --aqua: #3fb8c8;
  --blue: #496cc7;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, "Segoe UI", Arial, sans-serif;
  background: #163940;
  color: var(--ink);
}

button {
  font: inherit;
}

.shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 25% 10%, #eff8d4 0 12%, transparent 32%), linear-gradient(135deg, #a8e6cf, #71c9ce 42%, #6c8bd3);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  image-rendering: auto;
}

#game:active {
  cursor: grabbing;
}

.topbar,
.palette,
.panel,
.toast {
  position: absolute;
  z-index: 2;
}

.topbar {
  top: 16px;
  left: 18px;
  right: 18px;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(190px, 1.5fr) repeat(5, minmax(92px, 0.55fr));
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 55px rgba(21, 48, 58, 0.25);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: conic-gradient(from 20deg, var(--coral), var(--gold), var(--mint), var(--aqua), var(--coral));
  box-shadow: inset 0 -7px 0 rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.18);
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand small,
.metric span {
  display: block;
  color: #637071;
  font-size: 12px;
}

.metric {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.65);
}

.metric strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(17px, 1.8vw, 24px);
  white-space: nowrap;
}

.palette {
  left: 18px;
  top: 108px;
  display: grid;
  width: 86px;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 249, 232, 0.9);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(17, 51, 52, 0.22);
}

.tool {
  width: 70px;
  height: 56px;
  display: grid;
  place-items: center;
  grid-template-rows: 26px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #324044;
  background: rgba(255, 255, 255, 0.58);
  cursor: pointer;
}

.tool span {
  font-size: 24px;
  line-height: 1;
}

.tool b {
  font-size: 11px;
}

.tool:hover,
.tool.active {
  background: #fff;
  border-color: rgba(63, 184, 200, 0.65);
  box-shadow: inset 0 -4px 0 rgba(63, 184, 200, 0.16), 0 8px 18px rgba(29, 79, 87, 0.16);
}

.panel {
  right: 18px;
  top: 108px;
  width: min(330px, calc(100vw - 130px));
  display: grid;
  gap: 10px;
}

.card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(17, 51, 52, 0.22);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-head strong {
  font-size: 17px;
}

#selectionBadge {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(73, 183, 127, 0.15);
  color: #247551;
  font-size: 12px;
  white-space: nowrap;
}

.card p {
  margin: 10px 0 12px;
  color: #5d686c;
  font-size: 13px;
  line-height: 1.35;
}

.bars {
  display: grid;
  gap: 9px;
}

.bars label {
  display: grid;
  grid-template-columns: 72px 36px 1fr;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: #586467;
}

.bars i {
  height: 8px;
  border-radius: 999px;
  background: rgba(38, 49, 58, 0.13);
  overflow: hidden;
}

.bars em {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--aqua), var(--mint));
}

.compact {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.compact button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: #26313a;
  color: #fff8e8;
  cursor: pointer;
}

.toast {
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 36px));
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(38, 49, 58, 0.86);
  color: #fff8e8;
  font-size: 13px;
  box-shadow: 0 12px 35px rgba(18, 40, 48, 0.28);
  pointer-events: none;
}

@media (max-width: 780px) {
  .topbar {
    grid-template-columns: 1fr 1fr 1fr;
    right: 10px;
    left: 10px;
    top: 10px;
  }

  .brand {
    grid-column: 1 / -1;
  }

  .palette {
    left: 10px;
    top: auto;
    bottom: 12px;
    width: calc(100vw - 20px);
    grid-template-columns: repeat(10, minmax(48px, 1fr));
    overflow-x: auto;
  }

  .tool {
    width: 100%;
    min-width: 54px;
  }

  .panel {
    top: 176px;
    right: 10px;
    width: min(300px, calc(100vw - 108px));
  }

}
