/* Team game (js/game.js). Nothing here shows until a game is turned on from the settings button. */

/* settings menu under the gear */
.settings-menu {
  position: absolute; z-index: 60; min-width: 250px; background: #fff; color: #222;
  border: 1px solid #e3e3e3; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .16); padding: 6px;
}
.sm-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; background: none;
  border-radius: 8px; cursor: pointer; text-align: start; color: #222; font: inherit;
}
.sm-item:hover { background: #f2f2f2; }
.sm-item svg { color: #563599; flex: none; }
.sm-item b { display: block; font-size: 15px; }
.sm-item small { display: block; color: #777; font-size: 12.5px; margin-top: 1px; }

/* while a game is on */
body.game-on #pop-reveal { display: none !important; }
body.game-turn .pop-head { display: none; }
.pop-skip { display: none; }
body.game-turn .pop-skip { display: inline-flex; margin-inline-start: auto; }
.pop-foot .btn.pop-skip { background: #fff; border-color: #e0b4ba; color: #a3192a; }
.pop-foot .btn.pop-skip:hover { background: #fdecee; }
body.game-turn .line-arrows { visibility: hidden; }
body.game-on #done-x { display: none; }
body.game-on .zone.open { cursor: default; }

/* team bar above the music */
/* the teams sit inside the line bar, at its far end: one bar, not two */
.gamebar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-inline-start: auto; min-width: 0;
}
.gb-teams { justify-content: flex-end; }
/* the whole chorale on screen: the bar stays for the teams, without the line arrows */
body.game-on #linebar[hidden] { display: flex !important; }
body.game-on #linebar[hidden] .line-arrows, body.game-on #linebar[hidden] .line-pos { display: none; }
.gb-teams { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; min-width: 0; }
.gb-team {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 6px 5px 12px; border-radius: 99px;
  border: 1px solid #dedede; background: #fafafa; font-size: 14px; color: #444; transition: background .25s, color .25s;
}
.gb-team.cur { background: #222; border-color: #222; color: #fff; }
.gb-pts {
  min-width: 28px; padding: 1px 7px; border-radius: 99px; background: #fff; color: #222; text-align: center;
  font-variant-numeric: tabular-nums; font-size: 14px; border: 1px solid #e3e3e3;
}
.gb-team.cur .gb-pts { border-color: #fff; }
.gb-pts.bump { animation: gb-bump .45s ease; }
@keyframes gb-bump { 40% { transform: scale(1.35); } }
.gb-round { color: #888; font-size: 13.5px; white-space: nowrap; }
.gb-end {
  border: 1px solid #d6d6d6; background: #fff; color: #333; border-radius: 8px; padding: 5px 12px;
  font: inherit; font-size: 13.5px; cursor: pointer;
}
.gb-end:hover { background: #f2f2f2; }

/* the hourglass: on a wide screen it stands in a left margin of its own, beside the music */
@media (min-width: 901px) {
  body.game-on #stage { padding-left: 170px; }
}
.hourglass {
  position: fixed; z-index: 25; left: max(30px, env(safe-area-inset-left, 0px)); top: 50%; transform: translateY(-40%);
  width: 110px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
  filter: drop-shadow(0 8px 14px rgba(40, 20, 90, .22));
}
.hg-body { width: 100%; transform-origin: 50% 50%; }
.hg-svg { display: block; width: 100%; height: auto; overflow: visible; }
.hg-stream { opacity: 0; }
.hourglass.flowing .hg-stream { opacity: 1; animation: hg-flow .35s linear infinite; }
@keyframes hg-flow { to { stroke-dashoffset: -9; } }
.hg-time {
  font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; color: #222; background: #fff;
  border: 1px solid #e3e3e3; border-radius: 99px; padding: 2px 14px; min-width: 64px; text-align: center;
}
.hourglass.hurry .hg-time { color: #c62a3a; border-color: #f0b7bd; animation: hg-pulse 1s ease-in-out infinite; }
@keyframes hg-pulse { 50% { transform: scale(1.08); } }
.hg-float {
  position: absolute; top: 30%; left: 50%; transform: translateX(-50%); font-size: 26px; font-weight: 800;
  animation: hg-rise 1.1s ease-out forwards;
}
.hg-float.good { color: #17914a; }
.hg-float.bad { color: #c62a3a; }
@keyframes hg-rise { from { opacity: 0; transform: translate(-50%, 10px); } 20% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -48px); } }
/* narrow screen: a small hourglass at the start of the team bar, which stays at the top */
.hourglass.inline {
  position: relative; left: auto; top: auto; transform: none; z-index: auto; width: auto;
  flex-direction: row; gap: 6px; filter: drop-shadow(0 3px 5px rgba(40, 20, 90, .2));
}
.hourglass.inline .hg-body { width: 30px; }
.hourglass.inline .hg-time { font-size: 15px; padding: 1px 9px; min-width: 0; }
.hourglass.inline .hg-float { top: -6px; left: 15px; font-size: 18px; }
@media (max-width: 900px) {
  .gamebar { flex-wrap: nowrap; gap: 8px; }
  .gb-teams { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
  .gb-team { flex: none; padding: 3px 4px 3px 10px; gap: 6px; }
  .gb-round { display: none; }
  .gb-end { padding: 4px 8px; font-size: 13px; flex: none; }
}
@media (max-width: 560px) { .gb-word { display: none; } }
@media (max-width: 900px) {
  body.game-on #linebar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; box-shadow: 0 2px 8px rgba(0, 0, 0, .06); padding: 8px 10px; }
  .gamebar { flex: 1 1 100%; margin-inline-start: 0; }
}

/* cards: setup, the next turn, the winner */
.game-back {
  position: fixed; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(255, 255, 255, .55); backdrop-filter: blur(2px);
}
.game-card {
  width: min(380px, 100%); background: #fff; border: 1px solid #e3e3e3; border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .18); padding: 22px 24px 20px; text-align: center; color: #222;
  animation: gc-in .25s ease-out;
}
@keyframes gc-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.gc-title { margin: 2px 0 6px; font-size: 26px; text-wrap: balance; }
.gc-sub { margin: 0 0 14px; color: #666; font-size: 14.5px; }
.gc-small { display: block; color: #777; font-size: 13.5px; }
.gc-big { font-size: 22px; margin: 2px 0; }
.gc-big b { font-variant-numeric: tabular-nums; }
.gc-result { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid #eee; }
.gc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid #f0f0f0; }
.gc-label { font-size: 15px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid #d6d6d6; background: #fff; font-size: 20px;
  line-height: 1; cursor: pointer; color: #222;
}
.stepper button:disabled { opacity: .35; cursor: default; }
.st-n { min-width: 34px; font-size: 20px; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; border: 1px solid #d6d6d6; border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 10px; font: inherit; font-size: 13.5px; cursor: pointer; color: #333; }
.seg button + button { border-inline-start: 1px solid #d6d6d6; }
.seg button.sel { background: #222; color: #fff; }
.gc-rules { list-style: none; margin: 6px 0 0; padding: 10px 0 0; border-top: 1px solid #f0f0f0; color: #555; font-size: 14px; text-align: start; }
.gc-rules li { padding: 2px 0; }
.gc-rules b { display: inline-block; min-width: 26px; }
.gc-rules .good { color: #17914a; } .gc-rules .bad { color: #c62a3a; }
.gc-actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.gc-btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid #d6d6d6; background: #fff; color: #222;
  border-radius: 10px; padding: 9px 18px; font: inherit; font-size: 15px; cursor: pointer;
}
.gc-btn:hover { background: #f2f2f2; }
.gc-btn.primary { background: #222; border-color: #222; color: #fff; font-weight: 600; }
.gc-btn.primary:hover { background: #444; }
.turn .gc-start { padding: 12px 30px; font-size: 18px; }
.gc-link { margin-top: 12px; border: 0; background: none; color: #888; font: inherit; font-size: 13.5px; cursor: pointer; text-decoration: underline; }
.gc-trophy { display: inline-block; color: #e3a524; margin-bottom: 2px; }
.gc-rank { list-style: none; margin: 10px 0 0; padding: 0; text-align: start; }
.gc-rank li { display: flex; justify-content: space-between; padding: 7px 12px; border-radius: 8px; font-size: 15px; }
.gc-rank li:nth-child(odd) { background: #fafafa; }
.gc-rank li.win { background: #fff6e0; font-weight: 700; }
.gc-rank b { font-variant-numeric: tabular-nums; }
.hourglass[hidden], .gamebar[hidden] { display: none !important; }

/* listening to the line before the game starts */
.listen-bar {
  position: fixed; z-index: 44; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; background: #222; color: #fff;
  border-radius: 99px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); font-size: 15px; white-space: nowrap;
  animation: gc-in .25s ease-out;
}
.lb-icon { display: inline-flex; color: #e3a524; }
.lb-skip { border: 0; background: #fff; color: #222; border-radius: 99px; padding: 6px 14px; font: inherit; font-size: 14px; cursor: pointer; }
.lb-skip:hover { background: #eee; }

/* the key of a new line, for five seconds */
.key-toast {
  position: fixed; z-index: 46; left: 50%; top: 150px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; padding: 12px 24px; background: #fff; color: #222;
  border: 1px solid #e3e3e3; border-inline-start: 4px solid #563599; border-radius: 14px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .18); pointer-events: none; animation: kt-in .35s ease-out; transition: opacity .4s;
  max-width: calc(100vw - 32px); flex-wrap: wrap; justify-content: center;
}
.key-toast.out { opacity: 0; }
.kt-row { display: flex; flex-direction: column; align-items: center; }
.kt-row small { color: #777; font-size: 13px; }
.kt-row b { font-size: 24px; }
.kt-arrow { color: #aaa; font-size: 20px; }
@keyframes kt-in { from { opacity: 0; transform: translate(-50%, -10px) scale(.96); } }
@media (max-width: 900px) { .key-toast { top: 40%; } }
.gb-short { display: none; }
@media (max-width: 560px) { .gb-long { display: none; } .gb-short { display: inline; } .gb-team { padding: 3px 3px 3px 8px; gap: 4px; } .gb-pts { min-width: 24px; padding: 1px 5px; } }
body.game-on #cad-reveal { display: none !important; }
body.game-on .cad.open { cursor: default; }
