/* ── Reset & Base ─────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a1a0a;
  --surface: #0f2b0f;
  --surface2: #152e15;
  --border: #1e4020;
  --border2: #2a5c2a;
  --accent: #4ade80;
  --accent2: #22c55e;
  --accent-dim: #166534;
  --text: #e2f5e2;
  --text-muted: #6b9b6b;
  --danger: #ef4444;
  --yellow: #facc15;
  --radius: 8px;
  --radius-sm: 5px;
  --sidebar-w: 220px;
  --titlebar-h: 42px;
  --transition: 0.18s ease;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 12px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 4px;
}

/* ── Title Bar ────────────────────────────────────────────── */
.title-bar {
  height: var(--titlebar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  background: rgba(9, 20, 9, 0.95);
  border-bottom: 1px solid var(--border);
  -webkit-app-region: drag;
  flex-shrink: 0;
  gap: 8px;
  backdrop-filter: blur(12px);
}

.title-bar-left,
.title-bar-right,
.title-bar-center {
  display: flex;
  align-items: center;
  gap: 6px;
  -webkit-app-region: no-drag;
}

.title-bar-left {
  flex: 0 0 auto;
}

.title-bar-center {
  flex: 1;
  justify-content: center;
}

.title-bar-right {
  flex: 0 0 auto;
}

.app-logo svg {
  display: block;
}

.app-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* Pitch selector buttons */
.pitch-selector {
  display: flex;
  gap: 3px;
}

.pitch-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 10px;
  font-weight: 500;
  font-family: inherit;
  transition: all var(--transition);
  white-space: nowrap;
}

.pitch-btn:hover {
  border-color: var(--border2);
  color: var(--text);
}

.pitch-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Title bar action buttons */
.tb-action-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.tb-action-btn:hover {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text);
}

.tb-action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.tb-export-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
  transition: all var(--transition);
}

.tb-export-btn:hover {
  background: var(--accent);
  color: #0a1a0a;
}

.tb-separator {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 3px;
}

/* Window controls */
.wc-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: all var(--transition);
}

.wc-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.wc-close:hover {
  background: var(--danger);
  color: #fff;
}

/* ── App Body ─────────────────────────────────────────────── */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: rgba(9, 20, 9, 0.97);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 0 12px;
}

.panel {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.panel:last-child {
  border-bottom: none;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Tool grid */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 9px;
  font-family: inherit;
  transition: all var(--transition);
}

.tool-btn:hover {
  border-color: var(--border2);
  color: var(--text);
}

.tool-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.tool-btn span {
  display: block;
  text-align: center;
  line-height: 1.1;
}

/* Equipment grid */
.equip-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.equip-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 9px;
  font-family: inherit;
  transition: all var(--transition);
}

.equip-btn:hover {
  border-color: var(--border2);
  color: var(--text);
}

.equip-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cone-icon::before {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 16px solid #f97316;
}

.ball-icon::before {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff, #aaaaaa);
  box-shadow: 0 0 0 2px #555;
}

.mannequin-icon::before {
  content: '';
  display: block;
  width: 6px;
  height: 18px;
  background: #f59e0b;
  border-radius: 3px;
  box-shadow: 0 0 0 2px #78350f;
}

.minigoal-icon::before {
  content: '';
  display: block;
  width: 18px;
  height: 12px;
  border: 2px solid #94a3b8;
  border-bottom: none;
  border-radius: 1px 1px 0 0;
}

.hurdle-icon::before {
  content: '';
  display: block;
  width: 16px;
  height: 10px;
  border: 3px solid #f87171;
  border-bottom: none;
  border-radius: 2px 2px 0 0;
}

.ladder-icon::before {
  content: '';
  display: block;
  width: 8px;
  height: 20px;
  border-left: 2px solid #facc15;
  border-right: 2px solid #facc15;
  background: repeating-linear-gradient(0deg, transparent, transparent 4px, #facc15 4px, #facc15 6px);
}

.rebounder-icon::before {
  content: '';
  display: block;
  width: 16px;
  height: 6px;
  background: #38bdf8;
  border-radius: 2px;
  box-shadow: 0 4px 0 -2px #0ea5e9;
}

.fullgoal-icon::before {
  content: '';
  display: block;
  width: 22px;
  height: 10px;
  border: 2px solid #ffffff;
  border-bottom: none;
  background: repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(255, 255, 255, 0.3) 2px, rgba(255, 255, 255, 0.3) 4px);
}

.flatcone-icon::before {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, transparent 20%, #f97316 25%);
}

.ring-icon::before {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid #4ade80;
}

.slalompole-icon::before {
  content: '';
  display: block;
  width: 4px;
  height: 20px;
  background: repeating-linear-gradient(0deg, #facc15, #facc15 4px, #000 4px, #000 8px);
  border-radius: 2px;
}

.straightpole-icon::before {
  content: '';
  display: block;
  width: 4px;
  height: 20px;
  background: #ffffff;
  border-radius: 2px;
}

/* Draw style */
.style-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.style-row label {
  color: var(--text-muted);
  width: 44px;
  flex-shrink: 0;
  font-size: 10px;
}

.style-row input[type="color"] {
  width: 26px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid var(--border2);
  padding: 1px;
  background: var(--surface2);
  cursor: pointer;
}

.style-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 3px;
}

.style-row select {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  font-size: 10px;
  font-family: inherit;
}

.style-row span {
  color: var(--text-muted);
  font-size: 10px;
  width: 28px;
  text-align: right;
}

/* Formation grid */
.formation-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.form-btn {
  padding: 5px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  transition: all var(--transition);
}

.form-btn:hover {
  border-color: var(--border2);
  color: var(--text);
}

.form-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.form-team-opts {
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-team-opts label {
  color: var(--text-muted);
  font-size: 10px;
}

.form-team-opts select {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 3px 4px;
  font-size: 10px;
  font-family: inherit;
}

/* Pitch theme */
.pitch-theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.theme-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 4px;
  color: var(--text-muted);
  font-size: 9px;
  font-family: inherit;
  transition: all var(--transition);
}

.theme-btn:hover {
  border-color: var(--border2);
}

.theme-btn.active {
  border-color: var(--accent);
}

.theme-swatch {
  width: 100%;
  height: 24px;
  border-radius: 3px;
}

/* Session */
.session-row {
  margin-bottom: 6px;
  display: flex;
  gap: 4px;
}

.session-row input[type="text"] {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 4px 7px;
  font-size: 11px;
  font-family: inherit;
}

.session-row input[type="text"]::placeholder {
  color: var(--text-muted);
}

.session-row input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.sess-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 10px;
  font-family: inherit;
  font-weight: 600;
  transition: all var(--transition);
}

.sess-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 6px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 10px;
  transition: all var(--transition);
}

.session-item:hover {
  border-color: var(--border2);
  color: var(--accent);
}

.session-item-del {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
  transition: color var(--transition);
}

.session-item-del:hover {
  color: var(--danger);
}

/* ── Canvas Area ──────────────────────────────────────────── */
.canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(74, 222, 128, 0.04) 0%, transparent 60%),
    var(--bg);
  position: relative;
  overflow: hidden;
}

#pitchCanvas {
  cursor: crosshair;
  display: block;
  border-radius: 4px;
  box-shadow:
    0 0 0 1px rgba(74, 222, 128, 0.15),
    0 8px 40px rgba(0, 0, 0, 0.6),
    0 0 80px rgba(74, 222, 128, 0.04);
}

/* ── Context Menu ─────────────────────────────────────────── */
.context-menu {
  display: none;
  position: absolute;
  background: rgba(10, 26, 10, 0.97);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  min-width: 150px;
  overflow: hidden;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
}

.context-menu button {
  display: block;
  width: 100%;
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  text-align: left;
  transition: background var(--transition);
}

.context-menu button:last-child {
  border-bottom: none;
}

.context-menu button:hover {
  background: var(--surface2);
}

/* ── Rename Overlay ───────────────────────────────────────── */
.rename-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.rename-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 20px 24px;
  min-width: 240px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rename-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.rename-box input {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  font-size: 12px;
  font-family: inherit;
}

.rename-box input:focus {
  outline: none;
  border-color: var(--accent);
}

.rename-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.rename-actions button {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  transition: all var(--transition);
}

.rename-actions button:hover {
  border-color: var(--border2);
  color: var(--text);
}

.rename-actions button.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.rename-actions button.primary:hover {
  background: var(--accent);
  color: #0a1a0a;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast-container {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 3000;
  pointer-events: none;
}

.toast {
  padding: 8px 18px;
  background: rgba(15, 43, 15, 0.96);
  border: 1px solid var(--accent);
  border-radius: 20px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
  animation: toastIn 0.25s ease, toastOut 0.3s ease 2s forwards;
  backdrop-filter: blur(8px);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}