﻿:root {
  --bg: #090b14;
  --panel: #111528;
  --panel-2: #161d34;
  --line: rgba(255, 255, 255, 0.1);
  --text: #e9edf9;
  --muted: #9ba4c5;
  --purple: #a368ff;
  --green: #3ce9b3;
  --danger: #f05a7e;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 5%, rgba(163, 104, 255, 0.2) 0%, transparent 42%),
    radial-gradient(circle at 80% 15%, rgba(60, 233, 179, 0.13) 0%, transparent 38%),
    linear-gradient(160deg, #06070f 0%, #0a0e1b 40%, #0b1220 100%);
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  padding: 0;
  min-height: 100vh;
  height: 100vh;
  width: 100vw;
}

@supports (height: 100dvh) {
  .app-shell {
    min-height: 100dvh;
    height: 100dvh;
  }
}

.sidebar {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}

.panel-head h1 {
  margin: 0;
  letter-spacing: 0.06em;
  font-size: 1.2rem;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.panel-block {
  background: linear-gradient(180deg, rgba(22, 29, 52, 0.8), rgba(16, 21, 40, 0.75));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px;
}

.panel-block h2 {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: var(--green);
}

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

label {
  font-size: 0.8rem;
  color: var(--muted);
}

select,
input[type="range"],
.action-grid button,
.tool-btn {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(8, 12, 22, 0.65);
  padding: 9px 10px;
}

select:focus,
input:focus,
button:focus {
  outline: 2px solid rgba(163, 104, 255, 0.5);
  outline-offset: 1px;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.tool-btn {
  cursor: pointer;
  font-size: 0.84rem;
}

.tool-btn.is-active {
  border-color: rgba(163, 104, 255, 0.8);
  background: linear-gradient(180deg, rgba(163, 104, 255, 0.35), rgba(163, 104, 255, 0.18));
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.action-grid button {
  cursor: pointer;
  font-size: 0.82rem;
}

.action-grid .danger {
  border-color: rgba(240, 90, 126, 0.55);
  background: rgba(240, 90, 126, 0.18);
}

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

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

.palette-item {
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 6px;
  background: rgba(7, 11, 20, 0.72);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.palette-item:active {
  cursor: grabbing;
}

.palette-item .icon-shell {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.palette-item img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  pointer-events: none;
}

.palette-item .icon-fallback {
  font-size: 0.72rem;
  font-weight: 700;
  color: #dbe4ff;
}

.palette-item .item-name {
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.1;
}

.sidebar-foot {
  margin-top: auto;
}

.sidebar-foot p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

kbd {
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 4px;
  background: rgba(255, 255, 255, 0.05);
}

.board-panel {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0;
  min-height: 100%;
  height: 100%;
}

.board-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100%;
  --board-toolbar-base-height: 74px;
  --board-toolbar-top-height: calc(var(--board-toolbar-base-height) + env(safe-area-inset-top, 0px));
  --board-toolbar-bottom-height: calc(var(--board-toolbar-base-height) + env(safe-area-inset-bottom, 0px));
  border-radius: 0;
  border: none;
  background:
    linear-gradient(
      165deg,
      rgba(33, 18, 56, 0.98) 0%,
      rgba(25, 15, 43, 0.98) 45%,
      rgba(18, 11, 32, 0.98) 100%
    );
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  overflow: hidden;
  touch-action: none;
}

.board-stage.mode-add-arrow {
  cursor: crosshair;
}

.board-stage.mode-pan {
  cursor: grab;
}

.board-stage.mode-pan.is-panning {
  cursor: grabbing;
}

.board-viewport {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--board-toolbar-top-height);
  bottom: var(--board-toolbar-bottom-height);
  overflow-x: auto;
  overflow-y: auto;
  scrollbar-gutter: stable both-edges;
  touch-action: none;
}

#mapImage,
.smoke-layer,
.arrow-layer,
.token-layer {
  position: absolute;
  inset: 0;
}

#mapImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

.arrow-layer {
  z-index: 30;
}

.smoke-layer {
  z-index: 20;
  pointer-events: none;
}

.token-layer {
  z-index: 40;
  pointer-events: none;
}

.board-toolbar {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  display: flex;
  align-items: center;
  padding: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(
      90deg,
      rgba(76, 30, 130, 0.88) 0%,
      rgba(99, 40, 170, 0.9) 45%,
      rgba(123, 58, 205, 0.88) 100%
    );
  backdrop-filter: blur(6px);
  z-index: 70;
}

.board-toolbar-top {
  top: 0;
  height: var(--board-toolbar-top-height);
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  padding-bottom: 8px;
}

.board-toolbar-bottom {
  bottom: 0;
  height: var(--board-toolbar-bottom-height);
  padding-top: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.strategy-badge-wrap {
  position: absolute;
  top: calc(var(--board-toolbar-top-height) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 68;
  pointer-events: auto;
}

.strategy-badge-input {
  width: min(74vw, 320px);
  height: 34px;
  border: 1px solid rgba(163, 104, 255, 0.48);
  border-radius: 999px;
  background: rgba(22, 12, 39, 0.86);
  color: #f2ecff;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  padding: 0 12px;
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.35),
    0 0 16px rgba(163, 104, 255, 0.18);
}

.strategy-badge-input::placeholder {
  color: rgba(228, 217, 255, 0.62);
}

.board-toolbar-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  gap: 8px;
  padding: 0 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.board-toolbar .tool-btn {
  width: auto;
  flex: 0 0 auto;
  min-width: 92px;
  min-height: 56px;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 7px 8px;
  border-radius: 12px;
}

.map-select-inline {
  width: auto;
  min-width: 170px;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(8, 12, 22, 0.68);
  color: var(--text);
  padding: 0 10px;
  flex: 0 0 auto;
}

.player-add-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
}

.player-add-dot-ally {
  border-color: rgba(60, 233, 179, 0.95);
  background: rgba(60, 233, 179, 0.35);
  box-shadow:
    0 0 8px rgba(60, 233, 179, 0.62),
    0 0 14px rgba(60, 233, 179, 0.32);
}

.player-add-dot-enemy {
  border-color: rgba(255, 108, 130, 0.96);
  background: rgba(255, 108, 130, 0.35);
  box-shadow:
    0 0 8px rgba(255, 108, 130, 0.62),
    0 0 14px rgba(255, 108, 130, 0.33);
}

.map-tool-btn img {
  width: 19px;
  height: 19px;
  object-fit: contain;
}

.board-toolbar-top .map-tool-btn img {
  filter: brightness(0) invert(1);
}

.map-tool-btn span {
  font-size: 0.66rem;
  line-height: 1;
}

.brand-link-btn {
  min-width: 56px;
  min-height: 56px;
  text-decoration: none;
  display: grid;
  place-items: center;
  padding: 6px;
}

.brand-link-btn img {
  width: 28px;
  height: 28px;
}

.board-toolbar-top .brand-link-btn img {
  filter: none;
}

.quick-item-btn {
  flex: 0 0 auto;
  min-width: 70px;
  min-height: 52px;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(8, 12, 22, 0.7);
  color: var(--text);
  cursor: pointer;
  touch-action: pan-x;
  user-select: none;
}

#topAddAllyBtn,
#topAddEnemyBtn {
  touch-action: pan-x;
  user-select: none;
}

.quick-item-btn img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  pointer-events: none;
}

.quick-item-btn .quick-name {
  font-size: 0.62rem;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
}

.quick-item-btn .quick-fallback {
  font-size: 0.65rem;
  font-weight: 700;
}

.quick-items-inline {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
}

.quick-divider {
  align-self: center;
  width: 1px;
  height: 34px;
  margin: 0 4px;
  background: linear-gradient(
    180deg,
    rgba(163, 104, 255, 0.15),
    rgba(163, 104, 255, 0.7),
    rgba(60, 233, 179, 0.7),
    rgba(60, 233, 179, 0.15)
  );
  border-radius: 999px;
  flex: 0 0 auto;
}

.board-item {
  position: absolute;
  transform: translate(-50%, -50%);
  touch-action: none;
  user-select: none;
  pointer-events: auto;
}

.token {
  display: grid;
  gap: 2px;
  place-items: center;
}

.token-main {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(10, 14, 24, 0.8);
  display: grid;
  place-items: center;
  position: relative;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
  transform: scale(var(--item-zoom, 1));
  transform-origin: center center;
}

.token-main-icon {
  width: 46px;
  height: 46px;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.token-main-player {
  width: 16px;
  height: 16px;
}

.token-main img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  pointer-events: none;
}

.token-main-icon img {
  width: 30px;
  height: 30px;
  filter:
    drop-shadow(0 0 1px rgba(163, 104, 255, 0.95))
    drop-shadow(0 0 7px rgba(163, 104, 255, 0.75))
    drop-shadow(0 0 16px rgba(163, 104, 255, 0.38));
}

.token-gadget .token-main-icon img {
  width: 25px;
  height: 25px;
}

.token-utility .token-main-icon img {
  width: 25px;
  height: 25px;
}

.player-badge {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  display: grid;
  place-items: center;
}

.player-badge-ally {
  background: rgba(60, 233, 179, 0.95);
  box-shadow:
    0 0 6px rgba(60, 233, 179, 0.75),
    0 0 12px rgba(60, 233, 179, 0.35);
}

.player-badge-enemy {
  background: rgba(255, 108, 130, 0.96);
  box-shadow:
    0 0 6px rgba(255, 108, 130, 0.75),
    0 0 12px rgba(255, 108, 130, 0.35);
}

.palette-item .player-badge {
  width: 8px;
  height: 8px;
}

.item-text {
  width: 82px;
  max-width: 110px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #f3f6ff;
  text-align: center;
  font-size: 0.55rem;
  font-weight: 600;
  line-height: 1.1;
  padding: 0;
  margin-top: 1px;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.9),
    0 3px 7px rgba(0, 0, 0, 0.55);
}

.item-text::placeholder {
  color: rgba(232, 239, 255, 0.65);
}

.item-text:focus {
  outline: none;
}

.board-item.is-selected .token-main,
.board-item.is-selected .smoke-circle {
  outline: 2px solid rgba(163, 104, 255, 0.85);
  outline-offset: 2px;
}

.board-item.is-selected .token-main-icon {
  outline: none;
  box-shadow: none;
}

.board-item.is-selected .token-main-icon img {
  filter:
    drop-shadow(0 0 2px rgba(163, 104, 255, 1))
    drop-shadow(0 0 10px rgba(163, 104, 255, 0.95))
    drop-shadow(0 0 22px rgba(163, 104, 255, 0.6));
}

.smoke {
  z-index: 5;
}

.smoke-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.26), rgba(200, 210, 228, 0.16) 52%, rgba(160, 166, 178, 0.1) 75%, rgba(120, 120, 135, 0.05));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 0 48px 22px rgba(212, 220, 235, 0.12),
    0 0 120px 56px rgba(196, 205, 224, 0.08);
  backdrop-filter: blur(1.8px);
}

.arrow-line {
  stroke: rgba(194, 236, 255, 0.95);
  stroke-width: 3.5;
  fill: none;
  pointer-events: none;
}

.arrow-hit {
  stroke: rgba(194, 236, 255, 0.01);
  stroke-width: 22;
  fill: none;
  pointer-events: stroke;
  cursor: move;
}

.arrow-label {
  font-size: 12px;
  fill: #e7f1ff;
  paint-order: stroke;
  stroke: rgba(3, 7, 13, 0.9);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.arrow-handle {
  fill: #b8d9ff;
  stroke: #031126;
  stroke-width: 2;
  cursor: pointer;
}

.arrow-group.is-selected .arrow-line {
  stroke: rgba(163, 104, 255, 0.96);
}

.palette-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 999;
  transform: translate(-50%, -50%);
  opacity: 0.9;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(163, 104, 255, 0.75);
  border-radius: 14px;
  background: rgba(14, 19, 35, 0.86);
  display: grid;
  place-items: center;
}

.palette-ghost img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.palette-ghost .ghost-text {
  font-size: 0.72rem;
  font-weight: 700;
}

.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(7, 11, 20, 0.95);
  border: 1px solid rgba(163, 104, 255, 0.55);
  border-radius: 9px;
  font-size: 0.8rem;
  padding: 8px 12px;
  color: #f3f5ff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1000;
}

.toast.is-visible {
  opacity: 1;
}

@media (min-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 0;
    padding: 0;
  }

  .board-panel {
    min-height: 100%;
    height: 100%;
  }

  .board-stage {
    height: 100%;
    min-height: 100%;
  }

  .board-toolbar-row {
    justify-content: center;
  }
}
