:root {
  --topbar-height: 72px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  background: #0f172a;
}

.app-shell {
  height: 100dvh;
  width: 100vw;
  display: grid;
  grid-template-rows: auto 1fr;
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.topbar {
  min-height: var(--topbar-height);
  padding: 0.5rem 1rem;
  gap: 1rem;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  min-width: 120px;
}

.app-title {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.title-main {
  font-weight: 800;
  font-size: 1.05rem;
}

.title-sub {
  font-size: 0.78rem;
  opacity: 0.65;
}

.topbar-fields {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.field-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.field-chip > span {
  font-size: 0.75rem;
  opacity: 0.75;
}

.field-chip select {
  max-width: 260px;
}

.main-stage {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 0.75rem;
  padding: 0.75rem;
  padding-bottom: calc(0.75rem + var(--safe-bottom));
}

.rink-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 1.25rem;
  background: radial-gradient(circle at center, rgba(148, 163, 184, 0.16), rgba(15, 23, 42, 0.85));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

#rink-svg {
  width: min(100%, calc((100dvh - var(--safe-top) - var(--safe-bottom) - 2rem) * 1));
  height: auto;
  max-width: 100%;
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 2rem);
  display: block;
  user-select: none;
  -webkit-user-select: none;
}

.shot-zone {
  fill: rgba(59, 130, 246, 0.01);
  stroke: rgba(255, 255, 255, 0.01);
  cursor: pointer;
  transition: fill 120ms ease, stroke 120ms ease, filter 120ms ease;
}

.shot-zone:hover,
.shot-zone:focus,
.shot-zone.active {
  fill: rgba(59, 130, 246, 0.22);
  stroke: rgba(59, 130, 246, 0.85);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.35));
}

.shot-zone[data-zone-id="central_close"]:hover,
.shot-zone[data-zone-id="central_close"]:focus,
.shot-zone[data-zone-id="central_close"].active {
  stroke: transparent;
  filter: none;
}

.event-marker {
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  transform-origin: center;
  animation: marker-pop 180ms ease-out;
  cursor: pointer;
}

.event-marker.no-animate {
  animation: none;
}

.event-marker.shot {
  fill: rgba(59, 130, 246, 0.9);
}

.event-marker.goal {
  fill: rgba(34, 197, 94, 0.95);
}

@keyframes marker-pop {
  from { opacity: 0; transform: scale(0.4); }
  to { opacity: 1; transform: scale(1); }
}

.side-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: auto;
  border-radius: 1.25rem;
  background: rgba(2, 6, 23, 0.82);
  color: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  padding: 0.75rem;
}

.selection-card {
  display: grid;
  gap: 0.55rem;
  padding: 0.75rem;
  border-radius: 1rem;
  background: rgba(15, 23, 42, 0.72);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.16);
}

.selection-pickers {
  display: grid;
  gap: 0.55rem;
}

.selection-accordion {
  display: grid;
  gap: 0.55rem;
}

.selection-accordion > summary {
  list-style: none;
}

.selection-accordion > summary::-webkit-details-marker {
  display: none;
}

.selection-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 0.75rem;
  row-gap: 0.1rem;
  align-items: center;
  padding: 0.82rem 0.9rem;
  border-radius: 0.9rem;
  background: rgba(30, 41, 59, 0.9);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
  text-align: left;
  cursor: pointer;
}

.selection-row > .selection-kicker {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

.selection-row > strong {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  font-size: 0.98rem;
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-kicker {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.selection-chevron {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 1.05rem;
  height: 1.05rem;
  color: #cbd5e1;
  transition: transform 140ms ease;
}

.selection-row.is-open .selection-chevron {
  transform: rotate(180deg);
}

.selection-accordion:not([open]) .selection-picker {
  display: none;
}

.selection-picker {
  display: grid;
  gap: 0.7rem;
  padding: 0.6rem 0.75rem 0.35rem;
  border-radius: 0.85rem;
  background: rgba(15, 23, 42, 0.84);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.14);
}

.selection-option {
  width: 100%;
  display: block;
  padding: 0.65rem 0.75rem;
  border-radius: 0.75rem;
  background: rgba(30, 41, 59, 0.92);
  color: #f8fafc;
  text-align: left;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.09);
  transition: transform 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.selection-option:hover,
.selection-option:focus,
.selection-option.is-selected {
  background: rgba(51, 65, 85, 0.98);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.24);
}

.selection-option.is-selected {
  color: #ffffff;
}

.selection-option-register {
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 118, 110, 0.24);
  font-weight: 700;
}

.selection-empty {
  padding: 0.35rem 0.15rem 0.25rem;
  font-size: 0.85rem;
  color: #94a3b8;
}

.selection-hidden {
  display: none;
}

.registry-modal {
  max-width: min(94vw, 980px);
}

.registry-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.registry-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.registry-create-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.registry-create {
  display: grid;
  gap: 0.55rem;
}

.registry-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 0.75rem;
  margin-top: 1rem;
}

.registry-panel {
  min-height: 0;
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: 0.95rem;
  background: rgba(15, 23, 42, 0.72);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.16);
}

.registry-panel-header {
  display: grid;
  gap: 0.15rem;
}

.registry-list {
  display: grid;
  gap: 0.45rem;
  max-height: 55vh;
  overflow: auto;
  padding-right: 0.1rem;
}

.registry-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border-radius: 0.8rem;
  background: rgba(30, 41, 59, 0.92);
  color: #f8fafc;
  text-align: left;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.1);
}

.registry-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.registry-item span {
  color: #cbd5e1;
  white-space: nowrap;
}

.registry-item.is-active {
  background: rgba(37, 99, 235, 0.32);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.3);
}

.registry-check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem;
  border-radius: 0.8rem;
  background: rgba(30, 41, 59, 0.9);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.1);
}

.registry-check input {
  width: 1rem;
  height: 1rem;
  accent-color: #60a5fa;
}

.event-feed {
  display: grid;
  gap: 0.75rem;
  min-height: 0;
  flex: 1 1 auto;
}

.selection-field {
  display: grid;
  gap: 0.35rem;
}

.selection-field > span {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #cbd5e1;
}

.selection-field input,
.selection-field select,
.selection-field textarea {
  width: 100%;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.settings-grid-buttons {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-help {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  opacity: 0.72;
}

.side-panel .stat-title,
.side-panel .stat-value,
.side-panel .event-card,
.side-panel .event-card strong,
.side-panel .event-card span,
.side-panel .event-card small,
.side-panel .empty-text {
  color: inherit;
}

.side-panel .stat-title,
.side-panel .event-card span,
.side-panel .event-card small,
.side-panel .empty-text {
  color: #cbd5e1;
}

.side-panel .stat-value,
.side-panel .event-card strong {
  color: #f8fafc;
}

.compact-stats {
  width: 100%;
  margin-bottom: 0.75rem;
}

.event-list {
  display: grid;
  gap: 0.5rem;
}

.event-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-radius: 0.9rem;
  background: rgba(15, 23, 42, 0.82);
  border-left: 0.35rem solid rgba(59, 130, 246, 0.9);
  cursor: pointer;
}

.event-card.event-goal {
  border-left-color: rgba(34, 197, 94, 0.95);
}

.event-card-body {
  display: grid;
  gap: 0.1rem;
}

.event-card-meta {
  display: grid;
  justify-items: end;
  gap: 0.35rem;
  padding-top: 0.15rem;
}

.event-card span,
.event-card small {
  opacity: 1;
}

.event-comment-icon {
  display: inline-flex;
  width: 1rem;
  height: 1rem;
  margin-left: 0.35rem;
  vertical-align: -0.1em;
  opacity: 0.85;
}

.event-comment-icon svg {
  width: 100%;
  height: 100%;
}

.event-card:hover,
.event-card:focus {
  outline: none;
  background: rgba(17, 24, 39, 0.92);
  box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.22);
}

.empty-text {
  opacity: 0.65;
  padding: 0.75rem;
}

.fab-top-right {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 1rem);
  right: calc(var(--safe-right) + 1rem);
  z-index: 30;
}

.event-modal,
.settings-modal {
  max-width: min(92vw, 520px);
}

.modal-subtitle {
  margin: 0.25rem 0 1rem;
  opacity: 0.7;
}

.event-actions {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

#save-event-button {
  grid-column: 1 / -1;
}

.settings-section {
  margin-top: 1rem;
  display: grid;
  gap: 0.5rem;
}

.settings-section h3 {
  font-weight: 700;
}

.settings-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.settings-row input {
  flex: 1 1 160px;
}

@media (max-width: 700px) {
  .settings-grid,
  .settings-grid-buttons,
  .registry-create-grid,
  .registry-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .fab-top-right {
    bottom: calc(var(--safe-bottom) + 1rem);
    right: calc(var(--safe-right) + 1rem);
  }
}



/* Local fallback for DaisyUI/Tailwind classes used by the app. */
*, *::before, *::after {
  box-sizing: border-box;
}

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

button {
  margin: 0;
  border: 0;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.w-full { width: 100%; }
.w-24 { width: 6rem; }
.h-20 { height: 5rem; }
.h-36 { height: 9rem; }
.mb-4 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.font-bold { font-weight: 700; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.resize-none { resize: none; }
.gap-2 { gap: 0.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }

.btn,
.input,
.select,
.textarea {
  min-height: 2.75rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
  padding: 0.75rem 0.9rem;
}

.input,
.select,
.textarea {
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.06);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  font-weight: 700;
}

.btn svg {
  width: 1.5rem;
  height: 1.5rem;
  flex: 0 0 auto;
}

.btn:hover,
.btn:focus-visible {
  filter: brightness(1.08);
}

.btn-primary { background: #2563eb; color: #ffffff; }
.btn-secondary { background: #475569; color: #ffffff; }
.btn-success { background: #16a34a; color: #ffffff; }
.btn-error { background: #dc2626; color: #ffffff; }
.btn-sm { min-height: 2.2rem; padding: 0.55rem 0.8rem; font-size: 0.92rem; }
.btn-lg { min-height: 3.25rem; padding: 0.9rem 1.1rem; font-size: 1rem; }
.btn-circle {
  width: 3.25rem;
  min-width: 3.25rem;
  padding: 0;
  border-radius: 999px;
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #cbd5e1 50%), linear-gradient(135deg, #cbd5e1 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.5rem;
}

.textarea {
  min-height: 5rem;
}

.modal {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  max-width: none;
  max-height: none;
}

.modal::backdrop {
  background: rgba(2, 6, 23, 0.72);
}

.modal-box {
  width: min(92vw, 44rem);
  margin: auto;
  border-radius: 1rem;
  background: #0f172a;
  color: #f8fafc;
  padding: 1.25rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.modal-action {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.modal-backdrop {
  display: none;
}

.tooltip {
  position: relative;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(51, 65, 85, 0.9);
  color: #f8fafc;
  font-size: 0.75rem;
  line-height: 1;
}

.stat {
  display: grid;
  gap: 0.15rem;
  padding: 0.85rem 0.9rem;
  border-radius: 0.85rem;
  background: rgba(15, 23, 42, 0.82);
}

.stat-title {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
}

.size-6 {
  width: 1.5rem;
  height: 1.5rem;
}

@media (orientation: portrait) {
  .main-stage {
    grid-template-columns: 1fr;
  }

  .side-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(180px, 0.85fr);
    align-items: start;
  }

  .selection-card {
    grid-column: 2;
    grid-row: 1;
  }

  .event-feed {
    grid-column: 1;
    grid-row: 1;
  }

  #rink-svg {
    width: 100%;
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 1.5rem);
  }
}
