html,
body.scorecard-page {
  width: 100%;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
  background: #ffffff;
}

.scorecard-page *,
.scorecard-page *::before,
.scorecard-page *::after {
  box-sizing: border-box;
}

body.scorecard-page {
  position: fixed;
  inset: 0;
}

.scorecard-page .mobile-shell {
  width: 100%;
  height: 100dvh;
  max-width: none;
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: none;
}

.scorecard-topbar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  width: 100%;
  flex: 0 0 auto;
  min-height: 86px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  color: white;
  background: #17633f;
}

.scorecard-topbar a,
.scorecard-topbar button {
  width: 44px;
  height: 48px;
  display: grid;
  place-items: center;
  color: white;
  background: transparent;
  border: 0;
  text-decoration: none;
  font-size: 2.35rem;
  line-height: 1;
}

.scorecard-topbar .scorecard-menu-link {
  font-size: 2rem;
  letter-spacing: 0.05em;
}

.scorecard-title {
  min-width: 0;
}

.scorecard-title strong,
.scorecard-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scorecard-title strong {
  font-size: clamp(1.16rem, 5.2vw, 1.95rem);
  font-weight: 650;
}

.scorecard-title span {
  margin-top: 4px;
  font-size: clamp(0.96rem, 4.1vw, 1.45rem);
  opacity: 0.96;
}

.scorecard-content {
  width: 100%;
  max-width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 14px 6px 0 2px;
  overflow: hidden;
}

.scorecard-format-tabs {
  min-width: 0;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 10px 14px;
  margin: 0 -6px 0 -2px;
  scrollbar-width: none;
}

.scorecard-format-tabs::-webkit-scrollbar {
  display: none;
}

.scorecard-format-tabs button {
  min-height: 58px;
  min-width: 118px;
  display: grid;
  place-items: center;
  gap: 1px;
  border: 0;
  border-radius: 999px;
  color: #333333;
  background: #f5f5f5;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.14);
  padding: 6px 20px;
  font: inherit;
  white-space: nowrap;
}

.scorecard-format-tabs button strong {
  font-size: clamp(1rem, 4vw, 1.45rem);
  font-weight: 500;
  line-height: 1;
}

.scorecard-format-tabs button small {
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.74;
}

.scorecard-format-tabs button.active {
  color: white;
  background: #1f8750;
}

.scorecard-format-tabs button.active small {
  opacity: 0.9;
}

#scorecardApp {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  overflow: hidden;
}

.scorecard-leader-card {
  margin: 0 0 0 2px;
  padding: 16px 12px 14px;
  background: #e8f4eb;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}

.scorecard-leader-card.collapsed {
  padding-bottom: 14px;
}

.scorecard-leader-card.collapsed .scorecard-leader-head {
  margin-bottom: 0;
}

.scorecard-leader-head,
.scorecard-leader-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px 54px;
  align-items: center;
  gap: 6px;
}

.scorecard-leader-head {
  margin-bottom: 10px;
  color: #121c16;
  text-transform: uppercase;
  font-size: clamp(0.78rem, 3.05vw, 1rem);
  font-weight: 900;
}

.scorecard-leader-head button {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: #121c16;
  background: transparent;
  border: 0;
  padding: 0;
  text-transform: uppercase;
  font: inherit;
  font-weight: 900;
}

.leader-chevron {
  color: #1f8750;
  font-size: 1.4rem;
  line-height: 1;
}

.scorecard-leader-row {
  min-height: 38px;
  color: #151515;
  font-size: clamp(0.86rem, 3.75vw, 1.18rem);
}

.scorecard-leader-player {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.scorecard-leader-player span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scorecard-leader-row strong {
  font-weight: 500;
  text-align: center;
}

.leader-collapse-control {
  display: flex;
  justify-content: center;
  margin: 0;
}

.leader-collapse-control button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #1f8750;
  background: #f0f2f1;
  border: 0;
  border-radius: 50%;
  font-size: 1.25rem;
  line-height: 1;
}

.scorecard-grid {
  min-height: 0;
  display: grid;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 0 18px;
  -webkit-overflow-scrolling: touch;
}

.scorecard-grid-inner {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.scorecard-grid-header,
.scorecard-grid-row {
  display: grid;
  grid-template-columns: 8% 9.5% 8% 13% repeat(var(--player-count), minmax(0, 1fr));
  align-items: center;
  column-gap: 0;
}

.scorecard-grid-header {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 108px;
  background: white;
}

.scorecard-grid-header span:not(.initial-badge) {
  justify-self: center;
  color: #050505;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: clamp(0.8rem, 3.4vw, 1.18rem);
  font-weight: 800;
}

.scorecard-grid-header .initial-badge {
  width: clamp(28px, 8.4vw, 42px);
  height: clamp(28px, 8.4vw, 42px);
  font-size: clamp(0.68rem, 3.2vw, 0.94rem);
}

.scorecard-grid-row {
  min-height: 66px;
  color: #030303;
}

.scorecard-grid-row:nth-child(odd) {
  background: #eeeeee;
}

.scorecard-grid-row span,
.scorecard-grid-row button {
  justify-self: center;
}

.hole-stat {
  font-size: clamp(0.84rem, 3.7vw, 1.25rem);
  font-weight: 800;
}

.score-cell-stack {
  min-width: 0;
  min-height: 56px;
  display: grid;
  grid-template-rows: 10px minmax(36px, auto);
  place-items: center;
  gap: 2px;
}

.stroke-dot-row {
  min-height: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
}

.stroke-dot {
  width: 5px;
  height: 5px;
  display: inline-block;
  background: #17633f;
  border-radius: 50%;
}

.score-button {
  width: clamp(26px, 7.6vw, 40px);
  height: clamp(30px, 8.4vw, 42px);
  display: grid;
  place-items: center;
  border: 0;
  color: #178554;
  background: transparent;
  font-size: clamp(1.42rem, 6.2vw, 1.9rem);
  line-height: 1;
  font-weight: 500;
}

.score-display {
  width: clamp(28px, 8vw, 42px);
  height: clamp(28px, 8vw, 42px);
  display: grid;
  place-items: center;
  color: #111111;
  background: transparent;
  border: 0;
  font-size: clamp(0.98rem, 4.45vw, 1.48rem);
  font-weight: 500;
}

.score-display.eagle {
  color: #0c4b30;
  background: #4fbe79;
  border: 2px solid #18864f;
  border-radius: 50%;
}

.score-display.birdie {
  color: #12663f;
  background: #e7f6ee;
  border: 2px solid #4fbe79;
  border-radius: 50%;
}

.score-display.par {
  color: #111111;
  background: transparent;
  border: 0;
}

.score-display.bogey {
  color: #7b400c;
  background: #fff7eb;
  border: 2px solid #e2a160;
  border-radius: 7px;
}

.score-display.double {
  color: #8f241e;
  background: #f8dfdb;
  border: 2px solid #c74a43;
  border-radius: 7px;
}

.summary-row {
  min-height: 54px;
  background: #dfe8e2;
  border-top: 1px solid #c9d8ce;
  border-bottom: 1px solid #c9d8ce;
}

.scorecard-grid-row.summary-row:nth-child(odd) {
  background: #dfe8e2;
}

.summary-label {
  grid-column: 1 / 5;
  justify-self: start !important;
  padding-left: 6px;
  color: #0b3425;
  font-size: clamp(0.7rem, 2.85vw, 0.9rem);
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: normal;
}

.summary-value {
  justify-self: center;
  color: #0b3425;
  font-size: clamp(0.86rem, 3.6vw, 1.18rem);
  font-weight: 950;
}

.score-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  align-items: end;
  background: rgba(7, 18, 12, 0.4);
}

.score-picker-backdrop[hidden] {
  display: none;
}

.score-picker {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: grid;
  gap: 14px;
  background: white;
  border-radius: 18px 18px 0 0;
  padding: 18px 16px 24px;
  box-shadow: 0 -18px 48px rgba(0, 0, 0, 0.22);
}

.score-picker h2,
.score-picker p {
  margin: 0;
}

.score-picker h2 {
  color: #0b3425;
  font-size: 1.25rem;
}

.score-picker p {
  color: #68766e;
}

.score-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.score-picker-grid button {
  min-height: 54px;
  border: 1px solid #dce5df;
  border-radius: 8px;
  color: #143b29;
  background: #f7faf8;
  font-size: 1.2rem;
  font-weight: 900;
}

.score-picker-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.score-picker-actions button {
  min-height: 44px;
  border: 1px solid #bed8c9;
  border-radius: 6px;
  color: #17633f;
  background: white;
  font-weight: 900;
}

.score-picker-actions button:first-child {
  color: white;
  background: #17633f;
}

.scorecard-page .initial-badge {
  --badge: #17633f;
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: white;
  background: var(--badge);
  border-radius: 50%;
  font-weight: 950;
  font-size: 0.72rem;
}

@media (min-width: 760px) {
  .scorecard-page .mobile-shell {
    margin-top: 0;
    margin-bottom: 0;
    border-radius: 0;
  }

  .scorecard-page .mobile-shell,
  .scorecard-topbar,
  .scorecard-content {
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
  }
}
