:root {
  color-scheme: light;
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --surface-strong: #202329;
  --text: #1d2128;
  --muted: #66707d;
  --line: #d9dee6;
  --orange: #f47c12;
  --orange-strong: #d96200;
  --orange-soft: #fff0df;
  --graphite: #292d34;
  --ice: #e9f4ff;
  --blue: #2563a8;
  --success: #147a55;
  --danger: #b42318;
  --shadow: 0 18px 44px rgba(26, 30, 36, 0.14);
  --shadow-soft: 0 10px 24px rgba(26, 30, 36, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(145deg, rgba(244, 124, 18, 0.22), rgba(238, 241, 244, 0.96) 34%, rgba(41, 45, 52, 0.28)),
    var(--bg);
  color: var(--text);
  overscroll-behavior-y: contain;
}

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

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 11px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(244, 124, 18, 0.16);
}

textarea {
  min-height: 108px;
  resize: vertical;
}

a {
  color: var(--blue);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: 0;
}

.app-shell {
  min-height: 100vh;
}

.auth-page,
.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 18px;
}

.auth-hero,
.topbar {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: linear-gradient(110deg, rgba(29, 33, 40, 0.98), rgba(58, 62, 70, 0.94));
  box-shadow: var(--shadow);
  color: #fff;
}

.auth-hero {
  display: grid;
  gap: 16px;
  padding: 18px;
  animation: fade-up 280ms ease both;
}

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

.brand-lockup-large {
  gap: 16px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 24px rgba(244, 124, 18, 0.28);
  overflow: hidden;
}

.brand-lockup-large .brand-mark {
  width: 112px;
  height: 112px;
}

.brand-mark img {
  width: 118%;
  height: 118%;
  object-fit: contain;
}

.brand-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.brand-copy strong,
.brand-copy h1 {
  color: #fff;
}

.brand-copy p {
  max-width: 700px;
  color: #dde4ed;
}

.eyebrow {
  color: #ff9a22;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-pills,
.tag-row,
.actions,
.nav-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 12px;
  backdrop-filter: blur(16px);
  animation: fade-up 240ms ease both;
}

.pull-refresh {
  display: none;
}

.muted {
  color: var(--muted);
}

.topbar .muted {
  color: #cbd3dd;
}

.auth-grid,
.dashboard-grid,
.profile-grid {
  display: grid;
  gap: 16px;
  align-items: start;
}

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

.dashboard-grid {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.55fr);
}

.profile-grid {
  grid-template-columns: minmax(0, 0.5fr) minmax(0, 1fr);
}

.stack {
  display: grid;
  gap: 16px;
}

.panel,
.item-card,
.modal {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-soft);
}

.panel {
  padding: 18px;
  animation: fade-up 280ms ease both;
}

.panel:nth-child(2) {
  animation-delay: 45ms;
}

.panel:nth-child(3) {
  animation-delay: 90ms;
}

.panel-header,
.item-line,
.modal-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-header {
  margin-bottom: 14px;
}

.dashboard-head {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  animation: fade-up 220ms ease both;
}

.dashboard-head p {
  max-width: 740px;
}

.form-grid,
.list,
.detail-content {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.unit-field {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.unit-field input,
.unit-field select {
  min-width: 0;
}

.unit-field input {
  flex: 1 1 auto;
}

.unit-field select {
  width: auto;
  flex: 0 1 160px;
}

.unit-field button {
  flex: 0 0 auto;
}

.btn-primary {
  background: linear-gradient(180deg, #ff9a22, var(--orange));
  color: #191b20;
  box-shadow: 0 8px 18px rgba(244, 124, 18, 0.24);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #ffad48, var(--orange-strong));
}

.btn-secondary {
  background: var(--graphite);
  color: #fff;
}

.btn-secondary:hover {
  background: #15181d;
}

.btn-ghost {
  background: #edf1f5;
  color: var(--text);
}

.btn-ghost:hover {
  background: #fff3e7;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--orange);
  color: var(--orange-strong);
}

.topbar .btn-ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.topbar .btn-outline {
  border-color: rgba(255, 154, 34, 0.75);
  color: #ffad48;
}

.topbar .btn-secondary {
  background: #fff;
  color: #1d2128;
}

.topbar .btn-ghost.is-active {
  background: rgba(255, 154, 34, 0.95);
  color: #191b20;
}

.banner {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface-soft);
  color: var(--text);
  animation: fade-up 200ms ease both;
}

.banner.error {
  border-color: rgba(180, 35, 24, 0.34);
  background: #fff1f0;
  color: var(--danger);
}

.banner.success {
  border-color: rgba(20, 122, 85, 0.34);
  background: #e7f7ef;
  color: var(--success);
}

.notification-preview {
  display: grid;
  gap: 5px;
  border: 1px solid rgba(244, 124, 18, 0.28);
  border-radius: 8px;
  padding: 12px;
  background: var(--orange-soft);
  color: var(--text);
}

.notification-preview span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.item-card {
  padding: 14px;
  box-shadow: none;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.item-card:hover {
  border-color: rgba(244, 124, 18, 0.36);
  box-shadow: 0 10px 20px rgba(26, 30, 36, 0.09);
  transform: translateY(-1px);
}

.tag-row {
  margin-top: 9px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: var(--orange-soft);
  color: #a84600;
  font-size: 12px;
  font-weight: 900;
}

.tag.blue {
  background: var(--ice);
  color: var(--blue);
}

.tag.danger {
  background: #fff1f0;
  color: var(--danger);
}

.tag.dark {
  background: #343942;
  color: #fff;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.68);
}

.checkbox-list {
  display: grid;
  gap: 8px;
  max-height: 210px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.check-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.check-grid input {
  width: 18px;
  min-height: 18px;
  flex: 0 0 auto;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
}

.coach-command-panel,
.linked-players-panel {
  display: grid;
  gap: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric-tile {
  display: grid;
  gap: 4px;
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(180deg, #fff, var(--surface-soft));
}

.metric-tile span {
  font-size: 28px;
  font-weight: 950;
  line-height: 1;
}

.metric-tile small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.command-actions {
  margin-top: 2px;
}

.team-management-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.34fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.team-list-panel {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 14px;
}

.team-card-list,
.team-detail-stack,
.team-roster-list {
  display: grid;
  gap: 10px;
}

.team-card {
  display: grid;
  width: 100%;
  min-height: 92px;
  justify-items: stretch;
  gap: 10px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--team-accent, var(--orange));
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--text);
  text-align: left;
  box-shadow: none;
}

.team-card:hover {
  border-color: rgba(244, 124, 18, 0.42);
  box-shadow: var(--shadow-soft);
}

.team-card.is-selected {
  border-color: var(--orange);
  background: var(--orange-soft);
}

.team-card strong {
  display: block;
  font-size: 16px;
}

.team-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.team-card-tags,
.mobile-team-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.create-team-details {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.create-team-details summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 900;
}

.create-team-details .form-grid {
  margin-top: 12px;
}

.team-detail-hero .panel-header {
  align-items: flex-start;
}

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

.team-member-form {
  width: 100%;
  margin-bottom: 12px;
}

.team-member-form select {
  flex: 1 1 260px;
}

.team-detail-hero,
.team-ops-panel {
  border-color: color-mix(in srgb, var(--team-accent, var(--orange)) 34%, var(--line));
}

.team-detail-hero {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--team-accent, var(--orange)) 14%, transparent), transparent 54%),
    var(--team-surface, rgba(255, 255, 255, 0.95));
  color: var(--team-text, var(--text));
}

.team-detail-hero .muted {
  color: color-mix(in srgb, var(--team-text, var(--text)) 68%, transparent);
}

.team-ops-panel {
  display: grid;
  gap: 14px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--team-accent, var(--orange)) 9%, transparent), transparent 38%),
    rgba(255, 255, 255, 0.96);
}

.team-settings-strip {
  display: grid;
  grid-template-columns: minmax(140px, 0.32fr) minmax(150px, 0.32fr) max-content;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.compact-field input[type="color"] {
  min-height: 42px;
  padding: 4px;
}

.operations-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.42fr);
  gap: 16px;
  align-items: start;
}

.operations-grid > * {
  min-width: 0;
}

.ops-subsection,
.compact-panel {
  display: grid;
  gap: 12px;
}

.ops-tool {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.ops-tool .split-fields {
  grid-template-columns: minmax(0, 1fr);
}

.ops-tool .field,
.ops-tool input,
.ops-tool select,
.ops-tool textarea {
  min-width: 0;
}

.section-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.event-list,
.protocol-list,
.attendance-board {
  display: grid;
  gap: 10px;
}

.event-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--team-accent, var(--orange));
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.event-card-head,
.attendance-form {
  display: grid;
  gap: 10px;
}

.event-card-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.attendance-current {
  display: grid;
  place-items: center;
  min-width: 72px;
  min-height: 44px;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 950;
}

.attendance-current.yes {
  background: #e7f7ef;
  color: var(--success);
}

.attendance-current.no {
  background: #fff1f0;
  color: var(--danger);
}

.attendance-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

.attendance-form-label,
.attendance-buttons,
.stats-toolbar,
.match-compact,
.token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.attendance-buttons button {
  flex: 1 1 88px;
}

.danger-soft {
  color: var(--danger);
}

.event-details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.event-details summary {
  cursor: pointer;
  font-weight: 900;
}

.stats-toolbar {
  align-items: stretch;
}

.stats-toolbar select,
.stats-toolbar input {
  width: auto;
  min-width: 132px;
}

.stats-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stats-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

.stats-table th,
.stats-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
}

.stats-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.attendance-mark {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid var(--line);
  border-radius: 999px;
  font-weight: 950;
}

.attendance-mark.yes {
  border-color: rgba(20, 122, 85, 0.28);
  background: #e7f7ef;
  color: var(--success);
}

.attendance-mark.no {
  border-color: rgba(180, 35, 24, 0.28);
  background: #fff1f0;
  color: var(--danger);
}

.event-kind-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 4px;
  vertical-align: -2px;
}

.event-kind-icon.training {
  background: linear-gradient(180deg, var(--orange), #ffd18f);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.event-kind-icon.match {
  border: 3px solid var(--blue);
  border-radius: 999px;
}

.calendar-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.calendar-day-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.calendar-day-card summary {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-weight: 900;
}

.match-compact {
  padding: 10px;
  border-radius: 8px;
  background: var(--ice);
  color: var(--blue);
  font-size: 13px;
}

.lineup-board {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.lineup-zone {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-height: 210px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  padding: 18px;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.16), transparent 22%),
    linear-gradient(90deg, transparent 49.5%, rgba(255, 255, 255, 0.34) 49.5%, rgba(255, 255, 255, 0.34) 50.5%, transparent 50.5%),
    #3f8f5b;
}

.lineup-zone span,
.player-token {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  border: 2px solid #fff;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--team-accent, var(--orange));
  color: #16181d;
  font-size: 12px;
  font-weight: 950;
  text-align: center;
}

.lineup-zone .goalie {
  grid-column: 2;
  background: #f7f9fb;
  color: var(--text);
}

.special-teams,
.lineup-position-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.special-teams > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

.diamond-tokens {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

.diamond-tokens .player-token:nth-child(1),
.diamond-tokens .player-token:nth-child(4) {
  grid-column: 2;
}

.diamond-tokens .player-token:nth-child(2) {
  grid-column: 1;
}

.diamond-tokens .player-token:nth-child(3) {
  grid-column: 3;
}

.lineup-editor {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.lineup-editor fieldset {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.lineup-editor legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.lineup-position-grid label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.assistant-block {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.protocol-form,
.protocol-edit-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.protocol-edit-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.protocol-stats {
  min-width: 420px;
}

.tag.urgent {
  background: #fff1f0;
  color: var(--danger);
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 900;
  text-decoration: none;
}

.btn-link:hover {
  background: var(--orange-soft);
}

.admin-grid {
  display: grid;
  gap: 16px;
}

.admin-history summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-size: 20px;
  font-weight: 900;
}

.admin-history-list {
  margin-top: 14px;
}

.approval-actions,
.inline-form,
.mini-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.approval-actions {
  flex-wrap: wrap;
  margin-top: 12px;
}

.inline-form {
  flex: 0 1 auto;
}

.decline-form {
  flex: 1 1 320px;
}

.inline-form input,
.inline-form select {
  min-width: 180px;
}

.decline-form input {
  min-width: min(100%, 260px);
}

.mini-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.mini-row {
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface-soft);
}

.compact-empty {
  margin-top: 12px;
  padding: 10px;
}

.approval-panel {
  display: grid;
  gap: 12px;
}

.media-frame {
  border: 1px solid #1d2128;
  border-radius: 8px;
  background: #15181d;
  overflow: hidden;
}

.media-frame img,
.media-frame video {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  background: #0e1116;
}

.board-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: 260px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background: #1d2128;
  touch-action: none;
}

.board-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.board-stage {
  min-width: 0;
  border: 1px solid #111827;
  border-radius: 8px;
  padding: 8px;
  background: #111827;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.board-control-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.75fr) minmax(0, 1.1fr);
  gap: 12px;
  align-items: end;
}

.board-tool-row,
.board-color-row,
.board-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.board-tool-row .is-active {
  background: var(--orange);
  color: #191b20;
}

.board-color {
  width: 38px;
  min-height: 38px;
  border: 2px solid #fff;
  border-radius: 999px;
  padding: 0;
  background: var(--swatch);
  box-shadow: 0 0 0 1px var(--line);
}

.board-color.is-active {
  box-shadow: 0 0 0 3px rgba(244, 124, 18, 0.36);
}

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

.panel-soft {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.board-camera-toggle {
  justify-content: flex-start;
}

.board-recording-preview {
  width: 100%;
  border-radius: 8px;
  background: #111827;
}

.folder-create-form,
.media-move-form {
  margin: 12px 0;
  width: 100%;
}

.folder-create-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(132px, 0.65fr) max-content;
}

.media-move-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
}

.folder-create-form input,
.folder-create-form select,
.media-move-form select {
  min-width: 0;
}

.folder-create-form button,
.media-move-form button {
  white-space: nowrap;
}

.folder-tree,
.folder-children,
.folder-media-list {
  display: grid;
  gap: 10px;
}

.folder-tree {
  margin-top: 12px;
}

.folder-children {
  margin: 10px 0 0 16px;
  padding-left: 12px;
  border-left: 2px solid var(--line);
}

.folder-node {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  overflow: hidden;
}

.folder-node summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  font-weight: 900;
  cursor: pointer;
}

.folder-node > .folder-media-list,
.folder-node > .folder-children,
.folder-node > .compact-empty {
  padding: 0 12px 12px;
}

.chat-modal {
  width: min(720px, 100%);
}

.chat-window {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #f7f9fb, #eef3f6);
}

.chat-message {
  display: flex;
}

.chat-message.is-own {
  justify-content: flex-end;
}

.chat-bubble {
  width: min(82%, 460px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.chat-message.is-own .chat-bubble {
  border-color: rgba(244, 124, 18, 0.38);
  background: var(--orange-soft);
}

.chat-bubble p {
  margin-top: 4px;
  white-space: pre-wrap;
}

.chat-bubble span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
  align-items: end;
}

.timestamp-capture,
.comment-timestamp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.timestamp-capture {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.timestamp-capture img,
.comment-timestamp-row img {
  width: 96px;
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
  background: #111827;
}

.comment-timestamp-row {
  margin-top: 8px;
}

.timestamp-link {
  min-height: 32px;
  border: 1px solid rgba(37, 99, 168, 0.24);
  background: var(--ice);
  color: var(--blue);
}

.modal-wide {
  width: min(1280px, 100%);
}

.video-analysis-panel,
.analysis-controls {
  display: grid;
  gap: 14px;
}

.analysis-playback-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-soft);
}

.analysis-playback-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.analysis-stage-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.7fr);
  gap: 14px;
  align-items: start;
}

.analysis-video-shell {
  position: relative;
  min-width: 0;
  aspect-ratio: 16 / 9;
  border: 1px solid #111827;
  border-radius: 8px;
  overflow: hidden;
  background: #0e1116;
}

.analysis-video-shell video,
.analysis-video-shell canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.analysis-video-shell video {
  object-fit: contain;
  background: #0e1116;
}

.analysis-video-shell canvas {
  touch-action: none;
  z-index: 2;
}

.analysis-readonly .analysis-video-shell canvas {
  pointer-events: none;
}

.analysis-side-board {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.analysis-side-board .board-canvas {
  min-height: 180px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 14, 18, 0.64);
}

.modal {
  width: min(940px, 100%);
  max-height: min(820px, calc(100vh - 48px));
  overflow-x: hidden;
  overflow-y: auto;
  padding: 20px;
  animation: pop-in 180ms ease both;
}

.modal-title-row {
  margin-bottom: 16px;
}

.hidden {
  display: none !important;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 920px) {
  h1 {
    font-size: 36px;
  }

  .auth-grid,
  .dashboard-grid,
  .profile-grid,
  .split-fields,
  .analysis-stage-grid,
  .board-control-grid,
  .board-publish-grid,
  .team-management-grid,
  .team-section-grid,
  .operations-grid,
  .special-teams,
  .lineup-position-grid {
    grid-template-columns: 1fr;
  }

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

  .team-list-panel {
    position: static;
  }

  .topbar,
  .item-line,
  .modal-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-row,
  .actions,
  .board-tool-row,
  .board-actions {
    width: 100%;
  }

  .nav-row button,
  .actions button,
  .board-tool-row button,
  .attendance-buttons button {
    flex: 1 1 150px;
  }
}

@media (max-width: 1180px) {
  .folder-create-form,
  .media-move-form,
  .team-settings-strip {
    grid-template-columns: minmax(0, 1fr);
  }

  .folder-create-form button,
  .media-move-form button,
  .team-settings-strip button {
    width: 100%;
  }
}

@media (max-width: 620px) {
  body {
    background:
      linear-gradient(160deg, rgba(244, 124, 18, 0.18), rgba(238, 241, 244, 0.98) 42%, rgba(41, 45, 52, 0.18)),
      var(--bg);
  }

  h1 {
    font-size: 30px;
  }

  h2 {
    font-size: 21px;
  }

  .auth-page,
  .page {
    width: min(100% - 18px, 1180px);
    padding: 12px 0;
  }

  .auth-hero,
  .topbar,
  .panel,
  .modal {
    padding: 14px;
  }

  .brand-lockup,
  .brand-lockup-large {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-lockup-large .brand-mark {
    width: 92px;
    height: 92px;
  }

  .brand-mark {
    width: 50px;
    height: 50px;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .modal {
    max-height: calc(100vh - 20px);
  }

  .approval-actions,
  .inline-form,
  .mini-row,
  .team-member-form,
  .event-card-head,
  .section-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-form,
  .inline-form input,
  .inline-form select,
  .inline-form button,
  .mini-row button,
  .team-member-form select,
  .stats-toolbar select,
  .stats-toolbar input {
    width: 100%;
  }

  .event-card-head,
  .lineup-zone {
    grid-template-columns: 1fr;
  }

  .unit-field {
    align-items: stretch;
    flex-direction: column;
  }

  .unit-field select,
  .unit-field button {
    flex-basis: auto;
    width: 100%;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .metric-tile {
    min-height: 64px;
  }

  .team-card {
    min-height: 84px;
  }

  .board-stage {
    padding: 5px;
  }

  .board-canvas {
    min-height: 190px;
  }

  .board-color-row {
    justify-content: space-between;
  }

  .board-color {
    width: 34px;
    min-height: 34px;
  }

  .chat-compose {
    grid-template-columns: 1fr;
  }

  .chat-bubble {
    width: 100%;
  }

  .folder-children {
    margin-left: 4px;
    padding-left: 8px;
  }

  .analysis-side-board .board-canvas {
    min-height: 170px;
  }

  .analysis-playback-row {
    grid-template-columns: 1fr;
  }

  .timestamp-capture img,
  .comment-timestamp-row img {
    width: 84px;
    height: 48px;
  }
}

@media (max-width: 700px) {
  .page {
    padding-top: calc(110px + env(safe-area-inset-top, 0px));
  }

  .page::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: auto;
    z-index: 29;
    width: 100vw;
    height: calc(110px + env(safe-area-inset-top, 0px));
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 10px 28px rgba(18, 22, 28, 0.08);
    pointer-events: none;
  }

  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: auto;
    z-index: 30;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    margin: 0;
    width: 100vw;
    border-top: 0;
    border-right: 0;
    border-left: 0;
    border-radius: 0 0 8px 8px;
    padding:
      calc(10px + env(safe-area-inset-top, 0px))
      max(12px, env(safe-area-inset-right, 0px))
      10px
      max(12px, env(safe-area-inset-left, 0px));
    transition: padding 180ms ease, box-shadow 180ms ease, background 180ms ease, transform 180ms ease;
  }

  .topbar .brand-lockup {
    align-items: center;
    flex-direction: row;
    min-width: 0;
  }

  .topbar .brand-mark {
    width: 42px;
    height: 42px;
    transition: width 180ms ease, height 180ms ease, box-shadow 180ms ease;
  }

  .topbar .brand-copy {
    overflow: hidden;
  }

  .topbar .brand-copy strong {
    display: block;
    overflow: hidden;
    font-size: 15px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar .brand-copy .muted {
    display: block;
    overflow: hidden;
    max-height: 18px;
    font-size: 12px;
    line-height: 1.2;
    opacity: 1;
    transition: max-height 180ms ease, opacity 180ms ease, transform 180ms ease;
  }

  .topbar .nav-row {
    flex-wrap: nowrap;
    gap: 7px;
    width: 100%;
    margin: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding-bottom: 1px;
    scrollbar-width: none;
  }

  .topbar .nav-row::-webkit-scrollbar {
    display: none;
  }

  .topbar .nav-row button {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0 11px;
    font-size: 13px;
    white-space: nowrap;
  }

  body.is-scrolled .topbar {
    padding:
      calc(7px + env(safe-area-inset-top, 0px))
      max(12px, env(safe-area-inset-right, 0px))
      7px
      max(12px, env(safe-area-inset-left, 0px));
    background: linear-gradient(110deg, rgba(24, 27, 33, 0.98), rgba(45, 49, 57, 0.96));
    box-shadow: 0 10px 28px rgba(18, 22, 28, 0.22);
  }

  body.is-scrolled .topbar .brand-mark {
    width: 32px;
    height: 32px;
    box-shadow: 0 6px 16px rgba(244, 124, 18, 0.18);
  }

  body.is-scrolled .topbar .brand-copy strong {
    font-size: 14px;
  }

  body.is-scrolled .topbar .brand-copy .muted {
    max-height: 0;
    opacity: 0;
    transform: translateY(-4px);
  }

  body.is-scrolled .topbar .nav-row button {
    min-height: 32px;
  }

  .pull-refresh {
    --pull-distance: 0px;
    --pull-offset: -48px;
    --pull-opacity: 0;
    position: fixed;
    top: calc(10px + env(safe-area-inset-top, 0px));
    left: 50%;
    z-index: 40;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    padding: 0 13px;
    background: rgba(29, 33, 40, 0.95);
    color: #fff;
    box-shadow: var(--shadow-soft);
    font-size: 13px;
    font-weight: 800;
    opacity: var(--pull-opacity);
    pointer-events: none;
    transform: translate(-50%, var(--pull-offset));
    transition: opacity 120ms ease, transform 120ms ease;
  }

  .pull-refresh-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: var(--orange);
    border-radius: 50%;
  }

  .pull-refresh[data-state="refreshing"] .pull-refresh-spinner {
    animation: spin 720ms linear infinite;
  }

  .pull-refresh[data-state="ready"] {
    background: rgba(244, 124, 18, 0.98);
    color: #191b20;
  }

  .team-head {
    margin-top: 8px;
  }

  .team-management-grid {
    gap: 12px;
  }

  .team-detail-stack,
  .team-card-list {
    gap: 12px;
  }

  .mobile-team-actions {
    position: sticky;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    z-index: 12;
    flex-wrap: nowrap;
    margin-top: 12px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow-soft);
    scrollbar-width: none;
  }

  .mobile-team-actions::-webkit-scrollbar {
    display: none;
  }

  .mobile-team-actions .btn-link {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
