/* Match the page colour so no white shows when iOS bounces past the edges. */
body.sheriff {
  background-color: #412304;
}

/*
 * The section is its own full-screen scroll area. Its background stays still while the content
 * scrolls inside it, which works on iOS where background-attachment: fixed and fixed layers do not.
 */
body.sheriff #gaming {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background-color: #412304;
  background-image: url("../img/sheriff/background.jpg");
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}

/* Leave room for the site sidebar on desktop. */
@media (min-width: 1200px) {
  body.sheriff #gaming {
    left: 300px;
  }
}

.start-page {
    position: relative;
    display: flex;
    cursor: pointer;
    text-align: center;
    justify-content: center;
}

.start-page img {
    max-width: 100%;
    z-index: 1;
    transition: opacity 0.3s;
    display: flex;
}

.start-page span {
    position: absolute;
    display: block;
    text-align: center;
    width: 100%;
    top: 54%;
    transform: translateY(-50%);
    font-size: 3vw;
    z-index: 2;
    color: #FFF;
    text-shadow: 0 2px rgba(0, 0, 0, .5);
    opacity: 1;
    transition: opacity 0.3s;
}

.start-page:hover span {
    opacity: 0.6;
}

/* Game pages (setup, play, scoring, result), styled to match Feed the Kraken and Avalon. */

.sheriff-menu {
  padding: 3rem 0;
  text-align: center;
}

.sheriff-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: 640px;
  margin: 0 auto 1.5rem auto;
}

/* For a nav bar with only a forward button. */
.sheriff-nav-end {
  justify-content: flex-end;
}

.sheriff-nav-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  font-weight: 600;
  color: #f6e2b3;
  text-decoration: none;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid #c9a15b;
  border-radius: 8px;
  box-shadow: 2px 2px 0 #000;
  cursor: pointer;
  transition: background 0.2s ease;
}

.sheriff-nav-button:hover,
.sheriff-nav-button:focus {
  color: #fff;
  background: #7a1f1f;
}

.sheriff-title {
  color: #f6e2b3;
  font-size: 2.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-shadow: 2px 2px 0 #000;
  margin-bottom: 0.5rem;
}

.sheriff-subtitle {
  max-width: 640px;
  margin: 0 auto 2rem auto;
  color: #e6dcc0;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-shadow: 1px 1px 0 #000;
}

.sheriff-group {
  max-width: 640px;
  margin: 0 auto 1.5rem auto;
  padding: 1rem;
  color: #f6e2b3;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 12px;
}

.sheriff-wide {
  max-width: 960px;
}

.sheriff-group h5 {
  color: #f6e2b3;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}

.sheriff-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.sheriff-button {
  flex: 1 1 160px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.9rem 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: #f6e2b3;
  text-decoration: none;
  background: #7a1f1f;
  border: 2px solid #c9a15b;
  border-radius: 8px;
  box-shadow: 2px 2px 0 #000;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.sheriff-button:hover,
.sheriff-button:focus {
  color: #fff;
  background: #962828;
}

.sheriff-button:active {
  transform: translateY(2px);
}

/* Setup */

.sheriff-field,
.sheriff-player-field-content {
  text-align: left;
}

.sheriff-label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
  color: #f6e2b3;
}

.sheriff-input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  /* At least 16px, or iOS zooms in on focus. */
  font-size: 16px;
  color: #f6e2b3;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid #c9a15b;
  border-radius: 8px;
}

.sheriff-input::placeholder {
  color: rgba(246, 226, 179, 0.5);
}

.sheriff-input:focus {
  outline: none;
  border-color: #f6e2b3;
  box-shadow: 0 0 0 3px rgba(201, 161, 91, 0.35);
}

.sheriff-input option {
  color: #000;
}

.sheriff-player-field {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
}

.sheriff-player-field + .sheriff-player-field {
  border-top: 1px solid rgba(201, 161, 91, 0.3);
}

.sheriff-player-field img {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.sheriff-player-field-content {
  flex: 1;
}

/* Play (round timer). The countdown classes are swapped by timer.js as time runs out. */

.sheriff-timer {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 240px;
  margin-bottom: 1rem;
  overflow: hidden;
  color: #fff;
  border: 2px solid #c9a15b;
  border-radius: 8px;
  box-shadow: 2px 2px 0 #000;
  transition: background 0.3s ease;
}

.sheriff-timer.countdown {
  background: linear-gradient(to bottom, #d99a3e 0%, #b8691f 100%);
}

.sheriff-timer.countdown-one-minute {
  background: linear-gradient(to bottom, #c0281e 0%, #6e1410 100%);
}

.sheriff-timer.countdown-finished {
  background: linear-gradient(to bottom, #000 0%, #282828 100%);
}

.sheriff-timer-img {
  height: 100%;
  width: auto;
  margin-left: -1rem;
}

.sheriff-timer-digits {
  align-self: center;
  padding-right: 1rem;
  font-size: clamp(3.5rem, 16vw, 7rem);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 3px 3px 0 #000;
}

/* Scoring */

.sheriff-player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.sheriff-player-bar .sheriff-nav-button {
  flex: 0 1 auto;
  min-width: 0;
  color: #fce38a;
}

.sheriff-player-current {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-width: 0;
}

.sheriff-player-current .background-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.sheriff-player-name {
  color: #fce38a;
  font-size: 1.25rem;
  font-weight: 700;
  text-shadow: 2px 2px 0 #000;
}

.sheriff-player-score {
  color: #f6e2b3;
  font-weight: 600;
}

/* On phones the current player gets its own row above the previous / next buttons. */
@media (max-width: 575px) {
  .sheriff-player-bar {
    flex-wrap: wrap;
  }

  .sheriff-player-current {
    order: -1;
    flex: 1 1 100%;
  }

  .sheriff-player-bar .sheriff-nav-button {
    flex: 1 1 0;
    justify-content: center;
  }
}

.sheriff-goods {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.75rem;
}

.sheriff-good {
  position: relative;
  padding: 0.5rem;
  font-size: 0.8rem;
  color: #fff;
  text-shadow: 0 2px rgba(0, 0, 0, 0.5);
  border: 2px solid #c9a15b;
  border-radius: 8px;
  box-shadow: 2px 2px 0 #000;
}

.sheriff-good-legal {
  background: #2f6b22;
}

.sheriff-good-contraband {
  background: #8f1c1c;
}

.sheriff-good-coin {
  background: #9a7a1e;
}

.sheriff-good .grid-img {
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.sheriff-good .text {
  margin: 0.5rem 0 0 0;
  font-weight: 600;
}

.scoring-container {
  touch-action: manipulation;
}

.scoring-count {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0;
  font-size: 80px;
  color: #fff;
  background: transparent;
  border: none;
  cursor: pointer;
  text-shadow: 2px 2px 0 #000;
}

.scoring-bonus-img {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 50px;
  height: 50px;
  display: none;
}

.scoring-decrement {
  position: absolute;
  top: -8px;
  right: -8px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 1.5rem;
  color: #f6e2b3;
  background: #7a1f1f;
  border: 2px solid #c9a15b;
  border-radius: 50%;
  box-shadow: 1px 1px 0 #000;
  cursor: pointer;
}

/* Result. The bars are built by result.js. */

.sheriff-results .counter-bar {
  position: relative;
  display: flex;
  align-items: center;
  height: 56px;
  margin-bottom: 0.5rem;
  overflow: hidden;
  border: 2px solid #c9a15b;
  border-radius: 8px;
  box-shadow: 2px 2px 0 #000;
}

.sheriff-results .counter-bar:last-child {
  margin-bottom: 0;
}

.sheriff-results .bar {
  flex: 1;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
}

.sheriff-results .progress {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(to bottom, #f0c64a 0%, #b8861f 100%);
  border-radius: 0;
  transition: width 1s;
}

.sheriff-results .player-image,
.sheriff-results .player-name,
.sheriff-results .gold-count,
.sheriff-results .gold-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.sheriff-results .player-image {
  left: 4px;
  height: 48px;
}

.sheriff-results .player-name {
  left: 64px;
  font-weight: 700;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
}

.sheriff-results .gold-count {
  right: 52px;
  font-weight: 700;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
}

.sheriff-results .gold-icon {
  right: 6px;
  height: 40px;
}
