/* ============================================================================
   SCORECARD BOTTOM SHEET
   Additive UI layer for mobile score entry.
   ============================================================================ */

body.score-sheet-active #scorecard .score-input {
  caret-color: transparent;
}

body.score-sheet-open {
  overscroll-behavior-y: none;
}

/* On touch screens, score cells look like tappable tiles rather than form inputs */
@media (pointer: coarse) {
  body.score-sheet-active #scorecard .score-input {
    border-color: var(--hi-soft) !important;
    background: #000000 !important;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    font-weight: 700;
    -moz-appearance: textfield;
  }

  body.score-sheet-active #scorecard .score-input::-webkit-inner-spin-button,
  body.score-sheet-active #scorecard .score-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }}

.score-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.002);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 9100;
}

.score-sheet-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}
.score-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: calc(100dvh - max(env(safe-area-inset-top, 0px), 56px));
  display: flex;
  flex-direction: column;
  background: var(--panel);
  color: var(--ink);
  border-top: 2px solid var(--line);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  box-shadow: none;
  transform: translateY(100%);
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 9101;
}

.score-sheet.is-open {
  transform: translateY(0);
  box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.4);
}
@media (min-width: 720px) {
  .score-sheet {
    left: 50%;
    right: auto;
    bottom: 24px;
    transform: translate(-50%, 120%);
    width: min(980px, calc(100vw - 24px));
    max-height: min(90vh, 960px);
    border-radius: var(--radius-lg);
    border: 2px solid var(--line);
  }

  .score-sheet.is-open {
    transform: translate(-50%, 0);
  }
}

.score-sheet-header {
  display: grid;
  grid-template-columns: 40px 1fr 40px 40px;
  gap: 8px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 2px solid var(--line);
  background: var(--panel-alt);
}
.score-sheet-title {
  margin: 0;
  text-align: center;
  font-size: var(--text-xl);
}

.score-sheet-navbtn,
.score-sheet-close {
  min-height: 40px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: calc(18px + var(--font-size-step));
  font-weight: 700;
}
.score-sheet-navbtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.score-sheet-body {
  padding: 12px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.score-sheet-hole-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--panel-alt);
  border-top: 2px solid rgba(255, 255, 255, 0.3);
  border-bottom: 2px solid rgba(255, 255, 255, 0.3);
  border-left: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  overflow: hidden;
}

.score-sheet-hole-stat {
  background: transparent;
  border: none;
  border-left: 2px solid rgba(255, 255, 255, 0.15);
  border-right: none;
  border-top: none;
  border-bottom: none;
  border-radius: 0;
  padding: 8px 10px;
  min-width: 0;
}

.score-sheet-hole-stat:first-child {
  border-left: none;
}
.score-sheet-meta-label {
  display: block;
  font-size: calc(12px + var(--font-size-step));
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.score-sheet-meta-value {
  display: block;
  font-size: var(--text-2xl);
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-sheet-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.score-sheet-player-card {
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--panel-alt);
  padding: 8px;
}
.score-sheet-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.score-sheet-card-name {
  font-size: var(--text-md);
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-sheet-card-stroke {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 2px 6px;
  border: 2px solid var(--line);
  border-radius: 999px;
  font-size: calc(11px + var(--font-size-step));
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.score-sheet-card-stroke.is-down {
  border-color: rgba(0, 188, 140, 0.65);
  background: rgba(0, 188, 140, 0.2);
  color: #e8ecf2;
}

.score-sheet-card-stroke.is-up {
  border-color: rgba(220, 53, 69, 0.7);
  background: rgba(220, 53, 69, 0.2);
  color: #e8ecf2;
}

.score-sheet-card-controls {
  --score-sheet-control-size: 56px;
  display: grid;
  grid-template-columns: 1fr var(--score-sheet-control-size) 1fr;
  gap: 8px;
  align-items: end;
}

.score-sheet-score-col {
  display: grid;
  gap: 4px;
  width: var(--score-sheet-control-size);
  justify-self: center;
}

.score-sheet-gross-label {
  min-height: 28px;
  padding-right: 0;
  font-size: calc(10px + var(--font-size-step));
  line-height: 1.15;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.score-sheet-stepbtn {
  min-height: 56px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--panel-alt);
  color: var(--ink);
  font-size: calc(30px + var(--font-size-step));
  font-weight: 700;
  cursor: pointer;
}
.score-sheet-stepbtn-sm {
  width: 100%;
  min-height: var(--score-sheet-control-size);
  height: var(--score-sheet-control-size);
  font-size: calc(24px + var(--font-size-step));
}

.score-sheet .score-sheet-player-input {
  width: var(--score-sheet-control-size);
  min-height: var(--score-sheet-control-size);
  height: var(--score-sheet-control-size);
  appearance: textfield;
  -moz-appearance: textfield;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  padding: 0;
  text-align: center;
  font-size: calc(24px + var(--font-size-step));
  font-weight: 700;
  line-height: 1;
}
.score-sheet .score-sheet-player-input::-webkit-outer-spin-button,
.score-sheet .score-sheet-player-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.score-sheet-footer {
  display: block;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 2px solid var(--line);
  background: var(--panel-alt);
}
.score-sheet-footer .btn {
  min-height: 44px;
  width: 100%;
}

@media (max-width: 480px) {
  .score-sheet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 720px) {
  .score-sheet-header {
    grid-template-columns: 69px 1fr 69px 69px;
    gap: 14px;
    padding: 21px 24px;
  }

  .score-sheet-title {
    font-size: calc(35px + var(--font-size-step));
  }

  .score-sheet-navbtn,
  .score-sheet-close {
    min-height: 69px;
    border-radius: 14px;
    font-size: calc(31px + var(--font-size-step));
  }

  .score-sheet-body {
    padding: 21px 24px;
  }

  .score-sheet-hole-card {
    gap: 0;
    border-radius: 0;
    padding: 0;
  }

  .score-sheet-hole-stat {
    border-radius: 0;
    padding: 14px;
  }

  .score-sheet-meta-label {
    font-size: calc(17px + var(--font-size-step));
    margin-bottom: 7px;
  }

  .score-sheet-meta-value {
    font-size: calc(31px + var(--font-size-step));
  }

  .score-sheet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 17px;
    margin-top: 21px;
  }

  .score-sheet-player-card {
    padding: 21px;
    border-radius: 17px;
  }

  .score-sheet-card-head {
    gap: 14px;
    margin-bottom: 14px;
  }

  .score-sheet-card-name {
    font-size: calc(31px + var(--font-size-step));
  }

  .score-sheet-card-stroke {
    min-height: 41px;
    padding: 4px 10px;
    font-size: calc(20px + var(--font-size-step));
  }

  .score-sheet-gross-label {
    font-size: calc(20px + var(--font-size-step));
    min-height: 56px;
    padding-right: 0;
    line-height: 1.15;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .score-sheet-card-controls {
    --score-sheet-control-size: 97px;
    gap: 17px;
  }

  .score-sheet-score-col {
    gap: 7px;
  }

  .score-sheet-stepbtn-sm {
    font-size: calc(48px + var(--font-size-step));
  }

  .score-sheet .score-sheet-player-input {
    border-radius: 17px;
    font-size: calc(52px + var(--font-size-step));
  }

  .score-sheet-footer {
    padding: 17px 24px calc(17px + env(safe-area-inset-bottom, 0px));
  }

  .score-sheet-footer .btn {
    min-height: 76px;
    font-size: calc(31px + var(--font-size-step));
  }
}

@media (min-width: 520px) and (max-width: 719px) {
  .score-sheet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* =========================================================================
   Light theme overrides — moved from light-theme-overrides.css
   ========================================================================= */

:root[data-theme="light"] .score-sheet-backdrop {
  background: rgba(255, 255, 255, 0.006);
}

:root[data-theme="light"] .score-sheet {
  border-top-color: rgba(21, 32, 43, 0.18);
}

:root[data-theme="light"] .score-sheet.is-open {
  box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.14);
}

:root[data-theme="light"] .score-sheet-header {
  background: #f8fafc;
}

:root[data-theme="light"] .score-sheet-navbtn,
:root[data-theme="light"] .score-sheet-close {
  background: #ffffff;
  border-color: var(--shadow-navy);
  color: #0f172a;
}

:root[data-theme="light"] .score-sheet-hole-card {
  background: var(--panel-alt);
  border-top-color: rgba(0, 0, 0, 0.3);
  border-bottom-color: rgba(0, 0, 0, 0.3);
  border-left-color: rgba(0, 0, 0, 0.15);
  box-shadow: none;
}

:root[data-theme="light"] .score-sheet-hole-stat {
  background: transparent;
  border-left-color: rgba(0, 0, 0, 0.15);
}

:root[data-theme="light"] .score-sheet-player-card {
  background: #ffffff;
  border-color: rgba(21, 32, 43, 0.16);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.08);
}

:root[data-theme="light"] .score-sheet-gross-label {
  color: #475569;
}

:root[data-theme="light"] .score-sheet-stepbtn {
  background: #ffffff;
  border-color: var(--shadow-navy);
}

:root[data-theme="light"] .score-sheet .score-sheet-player-input {
  background: #ffffff;
  border-color: var(--shadow-navy);
}

:root[data-theme="light"] .score-sheet-card-stroke.is-down {
  color: #4b5563;
}

:root[data-theme="light"] .score-sheet-card-stroke.is-up {
  color: #4b5563;
}

:root[data-theme="light"] .score-sheet-footer {
  background: rgba(248, 250, 252, 0.94);
}

@media (pointer: coarse) {
  :root[data-theme="light"] body.score-sheet-active #scorecard .score-input {
    border-color: rgba(0, 0, 0, 0.08) !important;
    background: #ffffff !important;
  }
}
