/* ==========================================================================
   GolfCoach Pro - Components & Mobile UI Kit
   Bottom Sheets, Steppers, Cards, Radar, Scorecard & Chat
   ========================================================================== */

/* 1. Buttons & Controls */
.ui-icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  flex: 0 0 auto;
  vertical-align: -0.14em;
  color: currentColor;
  overflow: visible;
}

.btn .ui-icon,
.filter-pill .ui-icon {
  width: 1.05rem;
  height: 1.05rem;
}

.brand-badge .ui-icon {
  width: 1.45rem;
  height: 1.45rem;
}

.nav-icon .ui-icon,
.bottom-nav-icon .ui-icon {
  width: 1.2rem;
  height: 1.2rem;
}

.card-icon .ui-icon,
.workspace-context-icon .ui-icon,
.player-avatar .ui-icon {
  width: 1.15rem;
  height: 1.15rem;
}

.topbar-action-icon .ui-icon,
.demo-mode-notice-icon .ui-icon,
.demo-mode-indicator .ui-icon {
  width: 1rem;
  height: 1rem;
}

.badge .ui-icon,
.stat-sub .ui-icon,
.portal-item-meta .ui-icon,
.toast .ui-icon {
  width: 0.9rem;
  height: 0.9rem;
}

.icon-heading {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.reset-step-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.55rem;
  color: var(--text-main);
  font-size: 1rem;
  font-weight: 750;
}

.reset-step-number {
  width: 1.75rem;
  height: 1.75rem;
  display: inline-grid;
  place-items: center;
  flex: 0 0 1.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  color: var(--gold-400);
  background: rgba(212, 175, 55, 0.08);
  font-size: 0.78rem;
}

.ui-icon-copy .ui-icon,
#breathing-instruction-text .ui-icon,
#network-status .ui-icon {
  margin-right: 0.35rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-sm);
  line-height: var(--leading-tight);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  min-height: 44px;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none;
  transform: none;
}

.btn[aria-busy="true"] {
  opacity: 0.82;
}

.btn-spinner {
  width: 1rem;
  height: 1rem;
  flex: 0 0 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: uiSpin 0.7s linear infinite;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
  color: #061c11;
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.25);
}

.btn-primary:hover, .btn-primary:active {
  background: linear-gradient(135deg, var(--gold-fill-400), var(--gold-500));
  color: #061c11;
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  border-color: var(--border-subtle);
  color: var(--text-main);
}

.btn-secondary:hover, .btn-secondary:active {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--gold-400);
  color: var(--gold-400);
}

.btn-green {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  border-color: rgba(98, 199, 148, 0.3);
  color: #ffffff;
}

.btn-green:hover, .btn-green:active {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  box-shadow: var(--shadow-glow);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  min-height: 44px;
}

.btn-lg {
  padding: 0.95rem 1.75rem;
  font-size: 1rem;
}

/* 2. Responsive Grids & Cards */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--layout-gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--layout-gap); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--layout-gap); }

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--card-padding);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-normal), border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.card-gold-glow::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold-500), transparent);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.card-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: rgba(24, 92, 59, 0.35);
  border: 1px solid rgba(98, 199, 148, 0.2);
  color: var(--primary-300);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.card-title {
  font-size: var(--text-md);
  font-weight: 700;
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-tight);
}

/* Shared content rhythm */
.view-hero {
  margin-bottom: var(--section-gap);
}

.dashboard-coach-hero {
  background: radial-gradient(circle at 10% 20%, rgba(24, 92, 59, 0.4) 0%, rgba(18, 25, 21, 0.95) 80%);
}

.view-hero-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-5);
}

.view-heading-copy {
  min-width: 0;
  max-width: 760px;
}

.view-heading-copy h2 {
  margin: 0;
  font-size: var(--text-xl);
}

.view-heading-copy p {
  max-width: 680px;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
}

.view-kicker-row,
.view-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.view-kicker-row {
  margin-bottom: var(--space-2);
}

.view-actions {
  justify-content: flex-end;
}

.view-actions .btn {
  min-height: 44px;
}

.layout-section {
  margin-bottom: var(--section-gap);
}

.content-stack {
  display: flex;
  flex-direction: column;
  gap: var(--layout-gap);
}

.content-title {
  margin-bottom: var(--space-2);
  font-size: var(--text-md);
}

.content-copy {
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
}

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

/* Skeletons reserve the final layout without inventing real content. */
.loading-skeleton {
  display: block;
}

.skeleton-card,
.skeleton-hero {
  overflow: hidden;
}

.skeleton-card-heading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.skeleton-line,
.skeleton-icon,
.skeleton-action {
  display: block;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.055) 20%, rgba(255, 255, 255, 0.13) 42%, rgba(255, 255, 255, 0.055) 64%);
  background-size: 240% 100%;
  animation: skeletonShimmer 1.35s ease-in-out infinite;
}

[data-theme="light"] .skeleton-line,
[data-theme="light"] .skeleton-icon,
[data-theme="light"] .skeleton-action {
  background-image: linear-gradient(100deg, rgba(16, 66, 41, 0.055) 20%, rgba(16, 66, 41, 0.13) 42%, rgba(16, 66, 41, 0.055) 64%);
}

.skeleton-line {
  width: var(--skeleton-width, 100%);
  max-width: 100%;
  height: 0.72rem;
  margin-top: var(--space-3);
  border-radius: var(--radius-full);
}

.skeleton-line:first-child { margin-top: 0; }
.skeleton-title { height: 0.95rem; margin-top: 0; }
.skeleton-heading { height: 1.45rem; margin-top: var(--space-3); }
.skeleton-kicker { height: 0.62rem; margin-top: 0; }

.skeleton-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: var(--radius-sm);
}

.skeleton-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-5);
  min-height: 132px;
  margin-bottom: var(--section-gap);
}

.skeleton-action {
  width: 148px;
  height: 44px;
  border-radius: var(--radius-md);
}

.skeleton-card {
  min-height: 150px;
}

.skeleton-card-compact {
  min-height: 104px;
}

.skeleton-kpi-grid {
  margin-bottom: var(--section-gap);
}

.skeleton-thread {
  display: flex;
  min-height: 220px;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
}

.skeleton-thread .skeleton-line:nth-child(even) {
  align-self: flex-end;
}

@keyframes skeletonShimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

.insight-grid {
  margin-top: var(--space-4);
}

.insight-card {
  padding: var(--space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
}

.insight-card h4 {
  margin-bottom: var(--space-2);
  color: var(--gold-400);
  font-size: var(--text-md);
  line-height: var(--leading-snug);
}

.insight-card p {
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

/* 3. Stat Cards / KPI Widgets */
.stat-card {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-label {
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--text-subtle);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.1;
}

.stat-sub {
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  color: var(--text-muted);
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.stat-sub.positive { color: var(--color-success); }
.stat-sub.negative { color: var(--color-danger); }
.stat-sub.gold { color: var(--gold-400); }

/* 4. Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  line-height: var(--leading-tight);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.035em;
}

.badge-gold {
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold-400);
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.badge-green {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-blue {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* 5. Custom Radar & Progress Charts */
.radar-container {
  width: 100%;
  height: 260px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.radar-container svg {
  max-width: 100%;
  max-height: 100%;
}

.progress-bar-container {
  width: 100%;
  height: 7px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-500), var(--gold-fill-400));
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 6. Drill Cards & Filter Pills */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.6rem;
  margin-bottom: 1.25rem;
  -webkit-overflow-scrolling: touch;
}

.filter-pill {
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.filter-pill:active {
  transform: scale(0.95);
}

.filter-pill.active {
  background: var(--primary-700);
  border-color: var(--gold-500);
  color: #ffffff;
}

.drill-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-left: 4px solid var(--primary-500);
}

.drill-instructions {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.45;
}

.drill-purpose {
  background: rgba(24, 92, 59, 0.15);
  border: 1px solid rgba(98, 199, 148, 0.2);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--primary-200);
  margin-bottom: 1rem;
}

/* 7. Practice Timer (Pomodoro / Drill mode) */
.timer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: radial-gradient(circle, rgba(16, 66, 41, 0.4) 0%, rgba(18, 25, 21, 0.95) 75%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-gold);
}

.timer-circle {
  width: 190px;
  height: 190px;
  border-radius: 50%;
  border: 4px solid var(--primary-700);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 1.5rem;
}

.timer-display {
  font-size: 3rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--gold-400);
  letter-spacing: -0.03em;
}

.timer-phase {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--primary-300);
  font-weight: 700;
}

.timer-controls {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* 8. Breathing Animator for Mental Fortitude */
.breathing-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 1.25rem;
}

.breathing-circle-wrapper {
  position: relative;
  width: 170px;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1.5rem 0;
}

.breathing-outer-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 2px dashed rgba(212, 175, 55, 0.3);
  border-radius: 50%;
  animation: rotateSlow 24s linear infinite;
}

.breathing-bubble {
  width: 70px;
  height: 70px;
  background: radial-gradient(circle, var(--gold-fill-400), var(--primary-600));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.4);
  transition: transform 4s cubic-bezier(0.4, 0, 0.2, 1);
}

.breathing-bubble.inhale {
  transform: scale(2);
  box-shadow: 0 0 45px rgba(98, 199, 148, 0.7);
}

.breathing-bubble.hold {
  transform: scale(2);
  box-shadow: 0 0 50px rgba(212, 175, 55, 0.8);
}

.breathing-bubble.exhale {
  transform: scale(1);
  box-shadow: 0 0 20px rgba(24, 92, 59, 0.4);
}

.breathing-instruction {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--text-main);
  min-height: 2.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes rotateSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 9. Interactive Pre-shot Routine Checklist */
.routine-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.routine-step {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  color: var(--text-main);
  font: inherit;
  text-align: left;
}

.routine-step > span:last-child {
  min-width: 0;
  display: block;
}

.routine-step .step-text,
.routine-step .step-subtext {
  display: block;
}

.routine-step:active {
  transform: scale(0.98);
}

.routine-step.completed {
  border-color: var(--color-success);
  background: rgba(16, 185, 129, 0.08);
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold-400);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.routine-step.completed .step-num {
  background: var(--color-success);
  color: #061c11;
}

.step-text {
  flex: 1;
  font-weight: 600;
  font-size: 0.9rem;
}

.step-subtext {
  font-size: 0.78rem;
  color: var(--text-subtle);
  margin-top: 0.15rem;
}

/* 10. Smart Caddy & Tactics Calculator */
.caddy-calculator {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 700;
  margin-bottom: var(--space-2);
  color: var(--text-main);
  line-height: var(--leading-snug);
}

.form-control, select.form-control {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: var(--text-base);
  min-height: 44px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.form-control:focus {
  outline: 3px solid var(--focus-ring);
  outline-offset: 1px;
  border-color: var(--gold-400);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

textarea.form-control {
  min-height: 96px;
  line-height: var(--leading-normal);
  resize: vertical;
}

.form-control::placeholder {
  color: var(--text-subtle);
  opacity: 0.82;
}

.form-control[aria-invalid="true"] {
  border-color: #d96b6b;
  box-shadow: 0 0 0 3px rgba(217, 107, 107, 0.12);
}

.field-error {
  min-height: 0;
  margin-top: var(--space-1);
  color: var(--status-error-text);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.35;
}

.field-error:empty {
  display: none;
}

.form-required {
  color: var(--gold-400);
}

.form-hint {
  display: block;
  margin-top: var(--space-1);
  color: var(--text-subtle);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
}

.app-form {
  padding: 0 1.75rem 1.75rem;
}

.form-section {
  margin: 0 0 var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.018);
}

.form-section-title {
  margin: 0 0 var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 800;
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.form-section-description {
  margin: -0.5rem 0 0.9rem;
  color: var(--text-subtle);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.form-grid-2,
.form-grid-3 {
  display: grid;
  gap: var(--space-3);
}

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

.form-grid-2 > .form-group,
.form-grid-3 > .form-group {
  margin-bottom: 0;
}

.form-context {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid rgba(68, 179, 126, 0.25);
  border-radius: var(--radius-md);
  background: rgba(34, 120, 77, 0.1);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.form-context .ui-icon {
  flex: 0 0 auto;
  color: var(--primary-300);
}

.form-status {
  min-height: 1.2rem;
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.4;
}

.form-status.error { color: var(--status-error-text); }
.form-status.success { color: var(--color-success); }

.form-actions {
  position: sticky;
  bottom: -1.75rem;
  z-index: 3;
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
  margin: 0.9rem -1.75rem -1.75rem;
  padding: 1rem 1.75rem calc(1rem + var(--sab));
  border-top: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--bg-surface) 94%, transparent);
  backdrop-filter: blur(14px);
}

.form-actions .btn {
  min-height: 46px;
  min-width: 132px;
}

.form-actions .btn-primary {
  min-width: 190px;
}

.optional-fields {
  margin-bottom: 1rem;
}

.optional-fields-content {
  padding-top: 0.25rem;
}

.caddy-recommendation-box {
  background: linear-gradient(135deg, rgba(24, 92, 59, 0.35), rgba(18, 25, 21, 0.85));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.rec-club-display {
  text-align: center;
  padding: 1rem 0;
}

.rec-club-name {
  font-size: 2.25rem;
  font-weight: 800;
  font-family: var(--font-heading);
  color: var(--gold-400);
  letter-spacing: -0.02em;
}

.rec-target-dist {
  font-size: 1rem;
  color: var(--primary-200);
  font-weight: 600;
}

/* ==========================================================================
   11. MOBILE SCORECARD INTERFACE (STEPPERS & CARDS)
   ========================================================================== */

.scorecard-table-wrapper {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  -webkit-overflow-scrolling: touch;
}

.scorecard-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 0.82rem;
}

.scorecard-table th {
  background: var(--primary-900);
  color: var(--gold-400);
  padding: 0.65rem 0.4rem;
  font-weight: 700;
  border-bottom: 2px solid var(--gold-600);
  white-space: nowrap;
}

.scorecard-table td {
  padding: 0.55rem 0.35rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

/* Mobile Stepper Controls for Golf Course Entry */
.round-setup-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  list-style: none;
  color: var(--text-main);
}

.round-setup-summary::-webkit-details-marker { display: none; }

.round-setup-summary > span:first-child {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.round-setup-summary strong {
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.round-setup-summary small {
  color: var(--text-subtle);
  font-size: 0.75rem;
  font-weight: 500;
}

.round-setup-edit {
  color: var(--gold-400);
  font-size: 0.75rem;
  font-weight: 800;
}

.round-setup-section[open] .round-setup-edit { visibility: hidden; }
.round-setup-content { margin-top: 1rem; }
.round-mobile-start-btn { display: none; }

.round-setup-optional {
  margin-top: 0.8rem;
  border-top: 1px solid var(--border-subtle);
}

.round-setup-optional > summary {
  display: flex;
  justify-content: space-between;
  padding: 0.8rem 0 0;
  cursor: pointer;
  list-style: none;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.round-setup-optional > summary::-webkit-details-marker { display: none; }

.round-setup-optional > summary span {
  color: var(--text-subtle);
  font-size: 0.68rem;
  font-weight: 600;
}

.round-setup-optional > .form-grid-2 {
  margin-top: 0.75rem;
}

.round-progress-card {
  margin-bottom: 0.9rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(212, 175, 55, 0.22);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.08), rgba(24, 92, 59, 0.08));
}

.round-progress-heading,
.round-progress-meta,
.hole-pagination-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.round-progress-heading {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.round-progress-heading strong {
  color: var(--gold-400);
  font-size: 0.84rem;
}

.round-progress-track {
  height: 6px;
  margin: 0.55rem 0 0.45rem;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
}

.round-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary-400), var(--gold-fill-400));
  transition: width 0.2s ease;
}

.round-progress-meta,
.hole-pagination-heading {
  color: var(--text-subtle);
  font-size: 0.7rem;
  font-weight: 600;
}

.hole-pagination-heading > span {
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 700;
}

.hole-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 0.2rem;
  border-radius: 50%;
  background: var(--primary-400);
}

.mobile-hole-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-top: 0.35rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.mobile-hole-card.needs-attention {
  border-color: rgba(217, 107, 107, 0.7);
  box-shadow: 0 0 0 3px rgba(217, 107, 107, 0.1);
}

.mobile-hole-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.mobile-hole-title > span {
  display: block;
  color: var(--text-subtle);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mobile-hole-title h4 {
  margin: 0.12rem 0 0;
  color: var(--text-main);
  font-size: 1.35rem;
}

.mobile-hole-title strong {
  display: block;
  margin-top: 0.1rem;
  color: var(--gold-400);
  font-size: 0.76rem;
}

.hole-par-control .form-label {
  margin-bottom: 0.2rem;
  text-align: right;
}

.hole-par-control .form-control {
  width: auto;
  min-height: 44px;
  padding: 0.35rem 0.6rem;
}

.quick-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.quick-score-row > span {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.quick-score-row > div {
  display: grid;
  grid-template-columns: repeat(4, minmax(38px, 1fr));
  gap: 0.3rem;
  width: min(100%, 240px);
}

.quick-score-row button {
  min-height: 44px;
  padding: 0 0.4rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
}

.quick-score-row button:active {
  border-color: var(--gold-500);
  color: var(--gold-400);
}

.hole-stepper-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}

.hole-stepper-field .form-label {
  margin-bottom: 0.3rem;
  text-align: center;
}

.hole-pagination-bar {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.4rem 0.2rem 0.8rem;
  -webkit-overflow-scrolling: touch;
}

.hole-chip-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}

.hole-chip-btn.active {
  background: var(--gold-500);
  color: #061c11;
  border-color: var(--gold-400);
  box-shadow: var(--shadow-gold);
}

.hole-chip-btn.completed:not(.active) {
  border-color: rgba(52, 168, 111, 0.55);
  color: var(--primary-300);
  background: rgba(52, 168, 111, 0.08);
}

.hole-chip-btn.completed:not(.active)::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary-fill-300);
}

.stepper-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.4rem;
}

.stepper-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--primary-700);
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: #ffffff;
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.stepper-btn:active {
  transform: scale(0.92);
  background: var(--primary-500);
}

.stepper-value {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: var(--font-heading);
  color: var(--gold-400);
  min-width: 45px;
  text-align: center;
}

.round-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}

.round-metric-toggle {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.round-metric-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.round-metric-toggle > span {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 800;
  transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease;
}

.round-metric-toggle small {
  margin-top: 0.08rem;
  color: var(--text-subtle);
  font-size: 0.61rem;
  font-weight: 600;
}

.round-metric-toggle:has(input:checked) > span {
  border-color: rgba(52, 168, 111, 0.55);
  background: rgba(52, 168, 111, 0.13);
  color: var(--primary-200);
}

.round-metric-toggle:focus-within > span {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.round-metric-toggle.disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.hole-navigation-actions {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(170px, 1.3fr);
  gap: 0.6rem;
}

.hole-navigation-actions .btn { min-height: 48px; }

.round-final-summary {
  color: var(--gold-400);
  font-size: 0.85rem;
  font-weight: 700;
}

.btn-danger-soft {
  border-color: rgba(217, 107, 107, 0.55) !important;
  color: #ef9a9a !important;
  background: rgba(217, 107, 107, 0.08) !important;
}

.score-chip {
  display: inline-block;
  min-width: 28px;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-weight: 700;
}

.score-chip.eagle { background: var(--score-eagle); color: #000; }
.score-chip.birdie { background: var(--score-birdie); color: #111; border-radius: 50%; }
.score-chip.par { background: transparent; color: var(--text-main); }
.score-chip.bogey { border: 1px solid var(--score-bogey); color: #60a5fa; }
.score-chip.double { border: 2px solid var(--color-danger); color: #f87171; }

/* 12. Mentor Chat Container */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 480px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chat-header {
  padding: 0.85rem 1.2rem;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  -webkit-overflow-scrolling: touch;
}

.chat-bubble {
  max-width: 85%;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.45;
}

.chat-bubble.coach {
  align-self: flex-start;
  background: var(--bg-surface-elevated);
  border: 1px solid rgba(212, 175, 55, 0.2);
  color: var(--text-main);
  border-bottom-left-radius: 2px;
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary-700), var(--primary-600));
  color: #ffffff;
  border-bottom-right-radius: 2px;
}

.chat-input-bar {
  padding: 0.75rem;
  background: var(--bg-surface-elevated);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 0.5rem;
}

/* ==========================================================================
   13. MODALS & MOBILE BOTTOM SHEETS
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 1.25rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  animation: modalScale 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-overflow-scrolling: touch;
}

.modal-box.form-modal {
  max-width: 680px;
  padding: 0;
}

.modal-box.form-modal.modal-wide,
.modal-box.form-modal:has(.round-entry-form) {
  max-width: 820px;
}

.modal-handle-bar {
  display: none;
  width: 40px;
  height: 5px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-full);
  margin: 0 auto 1.25rem;
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.form-modal .modal-handle-bar {
  margin-top: 0.7rem;
  margin-bottom: 0;
}

.form-modal .modal-header {
  align-items: flex-start;
  margin: 0;
  padding: 1.5rem 1.75rem 1rem;
}

.modal-heading {
  min-width: 0;
}

.modal-eyebrow {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--gold-400);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.modal-title {
  margin: 0;
  color: var(--text-main);
  font-size: clamp(1.2rem, 2vw, var(--text-xl));
  line-height: var(--leading-tight);
}

.modal-description {
  max-width: 560px;
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-md);
  line-height: 1;
  transition: color 0.16s ease, background-color 0.16s ease;
}

.modal-close:hover,
.modal-close:focus-visible {
  color: var(--text-main);
  background: var(--bg-surface-elevated);
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* 14. Toast Notifications */
.toast-container {
  position: fixed;
  bottom: calc(75px + var(--sab));
  left: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.8rem 1.2rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-main);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  animation: slideUpToast 0.25s ease;
  font-size: var(--text-sm);
  pointer-events: auto;
}

.toast-icon {
  width: 1.4rem;
  height: 1.4rem;
  display: grid;
  place-items: center;
  flex: 0 0 1.4rem;
  border-radius: 50%;
  font-weight: 800;
}

.toast-copy {
  min-width: 0;
  display: grid;
  gap: 0.12rem;
}

.toast-copy strong {
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: var(--text-base);
  line-height: var(--leading-snug);
}

.toast-copy span {
  color: var(--text-muted);
  line-height: var(--leading-snug);
}

.toast-success { border-color: rgba(52, 168, 111, 0.5); }
.toast-success .toast-icon { color: #d8f5e6; background: rgba(52, 168, 111, 0.22); }
.toast-error { border-color: rgba(239, 68, 68, 0.55); }
.toast-error .toast-icon { color: #fecaca; background: rgba(239, 68, 68, 0.2); }
.toast-warning { border-color: rgba(245, 158, 11, 0.55); }
.toast-warning .toast-icon { color: #fde68a; background: rgba(245, 158, 11, 0.18); }
.toast-info { border-color: rgba(59, 130, 246, 0.5); }
.toast-info .toast-icon { color: #bfdbfe; background: rgba(59, 130, 246, 0.18); }

@keyframes slideUpToast {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* 15. PWA Install & Offline State */
.pwa-install-button[hidden],
.network-status[hidden] {
  display: none !important;
}

.pwa-install-button {
  white-space: nowrap;
}

.network-status {
  position: fixed;
  z-index: 1100;
  left: 50%;
  bottom: calc(1rem + var(--sab));
  transform: translateX(-50%);
  width: min(calc(100% - 2rem), 520px);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid rgba(212, 175, 55, 0.45);
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  box-shadow: var(--shadow-lg);
  color: var(--text-main);
  font-size: 0.82rem;
  text-align: center;
}

.network-status > span:first-child {
  flex: 0 0 auto;
}

.network-status-copy {
  min-width: 0;
  flex: 1;
  text-align: left;
  line-height: var(--leading-snug);
}

.network-status-copy strong {
  display: block;
  color: var(--text-main);
}

.network-status-copy span {
  color: var(--text-muted);
}

.network-status .btn {
  min-height: 44px;
  flex: 0 0 auto;
}

.network-status.is-offline {
  border-color: rgba(245, 158, 11, 0.52);
}

.network-status.is-sync-error {
  border-color: rgba(239, 68, 68, 0.58);
}

.network-status.is-recovered {
  border-color: rgba(52, 168, 111, 0.52);
}

.sync-status-panel {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  min-height: 3rem;
  margin-top: var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  background: var(--bg-surface-elevated);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.sync-status-panel::before {
  content: 'i';
  width: 1.25rem;
  height: 1.25rem;
  display: grid;
  place-items: center;
  flex: 0 0 1.25rem;
  border-radius: 50%;
  color: var(--text-main);
  background: rgba(59, 130, 246, 0.2);
  font-weight: 800;
}

.sync-status-panel.error {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fecaca;
  background: rgba(239, 68, 68, 0.08);
}

.sync-status-panel.error::before { content: '!'; background: rgba(239, 68, 68, 0.22); }
.sync-status-panel.success { border-color: rgba(52, 168, 111, 0.4); color: var(--primary-200); background: rgba(52, 168, 111, 0.08); }
.sync-status-panel.success::before { content: '✓'; background: rgba(52, 168, 111, 0.22); }

.btn-icon.has-sync-pending {
  border-color: rgba(245, 158, 11, 0.5);
}

.sync-button-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: inline-grid;
  place-items: center;
  border: 2px solid var(--bg-surface);
  border-radius: var(--radius-full);
  background: var(--color-warning);
  color: #171307;
  font-size: 0.625rem;
  font-weight: 850;
  line-height: 1;
}

.sync-button-badge[hidden] { display: none; }

.offline-info-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.85rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

/* Player portal */
.player-portal-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  background:
    radial-gradient(circle at 92% 16%, rgba(212, 175, 55, 0.18), transparent 32%),
    linear-gradient(145deg, rgba(16, 66, 41, 0.88), rgba(10, 15, 13, 0.98));
}

.player-portal-hero-copy {
  max-width: 660px;
}

.player-portal-hero-copy h2 {
  font-size: clamp(1.55rem, 4vw, 2.35rem);
  margin: var(--space-2) 0;
}

.player-portal-hero-copy p {
  font-size: var(--text-sm);
}

.player-portal-refresh {
  min-width: 132px;
}

.player-portal-section {
  scroll-margin-top: 84px;
}

.coach-messages-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.coach-messages-hero > div {
  max-width: 720px;
}

.coach-messages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.coach-message-player-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.coach-message-player-main {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  min-width: 0;
}

.coach-message-player-main h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.coach-message-player-main p {
  margin-top: 0.45rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.player-portal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  align-items: start;
}

.portal-stack {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.portal-training-item,
.portal-goal-item,
.portal-tournament-item,
.portal-round-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.95rem;
  background: var(--bg-surface-elevated);
}

.portal-item-header h4 {
  font-size: var(--text-md);
  line-height: var(--leading-snug);
}

.portal-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.portal-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  margin-top: 0.55rem;
  font-size: 0.77rem;
  color: var(--text-subtle);
}

.portal-empty-state {
  padding: 1.3rem 1rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  text-align: center;
  color: var(--text-muted);
  background: rgba(24, 92, 59, 0.08);
}

.portal-handicap-trend {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  min-height: 118px;
  padding: 0.75rem 0 0.2rem;
  overflow-x: auto;
}

.portal-handicap-point {
  min-width: 46px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-subtle);
  font-size: 0.68rem;
}

.portal-handicap-bar {
  width: 100%;
  max-width: 34px;
  min-height: 8px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--gold-fill-400), var(--primary-600));
}

.portal-messages {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 360px;
  overflow-y: auto;
  padding: 0.25rem 0.1rem 0.6rem;
}

.portal-message {
  max-width: min(82%, 620px);
  padding: 0.72rem 0.9rem;
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
}

.portal-message.own {
  align-self: flex-end;
  border-color: rgba(212, 175, 55, 0.32);
  background: rgba(178, 138, 44, 0.14);
}

.portal-message.received {
  align-self: flex-start;
  border-color: rgba(98, 199, 148, 0.25);
  background: rgba(24, 92, 59, 0.18);
}

.portal-message-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.3rem;
  color: var(--text-subtle);
  font-size: 0.68rem;
}

.portal-message-body {
  color: var(--text-main);
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.portal-message-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: end;
  margin-top: 0.75rem;
}

.portal-message-composer textarea {
  min-height: 46px;
  max-height: 140px;
  resize: vertical;
}

.portal-account-pending {
  max-width: 720px;
  margin: 2rem auto;
  text-align: center;
  padding: 2rem;
}

.portal-account-pending .card-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 1rem;
  font-size: 1.45rem;
}

/* ===========================================================================
   RESPONSIVE ADJUSTMENTS FOR SMARTPHONES (< 768px)
   ========================================================================== */

@media (max-width: 768px) {
  .network-status {
    bottom: calc(5rem + var(--sab));
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    text-align: left;
  }

  .network-status .btn {
    width: 100%;
    grid-column: 1 / -1;
  }

  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
    gap: var(--layout-gap);
  }

  .view-hero-row {
    align-items: stretch;
    gap: var(--space-4);
  }

  .view-actions {
    width: 100%;
  }

  .view-actions .btn {
    flex: 1 1 180px;
  }

  .insight-card {
    padding: var(--card-padding);
  }

  .caddy-calculator {
    grid-template-columns: 1fr;
  }

  .round-entry-form {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .round-entry-form .form-section {
    padding: 0.72rem;
  }

  .round-mobile-start-btn {
    display: flex;
    width: 100%;
    min-height: 48px;
    margin-top: 0.85rem;
  }

  .round-score-section {
    scroll-margin-top: 0.75rem;
  }

  .hole-pagination-bar {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.34rem;
    overflow: visible;
    padding: 0.45rem 0 0.7rem;
  }

  .hole-chip-btn {
    width: 100%;
    height: auto;
    min-width: 0;
    min-height: 44px;
    aspect-ratio: 1;
    border-radius: 8px;
    font-size: 0.72rem;
  }

  .mobile-hole-card {
    padding: 0.78rem;
    border-radius: var(--radius-md);
  }

  .quick-score-row {
    align-items: stretch;
    flex-direction: column;
  }

  .quick-score-row > div {
    width: 100%;
  }

  .quick-score-row button {
    min-height: 44px;
  }

  .hole-stepper-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .hole-stepper-penalties {
    grid-column: 1 / -1;
  }

  .hole-stepper-penalties .stepper-control {
    max-width: 210px;
    margin: 0 auto;
  }

  .stepper-control {
    padding: 0.28rem;
  }

  .stepper-btn {
    width: 46px;
    height: 46px;
  }

  .stepper-value {
    min-width: 34px;
    font-size: 1.45rem;
  }

  .hole-navigation-actions {
    grid-template-columns: minmax(92px, 0.65fr) minmax(0, 1.35fr);
  }

  .round-entry-form .form-actions {
    margin-right: -0.75rem;
    margin-left: -0.75rem;
  }

  .pwa-install-button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    font-size: 0;
  }

  .player-portal-hero,
  .player-portal-grid,
  .portal-message-composer {
    grid-template-columns: 1fr;
  }

  .coach-messages-hero,
  .coach-message-player-card {
    align-items: stretch;
    flex-direction: column;
  }

  .coach-message-player-card .btn,
  .coach-messages-hero .btn {
    width: 100%;
  }

  .player-portal-refresh,
  .portal-message-composer .btn {
    width: 100%;
  }

  .portal-message {
    max-width: 92%;
  }

  /* Bottom Sheet Transformation */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-box {
    max-width: 100%;
    max-height: 88vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top: 1px solid var(--border-strong);
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 1.25rem 1rem calc(1.5rem + var(--sab));
    animation: slideUpSheet 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .modal-box.form-modal {
    padding: 0 0 calc(0.25rem + var(--sab));
  }

  .form-modal .modal-header {
    padding: 1.1rem 1rem 0.85rem;
  }

  .app-form {
    padding: 0 1rem 1rem;
  }

  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
    gap: 0.72rem;
  }

  .form-section {
    padding: 0.85rem;
    border-radius: var(--radius-md);
  }

  .form-actions {
    bottom: calc(-1rem - var(--sab));
    margin: 0.8rem -1rem calc(-1rem - var(--sab));
    padding: 0.85rem 1rem calc(0.85rem + var(--sab));
  }

  .form-actions .btn,
  .form-actions .btn-primary {
    flex: 1;
    min-width: 0;
  }

  .modal-handle-bar {
    display: block;
  }

  @keyframes slideUpSheet {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }

  .breathing-bubble {
    transform: none !important;
  }

  .breathing-outer-ring {
    animation: none !important;
  }
}

[data-theme="light"] .field-error,
[data-theme="light"] .form-status.error,
[data-theme="light"] .sync-status-panel.error,
[data-theme="light"] .btn-danger-soft {
  color: var(--status-error-text) !important;
}

[data-theme="light"] .badge-green {
  color: #087443;
  background: rgba(8, 116, 67, 0.1);
  border-color: rgba(8, 116, 67, 0.3);
}

[data-theme="light"] .badge-blue,
[data-theme="light"] .score-chip.bogey {
  color: #155eb3;
}

[data-theme="light"] .score-chip.double {
  color: #b42318;
}

[data-theme="light"] .toast-success .toast-icon { color: #087443; }
[data-theme="light"] .toast-error .toast-icon { color: #b42318; }
[data-theme="light"] .toast-warning .toast-icon { color: #7a4b00; }
[data-theme="light"] .toast-info .toast-icon { color: #155eb3; }

[data-theme="light"] .timer-container,
[data-theme="light"] .caddy-recommendation-box,
[data-theme="light"] .player-portal-hero,
[data-theme="light"] .dashboard-coach-hero {
  background:
    radial-gradient(circle at 90% 10%, rgba(212, 175, 55, 0.12), transparent 36%),
    linear-gradient(145deg, rgba(216, 245, 230, 0.65), rgba(255, 255, 255, 0.98)) !important;
}

@media (forced-colors: active) {
  :where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid Highlight !important;
  }

  .nav-item.active,
  .bottom-nav-item.active,
  .filter-pill.active {
    border: 2px solid Highlight;
  }
}
