/* ============================================
   Fiesta Falls — digital scorecard app styles
   ============================================ */

body.app {
  background: var(--cream);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: linear-gradient(160deg, var(--green-dark), var(--green-deep));
  color: var(--white);
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.app-header .brand {
  font-size: 1.25rem;
  text-decoration: none;
}

.app-header .header-sub {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fiesta-yellow);
}

.app-header .header-actions {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 0;
  color: var(--white);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.85rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:active {
  background: rgba(255, 255, 255, 0.25);
}

main.app-main {
  flex: 1;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 6.5rem;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeUp 0.25s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- start screen ---------- */

.start-hero {
  text-align: center;
  padding: 2rem 0 1.5rem;
}

.start-hero .wordmark {
  font-size: clamp(2.6rem, 12vw, 3.6rem);
}

.start-hero .wordmark-sub {
  font-family: var(--font-display);
  color: var(--fiesta-orange);
  text-shadow: none;
  font-size: 1.3rem;
}

.start-hero p {
  margin-top: 0.9rem;
  color: #5a6b57;
  font-weight: 700;
}

.start-actions {
  display: grid;
  gap: 0.9rem;
  margin-top: 1.75rem;
}

.resume-note {
  text-align: center;
  font-size: 0.9rem;
  color: #5a6b57;
  margin-top: 0.4rem;
}

/* ---------- setup screen ---------- */

.setup-title {
  font-family: var(--font-display);
  color: var(--green-dark);
  font-size: 1.6rem;
  text-align: center;
  margin: 0.5rem 0 1.25rem;
}

.player-inputs {
  display: grid;
  gap: 0.75rem;
}

.player-input-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.player-input-row .p-badge {
  flex: 0 0 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--fiesta-yellow), var(--fiesta-orange));
  color: #4a2500;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-input-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.7rem 0.9rem;
  border: 2px solid var(--card-line);
  border-radius: 12px;
  background: var(--white);
  color: var(--ink);
}

.player-input-row input:focus {
  outline: none;
  border-color: var(--green);
}

.player-input-row .remove-player {
  flex: 0 0 auto;
  background: none;
  border: 0;
  font-size: 1.2rem;
  color: #b0483a;
  cursor: pointer;
  padding: 0.4rem;
}

.setup-actions {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* ---------- play: tabs ---------- */

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--white);
  border-top: 1px solid var(--card-line);
  display: none;
  box-shadow: 0 -3px 14px rgba(20, 60, 30, 0.12);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab-bar.visible {
  display: flex;
}

.tab-bar button {
  flex: 1;
  background: none;
  border: 0;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.8rem;
  color: #7b8a78;
  padding: 0.6rem 0 0.7rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tab-bar button .tab-emoji {
  display: block;
  font-size: 1.3rem;
  margin-bottom: 0.1rem;
}

.tab-bar button.active {
  color: var(--green-dark);
}

.tab-bar button.active .tab-emoji {
  transform: scale(1.15);
}

/* ---------- play: hole view ---------- */

.hole-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.hole-nav .hole-title {
  text-align: center;
}

.hole-nav .hole-title .hole-num {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--green-dark);
  line-height: 1.1;
}

.hole-nav .hole-title .hole-par {
  font-weight: 900;
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fiesta-orange);
}

.hole-nav .nav-arrow {
  flex: 0 0 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 0;
  background: var(--white);
  box-shadow: var(--shadow);
  font-size: 1.3rem;
  color: var(--green-dark);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.hole-nav .nav-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

.hole-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--cream-dark);
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.hole-progress .fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--fiesta-yellow), var(--fiesta-orange));
  transition: width 0.3s ease;
}

.player-score-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem;
  margin-bottom: 0.9rem;
}

.player-score-card .psc-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.player-score-card .psc-name {
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--green-dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-score-card .psc-status {
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.psc-status.is-under { color: var(--birdie); }
.psc-status.is-par { color: var(--green); }
.psc-status.is-over { color: var(--bogey); }
.psc-status.is-ace { color: var(--fiesta-orange); }

.stroke-buttons {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.45rem;
}

.stroke-buttons button {
  aspect-ratio: 1;
  min-height: 2.7rem;
  border-radius: 12px;
  border: 2px solid var(--card-line);
  background: var(--cream);
  font-family: var(--font-body);
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.06s ease, background 0.12s ease, border-color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.stroke-buttons button:active {
  transform: scale(0.93);
}

.stroke-buttons button.selected {
  background: linear-gradient(180deg, var(--fiesta-yellow), var(--fiesta-orange));
  border-color: var(--fiesta-orange);
  color: #4a2500;
  box-shadow: 0 2px 8px rgba(247, 127, 0, 0.4);
}

.hole-next-wrap {
  margin-top: 1.1rem;
}

.hole-hint {
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: #7b8a78;
  margin-top: 0.6rem;
}

/* ---------- play: card view ---------- */

.card-scroll {
  overflow-x: auto;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.5rem;
}

table.score-table {
  border-collapse: collapse;
  width: 100%;
  text-align: center;
  font-weight: 700;
  font-size: 0.92rem;
}

table.score-table th,
table.score-table td {
  border: 1px solid var(--card-line);
  padding: 0.42rem 0.45rem;
  min-width: 2.2rem;
}

table.score-table thead th {
  background: var(--green);
  color: var(--white);
  position: sticky;
  top: 0;
  font-size: 0.82rem;
  max-width: 5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

table.score-table th.hole-col {
  background: var(--cream-dark);
  color: var(--green-dark);
}

table.score-table .par-col {
  color: #8b978a;
  font-size: 0.82rem;
}

table.score-table tr.subtotal-row td,
table.score-table tr.subtotal-row th {
  background: var(--cream-dark);
  color: var(--green-dark);
  font-weight: 900;
}

table.score-table tr.total-row td,
table.score-table tr.total-row th {
  background: var(--green-dark);
  color: var(--fiesta-yellow);
  font-weight: 900;
  font-size: 1rem;
}

table.score-table td.under { color: var(--birdie); }
table.score-table td.over { color: var(--bogey); }
table.score-table td.ace {
  color: var(--fiesta-orange);
  font-weight: 900;
}
table.score-table td.current-hole-cell {
  background: #fff3d6;
}

.card-legend {
  display: flex;
  justify-content: center;
  gap: 1.1rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  font-weight: 800;
  margin-top: 0.8rem;
}

.card-legend .under { color: var(--birdie); }
.card-legend .over { color: var(--bogey); }
.card-legend .ace { color: var(--fiesta-orange); }

/* ---------- play: standings ---------- */

.standings-list {
  display: grid;
  gap: 0.8rem;
}

.standing-row {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.standing-row.leader {
  border: 2px solid var(--fiesta-orange);
  background: linear-gradient(180deg, #fffdf6, #fff3d6);
}

.standing-row .place {
  flex: 0 0 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: var(--cream-dark);
  color: var(--green-dark);
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.standing-row.leader .place {
  background: linear-gradient(180deg, var(--fiesta-yellow), var(--fiesta-orange));
  color: #4a2500;
}

.standing-row .s-info {
  flex: 1;
  min-width: 0;
}

.standing-row .s-name {
  font-weight: 900;
  color: var(--green-dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.standing-row .s-thru {
  font-size: 0.8rem;
  font-weight: 700;
  color: #7b8a78;
}

.standing-row .s-score {
  text-align: right;
}

.standing-row .s-total {
  font-weight: 900;
  font-size: 1.35rem;
  color: var(--ink);
  line-height: 1.1;
}

.standing-row .s-vspar {
  font-size: 0.8rem;
  font-weight: 800;
}

.s-vspar.is-under { color: var(--birdie); }
.s-vspar.is-par { color: var(--green); }
.s-vspar.is-over { color: var(--bogey); }

.standings-note {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #7b8a78;
  margin-top: 1rem;
}

/* ---------- finish screen ---------- */

.finish-hero {
  text-align: center;
  padding: 1.5rem 0 0.5rem;
}

.finish-hero .trophy {
  font-size: 3.6rem;
  animation: bounceIn 0.6s ease;
}

@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.finish-hero h2 {
  font-family: var(--font-display);
  color: var(--green-dark);
  font-size: 1.8rem;
  margin-top: 0.4rem;
}

.finish-hero .winner-name {
  font-family: var(--font-display);
  font-size: 2.2rem;
  background: linear-gradient(180deg, var(--fiesta-yellow) 15%, var(--fiesta-orange) 60%, var(--fiesta-red-orange) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(60, 30, 0, 0.25));
  margin: 0.2rem 0 0.4rem;
  word-break: break-word;
}

.finish-hero p {
  font-weight: 700;
  color: #5a6b57;
}

.finish-standings {
  margin-top: 1.5rem;
}

.finish-actions {
  display: grid;
  gap: 0.8rem;
  margin-top: 1.75rem;
}

.lb-submit {
  display: grid;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.lb-submit-note {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--green-dark);
}

.lb-submit-note.is-error {
  color: var(--bogey);
}

/* ---------- celebrations ---------- */

.celebrate-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 59, 30, 0.55);
  animation: overlayIn 0.2s ease;
  cursor: pointer;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.celebrate-overlay.leaving {
  animation: overlayOut 0.25s ease forwards;
}

@keyframes overlayOut {
  to { opacity: 0; }
}

.celebrate-card {
  background: var(--white);
  border-radius: 24px;
  border: 4px solid var(--fiesta-orange);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
  text-align: center;
  padding: 2rem 2.5rem;
  max-width: min(20rem, 84vw);
  animation: celebratePop 0.5s cubic-bezier(0.18, 1.4, 0.4, 1);
}

@keyframes celebratePop {
  0% { transform: scale(0.2) rotate(-8deg); opacity: 0; }
  70% { transform: scale(1.08) rotate(2deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.celebrate-emoji {
  font-size: 3.4rem;
  animation: emojiWiggle 0.7s ease 0.2s;
}

@keyframes emojiWiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-14deg) scale(1.15); }
  60% { transform: rotate(12deg) scale(1.1); }
}

.celebrate-label {
  font-family: var(--font-display);
  font-size: 1.7rem;
  line-height: 1.15;
  margin-top: 0.3rem;
  background: linear-gradient(180deg, var(--fiesta-yellow) 15%, var(--fiesta-orange) 60%, var(--fiesta-red-orange) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(60, 30, 0, 0.25));
}

.celebrate-name {
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--green-dark);
  margin-top: 0.35rem;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 55;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -4vh;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.95;
  animation: confettiFall linear forwards;
}

.confetti-piece.round {
  border-radius: 50%;
  width: 9px;
  height: 9px;
}

@keyframes confettiFall {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); }
  100% { transform: translate3d(var(--drift, 0px), 108vh, 0) rotate(var(--spin, 540deg)); opacity: 0.85; }
}

/* score button celebratory pop when selected */
.stroke-buttons button.selected {
  animation: selectedPop 0.25s cubic-bezier(0.2, 1.6, 0.5, 1);
}

@keyframes selectedPop {
  0% { transform: scale(0.85); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .celebrate-card,
  .celebrate-emoji,
  .stroke-buttons button.selected {
    animation: none;
  }
  .confetti-piece {
    display: none;
  }
}

/* ---------- soft serve upsells ---------- */

.treat-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 1.25rem;
  padding: 1rem 1.1rem;
  background: #f9f0b8;
  border: 2px dashed var(--fiesta-orange);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.treat-card:active {
  transform: scale(0.985);
}

.treat-emoji {
  font-size: 2.2rem;
  animation: emojiWiggle 2.8s ease infinite;
}

.treat-text strong {
  display: block;
  color: var(--green-dark);
  font-size: 1.05rem;
}

.treat-text span {
  font-size: 0.88rem;
  font-weight: 700;
  color: #6b7566;
  line-height: 1.4;
}

.turn-toast {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(4.2rem + env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--white);
  border: 2px solid var(--fiesta-orange);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(12, 59, 30, 0.35);
  padding: 0.8rem 0.9rem;
  text-decoration: none;
  color: var(--ink);
  max-width: 32rem;
  margin: 0 auto;
  animation: toastUp 0.35s cubic-bezier(0.2, 1.2, 0.4, 1);
}

@keyframes toastUp {
  from { transform: translateY(120%); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.turn-toast.leaving {
  animation: toastDown 0.3s ease forwards;
}

@keyframes toastDown {
  to { transform: translateY(130%); opacity: 0; }
}

.turn-toast .toast-emoji {
  font-size: 1.7rem;
}

.turn-toast .toast-text {
  flex: 1;
  font-size: 0.86rem;
  font-weight: 700;
  color: #5a6b57;
  line-height: 1.4;
}

.turn-toast .toast-text strong {
  color: var(--green-dark);
}

.turn-toast .toast-close {
  background: none;
  border: 0;
  font-size: 1rem;
  font-weight: 900;
  color: #8b978a;
  cursor: pointer;
  padding: 0.4rem;
  align-self: flex-start;
}

@media (prefers-reduced-motion: reduce) {
  .treat-emoji,
  .turn-toast {
    animation: none;
  }
}

/* ---------- confirm dialog ---------- */

dialog.confirm-dialog {
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  padding: 1.5rem;
  max-width: 20rem;
  width: calc(100vw - 3rem);
  font-family: var(--font-body);
  color: var(--ink);
}

dialog.confirm-dialog::backdrop {
  background: rgba(12, 59, 30, 0.5);
}

dialog.confirm-dialog p {
  font-weight: 700;
  margin-bottom: 1.1rem;
}

dialog.confirm-dialog .dialog-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}

dialog.confirm-dialog .btn {
  padding: 0.55rem 1.1rem;
  font-size: 0.95rem;
}
