/* «شکارچی طلا» (arcade.js), in its window over the club page, in Yalda's colours: the window in
   pomegranate, the stage the longest night, gold for what shines.

   The field is the same shape and the same in itself on every screen (arcade.js, FIELD_W ×
   FIELD_H, 16:10), drawn as big as the stage allows in its middle, so a round is as hard on a
   phone as on a computer. On a computer: the stage, and beside it the score, what to catch and
   the keys. A phone plays on its side: the stage takes the screen's height, the buttons and the
   numbers in a column beside it; held upright, the window asks for the phone to be turned. A
   small screen of another kind (a tablet upright, a narrow window) has a bar at the top and the
   stage under it. */

.arcade-shell {
  --a-wine: #4a0e1c;
  --a-pom: #9b1b30;
  --a-pom-hi: #b8283f;
  --a-gold: #c9a227;
  --a-gold-text: #8f6b0c;
  --a-cream: #fbf3e4;
  --a-muted: #8a7a7c;
  --a-text: #6b5a5c;

  position: fixed;
  inset: 0;
  z-index: 900;
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.16), transparent 45%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0 14px, transparent 14px 28px),
    linear-gradient(135deg, var(--a-pom-hi), var(--a-pom) 55%, #7e1627);
  color: #fff;
  font-family: 'Kalameh', Tahoma, sans-serif;
  direction: rtl;
  opacity: 0;
  transition: opacity 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.arcade-shell.is-open {
  opacity: 1;
}

/* sizes include padding and borders, as on the main site the game comes from */
.arcade-shell,
.arcade-shell *,
.arcade-shell *::before,
.arcade-shell *::after {
  box-sizing: border-box;
}

/* the page under it stays where it was, and does not scroll or bounce with the game */
html.is-arcade-open,
html.is-arcade-open body {
  overscroll-behavior: none;
}

@media (hover: hover), (pointer: fine) {
  html.is-arcade-open,
  html.is-arcade-open body {
    overflow: hidden;
  }
}

/* On a touch screen the page under the game is left free to scroll (a phone's browser hides its
   bars only as its page scrolls, see .arcade__swipe), and the game itself takes every touch: no
   swipe on it moves the page */
@media (hover: none) and (pointer: coarse) {
  .arcade-shell {
    touch-action: none;
  }
}

.arcade {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 16px 28px 20px;
  font-family: 'Kalameh', Tahoma, sans-serif;
  color: #fff;
}

.arcade__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.arcade__head h1 {
  margin: 0;
  font-size: 34px;
  font-weight: bold;
  line-height: 1.35;
  text-shadow: 0 2px 0 rgba(60, 8, 20, 0.35);
}

.arcade__head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* back to the page */
.arcade__back {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--a-pom);
  font: inherit;
  font-size: 15px;
  font-weight: bold;
  box-shadow: 0 6px 18px rgba(60, 8, 20, 0.2);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.arcade__back:hover {
  transform: translateY(-1px);
}

.arcade__back:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

/* pause, in the top bar on a phone only (the keys' panel has it on a computer) */
.arcade__pause {
  display: none;
}

.arcade__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 306px;
  gap: 18px;
  align-items: start;
}

/* ------------------------------------------------------------------------------ stage -- */

.arcade__stage {
  position: relative;
  aspect-ratio: 16 / 10;
  max-height: calc(100vh - 106px);
  min-height: 360px;
  overflow: hidden;
  border-radius: 24px;
  /* the band round the field, where the stage is not of its shape */
  background: #14050b;
  box-shadow:
    0 24px 60px rgba(60, 8, 20, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  outline: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* the field: its size and place set by arcade.js (resize) */
.arcade__stage > canvas {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  border-radius: 14px;
  touch-action: none;
}

.arcade__stage.is-playing > canvas {
  cursor: none;
}

.arcade__screen {
  position: absolute;
  inset: 0;
  display: flex;
  overflow-y: auto;
  padding: 24px;
  background: rgba(28, 7, 16, 0.6);
  text-align: center;
  opacity: 0;
  visibility: hidden;
  touch-action: pan-y;
  transition:
    opacity 0.25s ease,
    visibility 0s linear 0.25s;
}

.arcade__screen.is-active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease;
}

.arcade__card {
  width: min(430px, 100%);
  margin: auto;
  padding: 28px 28px 24px;
  border-radius: 22px;
  background: #fff;
  color: var(--a-wine);
  box-shadow: 0 20px 50px rgba(20, 4, 10, 0.45);
  transform: translateY(10px) scale(0.97);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.arcade__screen.is-active .arcade__card {
  transform: none;
}

.arcade__badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  background: #fbf3d9;
  color: var(--a-gold-text);
  font-size: 13px;
  font-weight: 600;
}

.arcade__card h2 {
  margin: 10px 0 8px;
  font-size: 28px;
  font-weight: bold;
  color: var(--a-pom);
}

.arcade__card p {
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.9;
  color: var(--a-text);
}

.arcade__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.arcade__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 150px;
  padding: 12px 24px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--a-pom-hi), var(--a-pom));
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 0.15s ease,
    opacity 0.15s ease;
}

.arcade__btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.arcade__btn:focus-visible {
  outline: 3px solid #e3a0ab;
  outline-offset: 3px;
}

.arcade__btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.arcade__btn--ghost {
  background: #f9e9eb;
  color: var(--a-pom);
}

.arcade__btn--ghost:hover {
  background: #f3d9dd;
}

.arcade__hint {
  display: block;
  margin-top: 14px;
  font-size: 13px;
  color: var(--a-muted);
}

/* the hint for a mouse and keys, or for a finger */
.arcade__hint--touch {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .arcade__hint--keys {
    display: none;
  }

  .arcade__hint--touch {
    display: block;
  }
}

/* «تغییر نام یا شماره»: a quiet line a little way under the button (.arcade__card in front: the
   card's own `p` margin would win over the class alone and set it against the button) */
.arcade__card .arcade__who {
  margin-top: 24px;
}

.arcade__who {
  display: flex;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--a-cream);
  color: var(--a-muted);
  font-size: 13px;
  line-height: 1.7;
}

.arcade__who-change {
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--a-pom);
  font: inherit;
  font-weight: bold;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 5px;
  cursor: pointer;
  touch-action: manipulation;
}

.arcade__who-change:hover {
  text-decoration-style: solid;
}

.arcade__who-change:focus-visible {
  outline: 2px solid #e3a0ab;
  outline-offset: 2px;
  border-radius: 4px;
}

/* a round that could not start, or whose score is on its way or did not get there */
.arcade__error,
.arcade__note {
  margin: 0 0 16px;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--a-text);
}

.arcade__error,
.arcade__note.is-error {
  color: #b42318;
}

.arcade kbd {
  display: inline-block;
  min-width: 26px;
  padding: 1px 7px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.18);
  color: inherit;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
  direction: ltr;
  box-shadow: none;
}

.arcade__card kbd {
  border-color: #ecdfcb;
  background: var(--a-cream);
  color: var(--a-pom);
}

/* the round's end */
.arcade__record {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--a-gold);
  color: var(--a-wine);
  font-size: 13px;
  font-weight: bold;
  animation: arcade-pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

.arcade__record[hidden] {
  display: none;
}

.arcade__final {
  margin: 4px 0 2px;
  font-size: 64px;
  font-weight: bold;
  line-height: 1.2;
  color: var(--a-pom);
}

.arcade__final-label {
  display: block;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--a-muted);
}

.arcade__summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 22px;
}

.arcade__summary div {
  padding: 10px 6px;
  border-radius: 12px;
  background: var(--a-cream);
}

.arcade__summary dt {
  font-size: 12px;
  font-weight: normal;
  color: var(--a-muted);
}

.arcade__summary dd {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: bold;
  color: var(--a-pom);
}

/* ------------------------------------------------------------------------------- side -- */

.arcade__side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.arcade__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.arcade__stat {
  padding: 12px 6px 10px;
  border-radius: 16px;
  background: #fff;
  color: var(--a-wine);
  text-align: center;
  box-shadow: 0 8px 20px rgba(60, 8, 20, 0.15);
}

.arcade__stat span {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
  color: var(--a-muted);
}

.arcade__stat strong {
  display: inline-block;
  font-size: 24px;
  font-weight: bold;
  color: var(--a-wine);
}

.arcade__stat--score strong {
  color: var(--a-pom);
}

.arcade__stat.is-low strong {
  color: #d92d20;
  animation: arcade-tick 1s ease-in-out infinite;
}

.arcade__guide,
.arcade__controls {
  padding: 16px 16px 14px;
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(60, 8, 20, 0.15);
}

.arcade__guide {
  background: #fff;
  color: var(--a-wine);
}

.arcade__guide h3,
.arcade__controls h3 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: bold;
}

.arcade__guide h3 {
  color: var(--a-pom);
}

.arcade__guide ul,
.arcade__mini-guide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.arcade__guide li,
.arcade__mini-guide li {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 7px;
  border-radius: 12px;
  background: var(--a-cream);
  text-align: right;
}

.arcade__guide li.arcade__guide-bad,
.arcade__mini-guide li.arcade__guide-bad {
  grid-column: 1 / -1;
  background: #fff1f0;
}

.arcade__guide canvas,
.arcade__mini-guide canvas {
  flex: none;
  width: 40px;
  height: 40px;
}

.arcade__guide b,
.arcade__mini-guide b {
  display: block;
  font-size: 13px;
  font-weight: bold;
  line-height: 1.5;
  color: var(--a-wine);
}

.arcade__guide small,
.arcade__mini-guide small {
  display: block;
  font-size: 12px;
  line-height: 1.5;
  color: var(--a-muted);
}

.arcade__guide-bad small {
  color: #c4322b !important;
}

.arcade__tip {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--a-text);
}

/* on a computer the start card needs no guide: it is beside the stage */
.arcade__mini-guide {
  display: none;
}

/* the keys: keycaps that go down as they are pressed */
.arcade__controls {
  background: linear-gradient(160deg, #6e1424, #3d0a17);
  color: #fff;
}

.arcade__controls ul {
  display: grid;
  gap: 7px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.arcade__controls li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}

.arcade__controls small {
  font-size: 12px;
  opacity: 0.75;
}

.arcade__caps {
  display: flex;
  flex: none;
  justify-content: flex-end;
  gap: 4px;
  width: 76px;
  direction: ltr;
}

.arcade .arcade__controls kbd {
  min-width: 34px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid #ecdfcb;
  border-bottom-width: 4px;
  border-radius: 8px;
  background: linear-gradient(#ffffff, #f8efe0);
  color: var(--a-wine);
  font-size: 13px;
  font-weight: bold;
  line-height: 25px;
  transition:
    transform 0.08s ease,
    border-bottom-width 0.08s ease,
    background 0.08s ease;
}

.arcade .arcade__controls kbd.arcade__cap-wide {
  min-width: 76px;
}

.arcade .arcade__controls kbd.is-pressed {
  transform: translateY(3px);
  border-bottom-width: 1px;
  background: linear-gradient(#fbf3d9, #f5e6b8);
  color: var(--a-gold-text);
}

.arcade__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 16px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #e0bb4a, var(--a-gold));
  color: #3d0a17;
  font: inherit;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    opacity 0.15s ease;
}

.arcade__toggle:hover:not(:disabled) {
  transform: translateY(-1px);
}

.arcade__toggle:focus-visible,
.arcade__pause:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.arcade__toggle:disabled {
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.6);
  cursor: default;
}

.arcade__toggle-play,
.is-paused > .arcade__toggle-pause {
  display: none;
}

.is-paused > .arcade__toggle-play {
  display: block;
}

@keyframes arcade-pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}

@keyframes arcade-tick {
  50% {
    transform: scale(1.12);
  }
}

/* --------------------------------------------------------- a phone, or a small screen -- */

@media (max-width: 900px), (max-height: 560px) {
  .arcade {
    gap: 8px;
    height: 100%;
    min-height: 0;
    padding:
      calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right))
      calc(10px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
  }

  .arcade-shell {
    overflow: hidden;
  }

  .arcade__head {
    gap: 8px;
  }

  .arcade__head h1 {
    font-size: 20px;
    white-space: nowrap;
  }

  .arcade__head-actions {
    gap: 8px;
  }

  .arcade__back {
    padding: 8px 14px;
    font-size: 13.5px;
  }

  /* pause: a round white button beside «بازگشت» */
  .arcade__pause {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: var(--a-pom);
    box-shadow: 0 6px 18px rgba(60, 8, 20, 0.2);
    cursor: pointer;
    touch-action: manipulation;
  }

  .arcade__pause:disabled {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.6);
    box-shadow: none;
    cursor: default;
  }

  .arcade__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    min-height: 0;
  }

  /* the numbers above the stage, the stage as big as is left */
  .arcade__side {
    order: -1;
    gap: 0;
  }

  .arcade__guide,
  .arcade__controls {
    display: none;
  }

  .arcade__stats {
    gap: 6px;
  }

  .arcade__stat {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
    padding: 7px 4px;
    border-radius: 12px;
  }

  .arcade__stat span {
    margin: 0;
    font-size: 11.5px;
  }

  .arcade__stat strong {
    font-size: 18px;
  }

  .arcade__stage {
    flex: 1;
    height: auto;
    aspect-ratio: auto;
    max-height: none;
    min-height: 240px;
    border-radius: 18px;
  }

  .arcade__screen {
    padding: 12px;
  }

  .arcade__card {
    padding: 20px 16px 18px;
    border-radius: 18px;
  }

  .arcade__card h2 {
    margin: 8px 0 6px;
    font-size: 23px;
  }

  .arcade__card p {
    margin-bottom: 14px;
    font-size: 14px;
    line-height: 1.8;
  }

  .arcade__final {
    font-size: 48px;
  }

  .arcade__summary dd {
    font-size: 18px;
  }

  .arcade__btn {
    min-width: 132px;
    padding: 12px 18px;
  }

  /* what to catch, on the start card */
  .arcade__mini-guide {
    display: grid;
    margin: 0 0 16px;
  }

  .arcade__mini-guide li {
    padding: 5px 6px;
  }

  .arcade__mini-guide canvas {
    width: 34px;
    height: 34px;
  }

  .arcade__mini-guide b {
    font-size: 12.5px;
  }

  .arcade__mini-guide small {
    font-size: 11.5px;
  }
}

/* a phone on its side: the stage the whole height of the screen, and beside it a column with the
   buttons over the numbers; the title left out */
@media (max-height: 560px) and (orientation: landscape) {
  .arcade {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 112px;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
  }

  .arcade__body {
    display: contents;
  }

  .arcade__head {
    grid-column: 2;
    grid-row: 1;
    justify-content: center;
  }

  .arcade__head h1,
  .arcade__back-label {
    display: none;
  }

  /* «بازگشت» as a round button, beside pause */
  .arcade__back {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
  }

  .arcade__stage {
    grid-column: 1;
    grid-row: 1 / span 2;
    min-height: 0;
    border-radius: 16px;
  }

  .arcade__side {
    grid-column: 2;
    grid-row: 2;
    order: 0;
  }

  .arcade__stats {
    grid-template-columns: 1fr;
  }

  .arcade__stat {
    flex-direction: column;
    align-items: center;
    gap: 0;
  }

  /* the cards as short as the stage: what to catch is in the guide on the start card no more */
  .arcade__mini-guide,
  [data-screen='start'] .arcade__card p:not(.arcade__error):not(.arcade__who),
  [data-screen='pause'] .arcade__card p:not(.arcade__error) {
    display: none;
  }

  .arcade__card {
    padding: 14px 16px;
  }

  .arcade__card h2 {
    margin: 6px 0 12px;
    font-size: 21px;
  }

  .arcade__hint {
    margin-top: 10px;
  }

  .arcade__card .arcade__who {
    margin-top: 18px;
  }

  .arcade__who {
    padding: 4px 10px;
    font-size: 12.5px;
  }

  .arcade__final {
    font-size: 38px;
  }

  .arcade__final-label {
    margin-bottom: 10px;
  }

  .arcade__summary {
    margin-bottom: 12px;
  }
}

/* a phone held upright: the game is played on its side, the same field as everyone's */
.arcade__rotate {
  display: none;
}

@media (hover: none) and (pointer: coarse) and (orientation: portrait) and (max-width: 600px) {
  .arcade__rotate {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 32px 28px;
    text-align: center;
  }

  .arcade__rotate > svg {
    width: 84px;
    height: 84px;
    animation: arcade-turn 2.4s ease-in-out infinite;
  }

  .arcade__rotate h2 {
    margin: 0;
    font-size: 24px;
    font-weight: bold;
  }

  /* what is behind it is not for now */
  .arcade-shell .arcade {
    display: none;
  }
}

/* A phone on its side whose browser still shows its bars (an iPhone's Safari has no full screen
   for a page, and an Android browser that was not allowed it): they go once the page is swiped
   up, so the game asks for that, and lets the swipe through to the page under it */
.arcade__swipe {
  display: none;
}

.arcade-shell.is-swipe {
  overflow: visible;
  touch-action: pan-y;
}

.arcade-shell.is-swipe .arcade {
  display: none;
}

.arcade-shell.is-swipe .arcade__swipe {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  touch-action: pan-y;
}

.arcade__swipe svg {
  width: 56px;
  height: 56px;
  animation: arcade-swipe 1.6s ease-in-out infinite;
}

.arcade__swipe h2 {
  margin: 0;
  font-size: 22px;
  font-weight: bold;
}

/* if the bars will not go, the game is played with them */
.arcade__swipe-skip {
  margin-top: 6px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

@keyframes arcade-swipe {
  0% {
    transform: translateY(14px);
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    transform: translateY(-14px);
    opacity: 0;
  }
}

@keyframes arcade-turn {
  0%,
  20% {
    transform: rotate(0);
  }
  50%,
  80% {
    transform: rotate(-90deg);
  }
  100% {
    transform: rotate(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .arcade-shell,
  .arcade__screen,
  .arcade__card,
  .arcade__btn,
  .arcade__toggle,
  .arcade .arcade__controls kbd {
    transition: none;
  }

  .arcade__record,
  .arcade__stat.is-low strong,
  .arcade__rotate > svg,
  .arcade__swipe svg {
    animation: none;
  }
}
