/* Everything visual here is Kenney's (CC0): the sky, the UI pack's panels,
   buttons and fields stretched as nine-slice images, its icons, and the
   portraits of the characters. The stylesheet only arranges them and tints
   them (a Kenney shape used as a mask, filled with a colour).

   One font: the device's own, which reads best on a phone (Kenney's fonts
   are capitals only). Two weights, 400 and 700, and three sizes: 17px for
   text, 20px for headings and the important line, 28px for the name and the
   banners. One spacing scale (4, 8, 12, 16) and three control sizes: 56px for
   buttons and fields, 44px for small square buttons, 52px for icon buttons
   and player chips. Kenney's panels and buttons have a 6px ledge at the
   bottom, which the paddings allow for. */

:root {
  --ink: #2f3442;
  --ink-soft: #626a7d;
  --red: #b8392d;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --big: 20px;
  --huge: 28px;
  --panel-face: #dadce7;
  --control: 56px;
  --small: 44px;
  --chip: 52px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  font-family: var(--text);
  font-size: 17px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  background: #cfeefb url("/kenney/bg/backgroundEmpty.png") center bottom / cover no-repeat fixed;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
  font-weight: 700;
}

h1 {
  font-size: var(--huge);
}

h2 {
  font-size: var(--big);
}

b,
strong {
  font-weight: 700;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.noscript {
  padding: 24px;
}

.muted {
  color: var(--ink-soft);
  text-align: center;
}

.problem {
  color: var(--red);
}

.problem:empty {
  display: none;
}

.stack > * + * {
  margin-top: 12px;
}

/* --- Kenney UI pack pieces --------------------------------------------------- */

/* A matching colour under every stretched Kenney panel, so no seams show. */
.panel,
.bar,
.banner {
  background: var(--panel-face) padding-box;
}

.panel {
  border-style: solid;
  border-width: 12px 12px 18px;
  border-image: url("/kenney/ui/grey-button_square_depth_flat.png") 24 24 36 24 fill / 12px 12px 18px stretch;
  padding: 12px;
}

button,
.button {
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  line-height: 1.2;
  width: 100%;
  min-height: var(--control);
  padding: 0 16px;
  color: var(--ink);
  background: none;
  border-style: solid;
  border-width: 12px 14px 18px;
  border-image: url("/kenney/ui/grey-button_rectangle_depth_flat.png") 24 28 36 28 fill / 12px 14px 18px stretch;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:active,
.button:active {
  transform: translateY(3px);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.primary {
  color: #ffffff;
  border-image-source: url("/kenney/ui/green-button_rectangle_depth_flat.png");
  text-shadow: 0 2px 0 rgb(0 0 0 / 0.2);
}

button.big,
.button.big {
  min-height: 64px;
  font-size: var(--big);
}

input {
  font: inherit;
  height: var(--control);
  width: 100%;
  padding: 0 8px;
  color: var(--ink);
  background: none;
  border-style: solid;
  border-width: 12px;
  border-image: url("/kenney/ui/input_rectangle.png") 24 fill / 12px stretch;
}

input::placeholder {
  color: var(--ink-soft);
  font-weight: 400;
}

input:focus,
input:focus-visible {
  outline: none;
  border-image-source: url("/kenney/ui/input_outline_rectangle.png");
}

/* Kenney icons are white; on grey buttons they are shown dark. */
.icon {
  width: 24px;
  height: 24px;
  flex: none;
  filter: brightness(0.25);
}

.primary .icon {
  filter: none;
}

/* A character's Kenney portrait. */
.face {
  width: 32px;
  height: 32px;
  flex: none;
}

/* The player's colour: Kenney's token icon, filled with that colour. */
.token {
  width: 14px;
  height: 14px;
  flex: none;
  background: var(--c, var(--ink));
  -webkit-mask: url("/kenney/ui/icons/token.png") center / contain no-repeat;
  mask: url("/kenney/ui/icons/token.png") center / contain no-repeat;
}

.devlink {
  word-break: break-all;
}

/* --- the frame: the board behind everything -------------------------------- */

#app > canvas.board {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.layer {
  position: relative;
  z-index: 1;
}

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

.start-layer {
  min-height: 100vh;
  pointer-events: none;
}

.start {
  width: min(420px, 100%);
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  min-height: 100vh;
}

.start > * {
  pointer-events: auto;
}

/* The name and the person icon, on a panel so they read over the trees. */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 0 0 8px;
}

.header .logo-icon {
  width: 32px;
  height: 32px;
  filter: brightness(0.25);
}

.header h1 {
  white-space: nowrap;
}

.header .account-button {
  margin-left: auto;
}

/* The buttons sit at the bottom, within thumb reach. */
.start .play,
.start .carry-on {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.start .carry-on {
  padding-bottom: 8px;
}

.game-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.game-row .button {
  flex: 1;
  min-width: 0;
}

.game-row .leave {
  margin-top: 6px;
}

.sheet .faces {
  display: flex;
  justify-content: center;
}

.sheet .faces .face {
  width: 44px;
  height: 44px;
}

.sheet .faces .face + .face {
  margin-left: -12px;
}

/* Leaving: Kenney's red button. */
.danger {
  color: #ffffff;
  border-image-source: url("/kenney/ui/red-button_rectangle_depth_flat.png");
  text-shadow: 0 2px 0 rgb(0 0 0 / 0.2);
}

.carry-on .faces {
  display: inline-flex;
}

.carry-on .faces .face {
  width: 28px;
  height: 28px;
}

.carry-on .faces .face + .face {
  margin-left: -14px;
}

.carry-on .button {
  white-space: nowrap;
}

/* You, then the computer players you will meet, then fewer and more. */
.lineup {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lineup .me {
  width: var(--control);
  height: var(--control);
  min-height: 0;
  flex: none;
}

.lineup .me .face {
  width: 44px;
  height: 44px;
}

.lineup .computers {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.lineup .computers .face {
  width: 40px;
  height: 40px;
  flex: none;
}

.lineup .computers .face + .face {
  margin-left: -16px;
}

.lineup .icon-button {
  width: var(--small);
  height: var(--small);
}

/* Kenney's portraits have room around the character; shown larger and
   clipped, the face fills its frame. */
.face {
  object-fit: cover;
  object-position: 50% 30%;
  transform: scale(1.35);
}

.characters .face,
.seat-face .face,
.picks .face,
.chips .face {
  transform: scale(1.5);
}

form {
  margin: 0;
}

.notice {
  color: var(--red);
}

/* Every sheet: a panel at the bottom, with Kenney's cross in its corner. */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: auto;
  display: grid;
  align-items: end;
  justify-items: center;
  padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  background: rgb(30 40 60 / 0.35);
}

.sheet .panel {
  position: relative;
  width: min(420px, 100%);
  max-height: 100%;
  overflow: auto;
}

.sheet .panel > .close {
  float: right;
  width: var(--small);
  height: var(--small);
  margin: 0 0 4px 8px;
}

.sheet .panel > .close + * {
  margin-top: 0;
}

.sheet .panel h2 {
  min-height: var(--small);
  display: flex;
  align-items: center;
}

/* While a sheet is open, the screen's own panels step aside. */
.sheet-open .start > :not(.header),
.sheet-open .hud .waiting {
  visibility: hidden;
}

/* --- the game -------------------------------------------------------------- */

.game-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.hud,
.hud .overlay {
  pointer-events: none;
}

.hud > *:not(.overlay):not(.banner),
.hud .overlay:not([hidden]),
.hud .overlay .panel {
  pointer-events: auto;
}

.top {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-button {
  width: var(--chip);
  height: var(--chip);
  min-height: 0;
  padding: 0;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-width: 10px 10px 14px;
  border-image: url("/kenney/ui/grey-button_square_depth_flat.png") 24 24 36 24 fill / 10px 10px 14px stretch;
}

/* Up to six chips always fit, shrinking on narrow phones; nothing scrolls
   or gets cut off. */
.chips {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A player's face on their colour: Kenney's square button shape, filled with
   the colour. Used for chips, seats, picks and your own face. */
.chips li,
.seat-face,
.picks .pick,
.lineup .me {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  border: 0;
  border-image: none;
  background: none;
  padding: 0 0 6px;
}

.chips li::before,
.seat-face::before,
.picks .pick::before,
.lineup .me::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--c, #9aa0b4);
  -webkit-mask: url("/kenney/ui/grey-button_square_depth_flat.png") center / 100% 100% no-repeat;
  mask: url("/kenney/ui/grey-button_square_depth_flat.png") center / 100% 100% no-repeat;
}

.chips li > *,
.seat-face > *,
.picks .pick > *,
.lineup .me > * {
  position: relative;
}

/* Your own face carries Kenney's person icon. */
.badge {
  position: absolute !important;
  right: -4px;
  bottom: -2px;
  width: 18px;
  height: 18px;
  filter: brightness(0.25) drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff);
}

.chips li {
  flex: 0 1 var(--chip);
  min-width: 0;
  height: var(--chip);
  transition: transform 0.2s;
}

.chips li .face {
  width: 70%;
  max-width: 34px;
  height: auto;
}

.chips li .place {
  position: absolute;
  top: -10px;
  font-weight: 700;
  color: var(--ink);
  text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}

.chips li.away .face {
  opacity: 0.4;
}

/* Whoever's go it is stands raised. */
.chips li.current {
  transform: translateY(6px) scale(1.12);
  z-index: 1;
}

.chips li:not(.current) {
  opacity: 0.8;
}

.connection {
  position: absolute;
  top: calc(max(8px, env(safe-area-inset-top)) + var(--chip) + 8px);
  left: 50%;
  transform: translateX(-50%);
  color: var(--red);
  font-weight: 700;
  white-space: nowrap;
}

/* The bottom bar: always the same height, so Roll never moves. */
.bar {
  position: absolute;
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  margin: 0 auto;
  max-width: 560px;
  min-height: 108px;
  display: flex;
  align-items: center;
  padding: 4px;
  border-style: solid;
  border-width: 12px 12px 18px;
  border-image: url("/kenney/ui/grey-button_square_depth_flat.png") 24 24 36 24 fill / 12px 12px 18px stretch;
}

.bar > * {
  flex: 1;
  min-width: 0;
}

.bar .play {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bar .status {
  flex: 1;
  min-width: 0;
}

/* Text wraps rather than being cut off. */
.bar .line {
  font-weight: 700;
  font-size: var(--big);
  line-height: 1.2;
  color: var(--c, var(--ink));
  overflow-wrap: anywhere;
}

.bar .note {
  font-size: 17px;
  line-height: 1.25;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.bar .note:empty {
  display: none;
}

.bar canvas.die {
  width: 52px;
  height: 52px;
  flex: none;
}

.bar button.roll {
  width: auto;
  min-width: 84px;
  flex: none;
  font-size: var(--big);
}

.bar button.roll.ready {
  animation: nudge 1s ease-in-out infinite;
}

@keyframes nudge {
  50% {
    transform: translateY(-3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bar button.roll.ready {
    animation: none;
  }
}

.bar .ask h2 {
  text-align: center;
  margin-bottom: 8px;
}

.picks {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.picks .pick {
  width: var(--control);
  height: var(--control);
  min-height: 0;
  flex: none;
}

.picks .pick .face {
  width: 40px;
  height: 40px;
}

.picks .pick.none {
  --c: #9aa0b4;
}

.picks .pick.none .icon {
  width: 28px;
  height: 28px;
}

.bar .over {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.places {
  list-style: none;
  margin: 0;
  padding: 0;
}

.places li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  font-weight: 700;
}

.places .face {
  width: 32px;
  height: 32px;
}

.places .place {
  width: 24px;
  text-align: center;
  color: var(--ink-soft);
}

.actions {
  display: flex;
  gap: 8px;
}

.banner {
  --c: var(--ink);
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  font-size: var(--huge);
  color: var(--c);
  padding: 6px 22px 14px;
  border-style: solid;
  border-width: 14px 14px 22px;
  border-image: url("/kenney/ui/grey-button_rectangle_depth_flat.png") 24 28 36 28 fill / 14px 14px 22px stretch;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.banner.show {
  animation: banner 1s ease forwards;
}

@keyframes banner {
  0% {
    opacity: 0;
    transform: translate(-50%, -30%) scale(0.9);
  }
  20%,
  80% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -65%) scale(0.95);
  }
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(30 40 60 / 0.3);
}

.overlay .panel {
  width: min(420px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
}

/* Waiting room */
.seats {
  list-style: none;
  margin: 0;
  padding: 0;
}

.seats li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--control);
}

.seat-face {
  width: var(--small);
  height: var(--small);
  min-height: 0;
  flex: none;
}

.seat-face .face {
  width: 34px;
  height: 34px;
}

.seats li .name,
.seats li input {
  flex: 1;
  min-width: 0;
  font-weight: 700;
}

/* The character picker */
.characters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.characters button {
  height: var(--control);
  min-height: 0;
  padding: 0;
  border-width: 10px 10px 14px;
  border-image: url("/kenney/ui/grey-button_square_depth_flat.png") 24 24 36 24 fill / 10px 10px 14px stretch;
}

.characters button.on {
  border-image-source: url("/kenney/ui/yellow-button_square_depth_flat.png");
}



.characters button:disabled .face {
  opacity: 0.3;
}

.characters .face {
  width: 100%;
  max-width: 40px;
  height: auto;
}

.seats .remove {
  width: var(--small);
  height: var(--small);
}

/* Rules: a key to the squares */
.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tile {
  position: relative;
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
}

/* The square's colour, in the shape of a Kenney button. */
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--t);
  -webkit-mask: url("/kenney/ui/grey-button_square_depth_flat.png") center / 100% 100% no-repeat;
  mask: url("/kenney/ui/grey-button_square_depth_flat.png") center / 100% 100% no-repeat;
}

.tile img {
  position: relative;
  width: 26px;
  height: 26px;
  margin-bottom: 4px;
  filter: brightness(0.2);
}

.tile img.light {
  filter: none;
}

.tile img.tag {
  position: absolute;
  width: 18px;
  height: 18px;
  right: 3px;
  bottom: 7px;
}

.tile:has(.tag) img:not(.tag) {
  width: 24px;
  height: 24px;
  margin: 0 10px 10px 0;
}
