/* AI assisted development */
:root {
  --black: #0a0a0a;
  --black-soft: #141414;
  --surface: #1a1a1a;
  --red: #c41e3a;
  --red-dark: #9e1830;
  --gold: #d4a843;
  --gold-light: #e8c56a;
  --white: #f5f5f5;
  --gray: #a0a0a0;
  --gray-dim: #6a6a6a;
  --green: #2d8a4e;
  --font-display: "Bebas Neue", sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --top-h: 52px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--black);
  color: var(--white);
  line-height: 1.45;
  min-height: 100dvh;
  padding-bottom: calc(1.5rem + var(--safe-bottom));
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* Top bar */
.sheet-top {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--top-h);
  padding: 0.5rem 0.75rem;
  padding-top: max(0.5rem, env(safe-area-inset-top));
  background: rgba(10, 10, 10, 0.94);
  border-bottom: 2px solid var(--red);
  backdrop-filter: blur(8px);
}

.sheet-top__home {
  justify-self: start;
  color: var(--gray);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.4rem 0.25rem;
}

.sheet-top__brand {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.04em;
}

.sheet-top__brand img {
  display: block;
}

.sheet-top__save {
  justify-self: end;
  background: var(--gold);
  color: var(--black);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
}

.sheet-top__save:disabled {
  opacity: 0.35;
}

.sheet-banner {
  background: var(--red-dark);
  color: var(--white);
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
}

/* Panels */
.panel {
  width: min(480px, 100%);
  margin-inline: auto;
  padding: 1.25rem 1rem 2rem;
}

.panel__title {
  font-family: var(--font-display);
  font-size: 2.4rem;
  letter-spacing: 0.03em;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.panel__lead {
  color: var(--gray);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
}

.setup-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field--full {
  grid-column: 1 / -1;
}

.field span {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray);
}

.field input,
.field select {
  appearance: none;
  background: var(--surface);
  border: 1px solid #333;
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  font-size: 1rem;
  min-height: 48px;
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-color: var(--gold);
}

.setup-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 52px;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
  transition: transform 0.08s ease, opacity 0.15s;
}

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

.btn--primary {
  background: var(--red);
  color: var(--white);
}

.btn--ghost {
  background: var(--surface);
  border: 1px solid #333;
  color: var(--white);
}

.btn--undo {
  width: 100%;
  margin-top: 0.65rem;
  min-height: 44px;
  background: transparent;
  border: 1px dashed #444;
  color: var(--gray);
  border-radius: 10px;
  font-weight: 600;
}

.btn--undo:disabled {
  opacity: 0.35;
}

.btn--goal {
  background: var(--green);
  color: var(--white);
  flex: 1;
}

.btn--penalty {
  background: #3a3a3a;
  border: 1px solid #555;
  color: var(--white);
  flex: 1;
}

/* Score strip */
.score-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.5rem;
  align-items: center;
  background: linear-gradient(180deg, #1f1518 0%, var(--surface) 100%);
  border: 1px solid #333;
  border-radius: 14px;
  padding: 0.85rem 0.75rem;
  margin-bottom: 0.75rem;
}

.score-strip__team {
  text-align: left;
}

.score-strip__team--opp {
  text-align: right;
}

.score-strip__label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray);
}

.score-strip__num {
  font-family: var(--font-display);
  font-size: 3rem;
  line-height: 1;
  color: var(--gold-light);
}

.score-strip__meta {
  text-align: center;
  font-size: 0.8rem;
  color: var(--gray);
  max-width: 7.5rem;
}

.score-strip__period {
  display: block;
  margin-top: 0.25rem;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--white);
  letter-spacing: 0.04em;
}

/* Period tabs */
.period-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.period-tab {
  min-height: 44px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid #333;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--gray);
}

.period-tab.is-active {
  background: var(--red);
  border-color: var(--red);
  color: var(--white);
}

/* Shot board — the hero interaction */
.shot-board {
  margin-bottom: 1rem;
}

.shot-board__hint {
  text-align: center;
  font-size: 0.78rem;
  color: var(--gray-dim);
  margin-bottom: 0.55rem;
}

.shot-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.shot-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 148px;
  border-radius: 18px;
  border: 2px solid transparent;
  user-select: none;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.15s;
}

.shot-btn:active {
  transform: scale(0.96);
}

.shot-btn.is-flash {
  box-shadow: 0 0 0 3px var(--gold);
}

.shot-btn--us {
  background: linear-gradient(160deg, #2a151c 0%, #1a0e12 100%);
  border-color: var(--red);
}

.shot-btn--them {
  background: linear-gradient(160deg, #1c1c22 0%, #121216 100%);
  border-color: #555;
}

.shot-btn__team {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray);
}

.shot-btn__count {
  font-family: var(--font-display);
  font-size: 4.2rem;
  line-height: 1;
  margin: 0.1rem 0;
}

.shot-btn--us .shot-btn__count {
  color: var(--gold-light);
}

.shot-btn__sub {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--white);
}

.shot-period {
  text-align: center;
  margin-top: 0.55rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray);
}

.quick-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.quick-actions .btn--ghost {
  flex: 0 0 auto;
  padding-inline: 0.7rem;
  font-size: 0.85rem;
}

.goalie-chip {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold);
  background: rgba(212, 168, 67, 0.08);
  border: 1px solid rgba(212, 168, 67, 0.25);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  margin-bottom: 1.25rem;
}

/* Event log */
.log {
  margin-bottom: 1.25rem;
}

.log__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.log__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.log__empty {
  color: var(--gray-dim);
  font-size: 0.9rem;
  padding: 0.75rem;
  text-align: center;
  border: 1px dashed #333;
  border-radius: 10px;
}

.log__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: start;
  background: var(--surface);
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 0.65rem 0.7rem;
  font-size: 0.88rem;
}

.log__badge {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  background: #333;
}

.log__badge--goal {
  background: var(--green);
}

.log__badge--pen {
  background: #6b4a1e;
}

.log__badge--opp {
  background: #444;
}

.log__body {
  min-width: 0;
}

.log__body strong {
  display: block;
}

.log__meta {
  color: var(--gray);
  font-size: 0.78rem;
}

.log__del {
  color: var(--gray-dim);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  min-width: 36px;
  min-height: 36px;
}

.live-footer {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px solid #2a2a2a;
}

/* Custom modals — native <dialog> can render blank on some iPhone Safari versions */
.sheet-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}

.sheet-modal[hidden] {
  display: none !important;
}

.sheet-modal.is-open {
  pointer-events: auto;
}

.sheet-modal__backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.72);
  cursor: pointer;
}

.sheet-modal__sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: min(88dvh, 100%);
  border-top: 1px solid #333;
  border-radius: 18px 18px 0 0;
  background: var(--black-soft);
  color: var(--white);
  overflow: hidden;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
}

body.modal-open {
  overflow: hidden;
  touch-action: none;
}

.dialog-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: min(88dvh, 100%);
  padding: 0;
  gap: 0;
}

.dialog-form__head {
  flex-shrink: 0;
  padding: 0.85rem 1rem 0.55rem;
  border-bottom: 1px solid #2a2a2a;
}

.dialog-form__head::before {
  content: "";
  display: block;
  width: 2.25rem;
  height: 0.28rem;
  margin: 0 auto 0.65rem;
  border-radius: 999px;
  background: #444;
}

.dialog-form h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: 0.03em;
  line-height: 1;
  text-align: center;
}

.dialog-form__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.75rem 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  align-content: start;
}

.dialog-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.dialog-form .field input,
.dialog-form .field select {
  min-height: 44px;
  padding: 0.55rem 0.7rem;
  font-size: 0.95rem;
}

.seg {
  grid-column: 1 / -1;
  border: none;
  display: flex;
  gap: 0.4rem;
}

.seg legend {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray);
  margin-bottom: 0.3rem;
}

.seg label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 42px;
  background: var(--surface);
  border: 1px solid #333;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.35rem;
}

.seg input {
  accent-color: var(--red);
}

.dialog-note {
  grid-column: 1 / -1;
  font-size: 0.82rem;
  color: var(--gray);
}

.dialog-actions {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.65rem 1rem calc(0.75rem + var(--safe-bottom));
  border-top: 1px solid #2a2a2a;
  background: rgba(20, 20, 20, 0.98);
}

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

@media (min-width: 480px) {
  .shot-btn {
    min-height: 168px;
  }

  .shot-btn__count {
    font-size: 4.6rem;
  }
}
