/* Shared play tools. Header/footer chrome: shared/site-chrome.css. */

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.top h1 {
  font-size: 1.45rem;
  letter-spacing: 0.04em;
  margin: 0;
  font-weight: 600;
  line-height: 1.1;
}

.top .sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 10px;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.06em;
  font-size: 1rem;
}

.nav a:hover,
.nav a[aria-current="page"] { color: var(--ink); }

.meta { display: flex; gap: 8px; flex-wrap: wrap; }

.board-wrap { position: relative; }
.board-wrap.is-gated .board { visibility: hidden; }
.start-gate {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: none;
}
.start-gate[hidden],
.start-gate.is-dismissed { display: none !important; }
.start-card {
  width: min(360px, 92%);
  padding: 28px 8px 20px;
  border: 0;
  border-top: 1px solid var(--line, #d8cfc2);
  border-bottom: 1px solid var(--line, #d8cfc2);
  border-radius: 0;
  background: transparent;
  text-align: left;
  box-shadow: none;
  position: relative;
}
.start-card h2 { margin: 0 0 8px; font-size: 1.55rem; }
.start-lock-icon {
  display: inline-flex;
  width: 28px;
  height: 28px;
  margin: 0 8px 0 0;
  vertical-align: middle;
  color: var(--ink);
}
.start-lock-icon svg { width: 28px; height: 28px; }
.start-member-cta { text-decoration: none; }
.start-sub, .start-upgrade, .start-account-note { color: var(--muted, #6b645b); margin: 0 0 16px; line-height: 1.45; }
.start-account-note { font-size: 0.85rem; margin-top: -4px; }
.mode-switch {
  display: flex;
  gap: 18px;
  justify-content: flex-start;
  margin: 0 0 18px;
}
.mode-btn {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.mode-btn.is-on {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--accent);
  color: var(--ink);
  font-weight: 600;
}
.play-mode-badge.is-unranked {
  color: var(--muted);
  border-style: dashed;
}
.start-upgrade a { color: inherit; }
.start-card .err { margin: 0 0 12px; }
.start-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

.start-actions > button,
.start-actions > a {
  width: 100%;
}

.start-unlock-main {
  display: inline-flex;
  align-items: center;
}

.dig-amount-badge,
.start-gate .puzzle-cost-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  padding: 3px 9px;
  border: 1px solid color-mix(in srgb, var(--ink) 26%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper-bright, #FFF9E8) 90%, var(--cta, #C88708));
  font-weight: 700;
  line-height: 1;
}

/* Unlock CTA sits on a dark primary button. Keep its pale DIG badge
   self-contrasting instead of inheriting the button's light foreground. */
.start-gate #startGateBtn .puzzle-cost-badge {
  background: #FFF4CF;
  border-color: #D4A72C;
  color: #241A14 !important;
}

.start-gate #startGateBtn .puzzle-cost-badge .dig-compact-value,
.start-gate #startGateBtn .puzzle-cost-badge .puzzle-cost-value {
  color: #241A14 !important;
}

.dig-amount-coin,
.start-gate .puzzle-cost-coin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35em;
  height: 1.35em;
  border: 1px solid color-mix(in srgb, var(--cta, #C88708) 35%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--paper-bright, #FFF9E8) 60%, transparent);
}

.dig-amount-coin img,
.start-gate .puzzle-cost-coin img {
  width: 1.1em;
  height: 1.1em;
  display: block;
}

.start-unlock-extra {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line, #DDBB72);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink);
  background: transparent;
}

.start-unlock-extra.is-buy-dig {
  border-color: color-mix(in srgb, var(--cta, #C88708) 58%, var(--line, #DDBB72));
}

button,
select,
input[type="text"] { font-size: 1rem; }

button {
  font: inherit;
  color: var(--ink);
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  min-height: 44px;
  cursor: pointer;
}

button:hover { border-color: var(--btn-hover-line); background: var(--btn-hover); }
button.primary { background: var(--gold-fill); color: var(--ink-button); border-color: var(--gold-border); font-weight: 600; }
button.primary:hover { background: var(--gold-hover); border-color: var(--gold-border); }
button.ghost { opacity: 0.7; }
button.active { border-color: var(--gold); color: var(--gold); background: var(--gold-active); }

@media (max-width: 760px) {
  .top { align-items: flex-start; }
}

/* How to play pop — compact cream modal, not a page takeover. */
#rulesBtn,
.howto-pop-btn,
.play-help-btn {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-bright);
  color: var(--ink);
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  cursor: pointer;
}
#rulesBtn:hover,
.howto-pop-btn:hover,
.play-help-btn:hover {
  color: var(--ink);
  border-color: var(--cta);
  background: color-mix(in srgb, var(--cta) 12%, var(--paper-bright));
}
#rulesBtn:focus-visible,
.howto-pop-btn:focus-visible,
.play-help-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

@media (max-width: 760px) {
  #rulesBtn,
  .howto-pop-btn,
  .play-help-btn {
    width: 52px;
    min-width: 52px;
    min-height: 52px;
  }
}

.rules-pop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--paper) 45%, transparent);
  z-index: 20;
  padding: 24px 16px;
}
.rules-pop.hidden { display: none !important; }
.rules-pop-card, .rules-card {
  background: var(--paper-bright);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  max-width: 22rem;
  width: min(22rem, 100%);
  box-shadow: var(--shadow);
  color: var(--ink);
}

@media (max-width: 760px) {
  .rules-pop-card, .rules-card {
    width: var(--mobile-content-width, 95%);
    max-width: none;
  }
}
.rules-pop-body { font-size: 1.02rem; line-height: 1.45; }
.rules-pop-body p { margin: 0 0 8px; }
.rules-pop-body p:last-child { margin-bottom: 0; }
.rules-pop-body ul { margin: 0 0 8px; padding-left: 1.15em; }
.rules-pop-more { margin: 12px 0 10px; }
.rules-pop-more a { color: var(--ink); text-underline-offset: 3px; }
.rules-pop-card > button, .rules-card > button {
  font: inherit;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 8px 0;
  min-height: 44px;
  cursor: pointer;
}
.rules-pop-card > button, .rules-card > button:hover { color: var(--ink); }

/* Play chrome: compact secondary + overflow on phones */
.play-secondary {
  display: none;
}

.play-more {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.play-more .field { width: 100%; }
.play-more select { width: 100%; }

.more-btn {
  flex: 0 0 auto;
  min-width: 44px;
  padding: 8px 10px;
  font-weight: 600;
}

.is-parked { display: none !important; }

.board-legend {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  opacity: 0.7;
}

@media (max-width: 760px) {
  .app {
    width: var(--mobile-content-width, 95%);
    max-width: none;
    margin-left: auto;
    margin-right: auto;
    padding: 6px 0 16px;
  }

  .app .meta { display: none !important; }
  .toolbar[hidden] { display: none !important; }

  .play {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    gap: 6px;
    width: 100%;
  }

  .side { display: contents; }

  .clock {
    order: 0;
    width: 100%;
    font-size: 1.05rem;
    align-items: center;
    gap: 8px;
    min-height: 36px;
  }
  .clock #timer { letter-spacing: 0.04em; }
  .clock #pause {
    min-height: 36px;
    padding: 4px 10px;
    font-size: 0.86rem;
    margin-left: auto;
  }
  .clock .pill {
    padding: 3px 8px;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
  }

  .board-wrap { order: 1; width: 100%; }
  .board { width: 100%; }

  .keypad {
    order: 2;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .keypad button {
    min-width: 0;
    width: 100%;
    max-width: none;
    min-height: 48px;
    padding: 0;
    font-size: 1.2rem;
  }
  .app:has(#zeroBtn) .keypad {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100%;
    max-width: none;
    gap: 8px;
  }
  .app:has(#zeroBtn) .keypad button {
    min-height: 56px;
    font-size: 1.45rem;
  }

  .play-secondary {
    order: 3;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: stretch;
    width: 100%;
  }
  .play-secondary > button {
    flex: none;
    min-width: 0;
    width: 100%;
    padding: 10px 12px;
    min-height: 46px;
    font-size: 0.95rem;
    font-weight: 600;
  }
  .play-secondary kbd { display: none; }
  .play-secondary .more-btn {
    grid-column: 1 / -1;
    min-width: 0;
    font-weight: 500;
  }

  .play-more {
    order: 4;
    display: none;
  }
  .play-more:not([hidden]) {
    display: flex;
    margin-top: 0;
    padding: 10px;
    background: var(--paper-bright, var(--bg-2));
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
  }

  .hint-why, .status {
    order: 5;
    min-height: 0;
    font-size: 0.92rem;
  }
  .hint-why:empty, .status:empty { display: none; }

  .board-legend { display: none; }

  .toggles.is-parked,
  .actions.is-parked,
  .side .actions { display: none !important; }

  .pill { padding: 4px 10px; font-size: 0.78rem; }
}