:root {
  --bg: #020617;
  --bg-alt: #0b1120;
  --panel: #020617;
  --panel-alt: #0f172a;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.2);
  --accent2: #3b82f6;
  --accent2-soft: rgba(59, 130, 246, 0.15);
  --danger: #ef4444;
  --warning: #f59e0b;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #1f2937;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #0f172a, #020617 60%);
}

/* Layout */

body {
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(15,23,42,0.95), rgba(8,47,73,0.9));
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  margin: 0;
  font-size: 1.4rem;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.header-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  font-size: 0.85rem;
}

.header-right label {
  display: flex;
  flex-direction: column;
  background: rgba(15,23,42,0.8);
  border-radius: 6px;
  padding: 4px 6px;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.header-right input {
  margin-top: 2px;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid rgba(148,163,184,0.5);
  background: #020617;
  color: var(--text);
  font-size: 0.8rem;
}

.app-main {
  flex: 1;
  display: flex;
  gap: 12px;
  padding: 12px;
}

.left-panel,
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.left-panel {
  flex: 1;
  min-width: 320px;
}

.right-panel {
  flex: 1.3;
  min-width: 320px;
}

.card {
  background: radial-gradient(circle at top left, #020617, #030712 60%);
  border-radius: 10px;
  border: 1px solid rgba(31, 41, 55, 0.9);
  padding: 10px 12px;
  box-shadow: 0 18px 45px rgba(0,0,0,0.55);
}

.card h2 {
  margin-top: 0;
  font-size: 1rem;
}

.card h3 {
  margin-top: 0;
  font-size: 0.95rem;
}

/* Clock */

.clock-display {
  font-size: 2.4rem;
  font-weight: 700;
  text-align: center;
  padding: 8px 0;
  margin-bottom: 8px;
  background: radial-gradient(circle at top, rgba(15,118,110,0.35), rgba(15,23,42,1));
  border-radius: 10px;
  border: 1px solid rgba(34,197,94,0.45);
  letter-spacing: 0.08em;
}

.clock-controls {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 4px;
}

/* Scoreboard */

.scoreboard {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.team {
  flex: 1;
  background: radial-gradient(circle at top, rgba(15,23,42,0.9), rgba(3,7,18,1));
  border-radius: 8px;
  padding: 8px;
  border: 1px solid rgba(31,41,55,0.9);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.team span {
  font-size: 0.9rem;
  color: var(--muted);
}

.score {
  font-size: 1.8rem;
  font-weight: 700;
}

.goal-btn {
  margin-top: 2px;
}

/* Goals list */

.goals-list-wrapper {
  max-height: 170px;
  overflow: auto;
  border-top: 1px dashed var(--border);
  padding-top: 6px;
}

.goals-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
}

.goals-list li {
  padding: 4px 0;
  border-bottom: 1px dashed rgba(30,64,175,0.4);
}

/* Buttons */

button {
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: #020617;
  color: var(--text);
  padding: 6px 10px;
  font-size: 0.85rem;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

button:hover {
  background: #020617;
  border-color: var(--accent2);
}

button:active {
  transform: scale(0.97);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), #16a34a);
  border-color: rgba(34,197,94,0.8);
  color: #052e16;
  font-weight: 600;
}

.primary-btn:hover {
  background: linear-gradient(135deg, #16a34a, #22c55e);
}

.icon-btn {
  align-self: flex-start;
  padding: 6px;
  min-width: 36px;
}

/* Form fields */

.field-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.field-row label {
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.field-row input,
.field-row select,
.field-row textarea {
  padding: 5px 7px;
  border-radius: 5px;
  border: 1px solid rgba(55,65,81,0.9);
  background: #020617;
  color: var(--text);
  font-size: 0.85rem;
}

textarea {
  resize: vertical;
}

.flex-1 {
  flex: 1;
}

/* Tabs */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.tab-btn {
  flex: 1;
  padding: 6px 4px;
  font-size: 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(55,65,81,0.9);
  background: #020617;
}

.tab-btn.active {
  background: radial-gradient(circle at top left, var(--accent-soft), rgba(15,23,42,1));
  border-color: rgba(34,197,94,0.95);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Events list */

.events-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 220px;
  overflow: auto;
  font-size: 0.85rem;
}

.events-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid transparent;
  margin-bottom: 4px;
}

.events-list li .event-main {
  display: flex;
  flex-direction: column;
}

.events-list li .event-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.events-list li button {
  font-size: 0.75rem;
}

.events-list li.selected {
  background: var(--accent2-soft);
  border-color: rgba(59,130,246,0.8);
}

/* Notes container */

.notes-container {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #020617;
  padding: 6px;
  max-height: 260px;
  overflow: auto;
  font-size: 0.85rem;
}

.empty-state {
  color: var(--muted);
}

.note-item {
  border-bottom: 1px solid rgba(31,41,55,0.8);
  padding: 4px 2px;
}

.note-header {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  font-size: 0.8rem;
}

.note-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.note-tag {
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid rgba(75,85,99,0.9);
  font-size: 0.7rem;
}

.note-severity-Ubetydelig {
  border-color: var(--muted);
}

.note-severity-Middels {
  border-color: var(--warning);
  color: var(--warning);
}

.note-severity-Kritisk {
  border-color: var(--danger);
  color: var(--danger);
}

.note-body {
  margin-top: 3px;
}

/* Pitch */

.pitch-wrapper {
  width: 100%;
  position: relative;
}

.pitch {
  position: relative;
  width: 100%;
  padding-top: 60%;
  background: radial-gradient(circle at center, #052e16, #022c22);
  border-radius: 12px;
  border: 2px solid #22c55e;
  overflow: hidden;
}

/* Enkel banemarkering */
.pitch::before,
.pitch::after {
  content: "";
  position: absolute;
  inset: 8%;
  border: 1px solid rgba(74,222,128,0.6);
  border-radius: 6px;
}

.pitch::after {
  left: 50%;
  right: 50%;
  border-left: 1px solid rgba(74,222,128,0.7);
  border-top: none;
  border-bottom: none;
  border-right: none;
}

.pitch-entity,
.pitch-pin {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  user-select: none;
}

.pitch-entity {
  background: rgba(15,23,42,0.95);
  border: 2px solid rgba(59,130,246,0.9);
}

.pitch-pin {
  background: var(--accent);
  color: #052e16;
  border: 2px solid #16a34a;
}

/* Split layout */

.split-layout {
  display: flex;
  gap: 8px;
}

.split-left,
.split-right {
  flex: 1;
}

/* Debrief canvas */

.draw-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-bottom: 4px;
  font-size: 0.8rem;
}

.draw-tool-btn {
  font-size: 0.75rem;
  padding: 4px 8px;
}

.draw-tool-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

#debriefCanvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
  border: 2px solid rgba(34,197,94,0.7);
  background: radial-gradient(circle at center, #052e16, #022c22);
}

/* Debrief */

.debrief-comment-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
  font-size: 0.85rem;
}

/* Rapport */

.report-preview {
  margin-top: 8px;
  max-height: 260px;
  overflow: auto;
  background: #020617;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 8px;
  font-size: 0.8rem;
}

/* Misc */

.small-text {
  font-size: 0.75rem;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(15,23,42,0.9);
  border: 1px solid rgba(148,163,184,0.6);
  font-size: 0.75rem;
}

/* Footer */

.app-footer {
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
  background: #020617;
}

/* Responsivitet */

@media (max-width: 960px) {
  .app-main {
    flex-direction: column;
  }

  .split-layout {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-right {
    width: 100%;
    justify-content: flex-start;
  }
}
