:root {
  --bg: #02070d;
  --panel: #061321;
  --panel2: #091929;
  --panel3: #0c2032;
  --gold: #c8942e;
  --gold2: #e5c06a;
  --gold3: #8b6726;
  --line: rgba(191, 143, 45, 0.48);
  --line2: rgba(191, 143, 45, 0.2);
  --text: #e9eef5;
  --muted: #8b9aae;
  --blue: #1478c8;
  --cyan: #36b6cf;
  --purple: #805ad5;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 1320px;
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 45% 5%, rgba(16, 65, 92, 0.25), transparent 26%),
    linear-gradient(180deg, #02080e 0%, #01050a 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

input,
select,
button {
  min-height: 30px;
  border: 1px solid var(--line2);
  border-radius: 3px;
  color: var(--text);
  background: #06101b;
  outline: none;
}

input,
select {
  width: 100%;
  padding: 6px 9px;
}

button {
  padding: 5px 10px;
  color: var(--gold2);
}

input:focus,
select:focus,
button:hover {
  border-color: var(--gold);
}

.page {
  width: min(1500px, calc(100vw - 20px));
  margin: 0 auto;
  padding: 10px 0 18px;
}

.lol-shell {
  display: grid;
  gap: 9px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  height: 52px;
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--gold3);
  color: var(--gold2);
  font-family: Georgia, serif;
  font-size: 34px;
  font-weight: 800;
  background: radial-gradient(circle at 60% 30%, rgba(229, 192, 106, 0.25), rgba(5, 17, 28, 0.9));
}

h1 {
  margin: 0;
  color: #f2d899;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0;
}

.topbar-controls {
  display: grid;
  grid-template-columns: repeat(3, 92px) 170px 42px;
  gap: 10px;
  align-items: center;
}

.gear-button {
  overflow: hidden;
  text-indent: -999px;
  position: relative;
}

.gear-button::after {
  content: "*";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--gold2);
  text-indent: 0;
  font-size: 22px;
}

.calculator-grid {
  display: grid;
  grid-template-columns: 325px minmax(520px, 1fr) 540px;
  grid-template-areas:
    "champion skills result"
    "items items target"
    "runes runes graph";
  gap: 9px;
}

.frame {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(10, 35, 54, 0.88), rgba(2, 10, 18, 0.96)),
    var(--panel);
  box-shadow: inset 0 0 22px rgba(6, 33, 52, 0.8);
  overflow: hidden;
}

.frame-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 14px;
  color: var(--gold2);
  font-size: 14px;
  font-weight: 900;
}

.frame-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.champion-panel { grid-area: champion; }
.skill-panel { grid-area: skills; }
.result-panel { grid-area: result; }
.selected-loadout { grid-area: items; }
.target-panel { grid-area: target; }
.rune-panel { grid-area: runes; }
.graph-panel { grid-area: graph; }

.champion-hero {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 14px;
  align-items: center;
  padding: 10px 16px 6px;
}

.champion-hero img {
  width: 72px;
  height: 72px;
  border: 2px solid var(--gold3);
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 18px rgba(200, 148, 46, 0.24);
}

.champion-hero label {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.basic-rune-setting {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-top: 2px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.basic-rune-setting button {
  min-height: 38px;
  text-align: left;
}

.champion-list {
  display: none;
}

.stat-grid {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 8px 18px 14px;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 78px;
  gap: 9px;
  align-items: center;
  min-height: 28px;
}

.stat-row dt {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #dce6ef;
  font-size: 13px;
}

.stat-row dd {
  margin: 0;
  padding: 4px 8px;
  border: 1px solid rgba(135, 157, 184, 0.22);
  border-radius: 3px;
  color: #f2f5fa;
  background: rgba(2, 9, 15, 0.72);
  text-align: left;
  font-size: 13px;
}

.stat-icon {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 5px rgba(200, 148, 46, 0.28));
}

.stat-icon path:first-child {
  fill: rgba(255, 255, 255, 0.03);
}

.stat-icon-ad { color: #d89d36; }
.stat-icon-ap { color: #9b61ff; }
.stat-icon-as { color: #d6b33a; }
.stat-icon-crit { color: #e24c42; }
.stat-icon-crit-damage { color: #f06a2f; }
.stat-icon-armor-pen { color: #c65a62; }
.stat-icon-magic-pen { color: #a65cff; }
.stat-icon-haste { color: #c6c1b3; }
.stat-icon-ms { color: #d79f35; }

.skill-budget {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  margin: 0 12px 8px;
  padding: 8px 10px;
  border: 1px solid var(--line2);
  color: var(--muted);
  background: rgba(2, 9, 15, 0.55);
  font-size: 12px;
}

.skill-budget strong {
  color: var(--gold2);
}

.skill-table,
.table-scroll table {
  width: 100%;
  border-collapse: collapse;
}

.skill-table {
  margin: 0 10px 12px;
  width: calc(100% - 20px);
}

.skill-table th,
.skill-table td,
.table-scroll th,
.table-scroll td {
  border: 1px solid rgba(82, 106, 130, 0.28);
  padding: 7px 8px;
  color: #dce6ef;
  text-align: center;
  font-size: 12px;
}

.skill-table th,
.table-scroll th {
  color: #b9c3cf;
  background: rgba(2, 9, 15, 0.68);
  font-weight: 700;
}

.skill-table td:nth-child(2) {
  text-align: left;
}

.skill-table strong {
  display: inline-block;
  margin-right: 7px;
  color: var(--gold2);
}

.skill-table span {
  color: #dce6ef;
}

.skill-icon {
  width: 30px;
  height: 30px;
  border: 1px solid var(--gold3);
}

.skill-stepper {
  display: grid;
  grid-template-columns: 24px 38px 24px;
  gap: 4px;
}

.skill-stepper button {
  min-height: 24px;
  padding: 0;
}

.rank-input {
  min-height: 24px;
  padding: 2px;
  text-align: center;
}

.rank-cap {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.loadout-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(84px, 1fr));
  gap: 14px;
  padding: 8px 22px 12px;
}

.item-slot {
  display: grid;
  grid-template-rows: 62px auto;
  justify-items: center;
  gap: 5px;
  min-height: 94px;
  border: 1px solid rgba(86, 112, 137, 0.23);
  border-radius: 3px;
  color: var(--gold2);
  background: rgba(3, 11, 18, 0.64);
}

.item-slot.empty {
  display: grid;
  place-items: center;
  color: rgba(229, 192, 106, 0.65);
}

.item-slot.filled {
  border-color: var(--line);
}

.item-slot img {
  width: 58px;
  height: 58px;
  margin-top: 6px;
  border: 1px solid var(--gold3);
}

.item-slot span {
  width: 100%;
  padding: 0 6px 4px;
  overflow: hidden;
  color: #dce6ef;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.item-stat-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 0 22px 12px;
}

.item-stat-card,
.item-effect-card {
  min-height: 120px;
  border: 1px solid var(--line2);
  padding: 12px;
  background: rgba(2, 9, 15, 0.45);
}

.item-stat-card h3,
.item-effect-card h3,
.shop-selected h3 {
  margin: 0 0 10px;
  color: var(--gold2);
  font-size: 13px;
}

.item-stat-card div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin: 6px 0;
  color: #cdd6e0;
  font-size: 12px;
}

.item-stat-card strong {
  color: #f1e2b5;
}

.item-effect-card ul {
  margin: 0;
  padding-left: 18px;
  color: #e2b557;
  font-size: 12px;
  line-height: 1.6;
}

.target-layout {
  display: grid;
  grid-template-columns: 1fr 175px;
  gap: 18px;
  padding: 12px 18px 14px;
}

.target-controls {
  display: grid;
  gap: 8px;
}

.target-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line2);
}

.target-tabs button {
  border: 0;
  border-radius: 0;
}

.target-tabs .active {
  color: var(--gold2);
  background: rgba(229, 192, 106, 0.12);
}

.target-controls label {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
  align-items: center;
  color: #dce6ef;
  font-size: 12px;
}

.target-art {
  display: grid;
  place-items: center;
  min-height: 170px;
  border: 1px solid var(--line2);
  color: rgba(229, 192, 106, 0.55);
  background: radial-gradient(circle, rgba(84, 101, 48, 0.55), rgba(2, 9, 15, 0.85));
  font-weight: 900;
}

.rune-selector {
  display: grid;
  gap: 12px;
  padding: 18px 24px 10px;
}

.rune-selector button {
  min-height: 58px;
  border: 0;
  border-left: 1px solid var(--line2);
  padding: 8px 14px;
  text-align: left;
  background: transparent;
}

.rune-selector button.active strong,
.open-rune-settings strong {
  color: var(--gold2);
}

.rune-selector strong {
  display: block;
  margin-bottom: 7px;
  color: #dce6ef;
}

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

.selected-rune-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.selected-rune-pills span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--line2);
  border-radius: 999px;
  color: #dce6ef;
  background: rgba(0, 0, 0, 0.18);
}

.selected-rune-pills img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

.selected-rune-pills em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.rune-total {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 0 28px 20px;
  color: #dce6ef;
  font-size: 13px;
}

.rune-total strong {
  color: var(--gold2);
}

.rune-modal[hidden] { display: none; }

.rune-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
}

.rune-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.68);
}

.rune-modal-panel {
  position: relative;
  width: min(1180px, 96vw);
  max-height: 92vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(10, 35, 54, 0.98), rgba(2, 10, 18, 0.99));
  overflow: hidden;
}

.rune-modal-header,
.rune-modal-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line2);
}

.rune-modal-header h2 {
  margin: 0;
  color: var(--gold2);
  font-size: 18px;
}

.rune-modal-footer {
  grid-template-columns: 150px 150px;
  justify-content: end;
  border-top: 1px solid var(--line2);
  border-bottom: 0;
}

.rune-modal-body {
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 12px;
  padding: 14px;
}

.rune-tree {
  border: 1px solid var(--line2);
  border-radius: 6px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.22);
}

.rune-tree header {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  color: var(--gold2);
}

.rune-tree header img {
  width: 32px;
  height: 32px;
}

.rune-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  padding: 9px 0;
  border-top: 1px solid var(--line2);
}

.rune-choice {
  min-height: 92px;
  display: grid;
  grid-template-rows: 34px auto auto;
  justify-items: center;
  gap: 4px;
  padding: 7px 5px;
}

.rune-choice img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  filter: grayscale(0.85);
  opacity: 0.65;
}

.rune-choice span,
.rune-choice small {
  width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rune-choice.active {
  border-color: var(--gold2);
  background: rgba(229, 192, 106, 0.14);
}

.rune-choice.active img {
  filter: none;
  opacity: 1;
}

.rune-choice.active span {
  color: #f1e2b5;
}

#resultSummary {
  padding: 10px 16px 14px;
}

.result-hero {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: end;
  padding: 8px 0 14px;
  border-bottom: 1px solid var(--line2);
}

.result-hero span {
  color: #dce6ef;
  font-size: 16px;
  font-weight: 700;
}

.result-hero strong {
  color: #f0ca72;
  font-size: 66px;
  line-height: 0.9;
  text-shadow: 0 0 22px rgba(229, 192, 106, 0.25);
}

.result-hero em {
  padding-bottom: 8px;
  color: #f1e2b5;
  font-style: normal;
  font-weight: 800;
}

.dps-bars {
  display: grid;
  gap: 10px;
  padding: 13px 0;
}

.dps-bar-row {
  display: grid;
  grid-template-columns: 130px 72px 58px 1fr;
  gap: 12px;
  align-items: center;
  color: #dce6ef;
  font-size: 12px;
}

.dps-bar-row strong {
  color: #e0a92f;
}

.dps-bar-row em {
  color: #dce6ef;
  font-style: normal;
}

.dps-bar-row i {
  height: 10px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(22, 37, 52, 0.78);
}

.dps-bar-row b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #c99023, #e1b446);
}

.result-bottom {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 8px;
  border-top: 1px solid var(--line2);
}

.result-bottom div {
  display: grid;
  gap: 5px;
  padding: 12px 10px;
  border-left: 1px solid var(--line2);
  text-align: center;
}

.result-bottom div:first-child {
  border-left: 0;
}

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

.result-bottom strong {
  color: #f2e6cc;
  font-size: 18px;
}

.graph-panel canvas {
  display: block;
  width: calc(100% - 28px);
  height: 230px;
  margin: 0 14px 10px;
  border: 1px solid var(--line2);
  background: #06101b;
}

.graph-panel #breakdownTable {
  padding: 0 14px 12px;
}

.shop-panel {
  min-height: 430px;
}

.shop-heading {
  display: grid;
  grid-template-columns: 1fr 140px;
  align-items: center;
}

.shop-heading .frame-title {
  padding-left: 14px;
}

.shop-heading button {
  margin-right: 14px;
}

.shop-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  padding: 0 16px 16px;
}

.shop-tools {
  padding: 0 0 10px;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 10px;
}

.category-tabs button {
  min-width: 62px;
  min-height: 30px;
}

.category-tabs .active {
  border-color: var(--gold);
  color: #10140c;
  background: linear-gradient(180deg, #d6b257, #9e761e);
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 10px;
  max-height: 300px;
  overflow: auto;
  padding-right: 8px;
}

.item-count {
  grid-column: 1 / -1;
  padding: 5px 8px;
  border: 1px solid var(--line2);
  color: var(--gold2);
  background: rgba(2, 9, 15, 0.5);
  font-size: 12px;
  font-weight: 800;
}

.item-grid button {
  display: grid;
  grid-template-rows: 48px 1fr auto;
  justify-items: center;
  min-height: 86px;
  border: 1px solid rgba(120, 146, 170, 0.25);
  padding: 6px;
  background: rgba(2, 9, 15, 0.66);
}

.item-grid button:hover {
  border-color: var(--gold);
}

.item-grid img {
  width: 46px;
  height: 46px;
  border: 1px solid var(--gold3);
}

.item-grid span {
  width: 100%;
  overflow: hidden;
  color: #dce6ef;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.item-tooltip {
  position: fixed;
  z-index: 1000;
  width: min(360px, calc(100vw - 24px));
  max-height: min(620px, calc(100vh - 24px));
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(200, 155, 60, 0.55);
  border-radius: 8px;
  background: rgba(7, 17, 31, 0.98);
  color: #f5e6b8;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.item-tooltip[hidden] {
  display: none;
}

.item-tooltip-head {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.item-tooltip-head img {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  border: 1px solid rgba(200, 155, 60, 0.45);
}

.item-tooltip-head strong {
  display: block;
  color: #fff1bf;
  font-size: 1rem;
}

.item-tooltip-head span,
.item-tooltip-section span,
.item-tooltip-section em {
  color: #b9c3d6;
  font-style: normal;
}

.item-tooltip p {
  margin: 8px 0 12px;
  color: #d9deea;
  line-height: 1.45;
}

.item-tooltip-section {
  border-top: 1px solid rgba(200, 155, 60, 0.22);
  padding-top: 10px;
  margin-top: 10px;
}

.item-tooltip-section h4 {
  margin: 0 0 8px;
  color: #c89b3c;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.item-tooltip-section dl,
.item-tooltip-section ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
}

.item-tooltip-section li {
  display: grid;
  gap: 4px;
  list-style: none;
}

.item-tooltip-section dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.item-tooltip-section dt {
  color: #b9c3d6;
}

.item-tooltip-section dd {
  margin: 0;
  color: #f5e6b8;
}

.item-tooltip code {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #f0d98b;
  white-space: normal;
}

.shop-selected {
  border-left: 1px solid var(--line2);
  padding-left: 16px;
}

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

.shop-selected-grid .item-slot {
  min-height: 86px;
  border-style: dashed;
}

.event-panel {
  display: none;
}

.table-scroll {
  max-height: 220px;
  overflow: auto;
}

.table-scroll td,
.table-scroll th {
  font-size: 11px;
}

.table-scroll td:not(:first-child),
.table-scroll th:not(:first-child) {
  text-align: right;
}

.empty-note {
  grid-column: 1 / -1;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1320px) {
  body {
    min-width: 0;
  }

  .page {
    width: calc(100vw - 16px);
  }

  .calculator-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "champion"
      "skills"
      "result"
      "items"
      "target"
      "runes"
      "graph";
  }

  .shop-layout {
    grid-template-columns: 1fr;
  }
}
