:where([expansion]:not([role] [expansion]), [role]) { --base: 2.8vh; }

@property --expansion-gradient-color {
 syntax: '<color>';
 inherits: false;
 initial-value: #545;
}
[expansion]:not([role] [expansion]) {
 padding: var(--global-spacing, calc(var(--base) / 4));
 background-image: linear-gradient(-10deg, #080818, var(--expansion-gradient-color));
 > [info] {
  > img { object-fit: contain; }
  > div { text-align: center; }
 }
 &:not([open]) {
  --size: calc(var(--base) * 3);
  width: var(--size);
  container-type: inline-size;
  border-radius: var(--size) var(--size) calc(var(--base) / 10) calc(var(--base) / 10);
  border: calc(var(--base) / 10) outset #333;
  border-right-style: inset;
  transition: --expansion-gradient-color calc(3000ms * var(--speed, 1)) ease;
  > [info] {
   display: grid;
   width: 100%;
   height: 100%;
   grid: auto 1fr / 1fr;
   gap: var(--global-spacing, calc(var(--base) / 4));
   align-items: center;
   img { pointer-events: none; }
   > img { width: 100cqw; height: 100cqw; object-fit: contain; }
  }
  &::after {
   content: "";
   display: block;
   position: absolute;
   top: calc(100% + var(--global-spacing, calc(var(--base) / 4)));
   left: calc(5cqw + var(--global-spacing, calc(var(--base) / 4)));
   width: 90cqw;
   height: calc(var(--base) / 10);
   border-radius: calc(var(--base) / 20);
   background: #AFA;
   scale: 0 1;
   transition: scale calc(400ms * var(--speed, 1)) ease;
  }
  &[selected] {
   --expansion-gradient-color: #060;
   transition: --expansion-gradient-color calc(400ms * var(--speed, 1)) ease;
   &::after { scale: 1 1; }
  }
  > [roles] { display: none; }
 }
 &[open] {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-content: center;
  align-items: center;
  overflow-y: auto;
  z-index: 1;
  > [info] {
   display: flex;
   width: 100%;
   flex-direction: row-reverse;
   gap: var(--global-spacing, calc(var(--base) / 4));
   > img { width: 2em; height: 2em; }
   > div { width: 100%; align-content: center; }
  }
  > [roles] {
   container-type: inline-size;
   display: flex;
   width: 100%;
   padding: var(--global-spacing, calc(var(--base) / 4));
   justify-content: center;
   flex-wrap: wrap;
   gap: var(--global-spacing, calc(var(--base) / 4));
   align-items: flex-end;
   > [role] {
    --font-size-modifier: -2;
    --size: min(calc(100cqw / 3 - var(--global-spacing, calc(var(--base) / 4)) * 3), 5em);
   }
  }
 }
}

::view-transition-group(role-opening), ::view-transition-group(role-opening-text), ::view-transition-group(role-opening-img) {
 animation-duration: calc(700ms * var(--speed, 1));
 animation-timing-function: ease;
}
::view-transition-old(role-opening-img), ::view-transition-new(role-opening-img) {
 clip-path: circle(calc(var(--role-opening-face-r, 50%) - var(--role-opening-face-b, 0) / 2) at var(--role-opening-face-x, 50%) var(--role-opening-face-y, 50));
 animation: calc(500ms * var(--speed, 1)) ease var(--role-opening-direction) both role-opening-clip-path;
}
@keyframes role-opening-clip-path {
 to { clip-path: circle(100% at 50% 50%); }
}
[role] {
 --size: calc(var(--base) * 3);
 min-width: var(--size);
 min-height: var(--size);
 margin-bottom: 0.5em;
 overflow: visible;
 img { pointer-events: none; }
 &::before { display: block; position: absolute; top: calc(100% - 1em); left: calc(50% + 0.05ch); font-size: 0.5em; }
 &:not([select]) {
  &::before { top: calc(100% - 1.8em); left: calc(50% - 0.8ch); }
  &[indicator="1"]::before { content: ""; }
  &[indicator="2"]::before { content: "×2"; }
  &[indicator="3"]::before { content: "×3"; }
  &[indicator="4"]::before { content: "×4"; }
 }
 &[select] {
  &[indicator="1"]::before { content: "/1"; }
  &[indicator="2"]::before { content: "/2"; }
  &[indicator="3"]::before { content: "/3"; }
  &[indicator="4"]::before { content: "/4"; }
  &::after {
   display: block;
   position: absolute;
   top: calc(100% - 1em);
   right: calc(50% + 0.05ch);
   border-radius: 0.5em;
   font-size: 0.5em;
   filter: drop-shadow(0 0 1px black);
  }
  &[amount="0"]::after { content: "—"; }
  &[amount="1"]::after { content: "×1"; }
  &[amount="2"]::after { content: "×2"; }
  &[amount="3"]::after { content: "×3"; }
  &[amount="4"]::after { content: "×4"; }
  &:not([amount="0"]) {
   background: #0608;
   outline: calc(var(--base) / 10) solid #8A8;
   border-radius: calc(var(--base) / 10);
  }
 }
 &[select][modified] {
  &[amount="0"]::after { content: ".—"; }
  &[amount="1"]::after { content: ".×1"; }
  &[amount="2"]::after { content: ".×2"; }
  &[amount="3"]::after { content: ".×3"; }
  &[amount="4"]::after { content: ".×4"; }
  [info] [modified] { display: block; }
 }
 &[select][warn] {
  &[indicator="1"]::before { content: "/1."; }
  &[indicator="2"]::before { content: "/2."; }
  &[indicator="3"]::before { content: "/3."; }
  &[indicator="4"]::before { content: "/4."; }
  [info] [warning] { display: block; }
 }
 > div {
  container-type: inline-size;
  width: var(--size);
  min-height: var(--size);
  overflow: hidden;
  img[src=""] { scale: 0; }
  > [image] {
   overflow: hidden;
   > img { width: 100%; }
  }
  > [info] {
   width: 100%;
   > [name] { width: 100%; text-align: center; }
   > [info] {
    font-size: 0.75em;
    font-family: 'Palatino Linotype';
    text-align: justify;
    white-space: pre-wrap;
    > :where([modified], [warning], [tokens]) {
     margin-bottom: 0.5em;
     padding: var(--global-spacing, calc(var(--base) / 4));
     border: 1px solid #FC9;
     border-radius: var(--global-spacing, calc(var(--base) / 4));
    }
    > :where([modified], [warning]) {
     display: none;
     font-style: italic;
    }
    > [warning] { border-color: #FFA; }
    > [tokens] {
     font-size: 0.9em;
     border-color: #000;
     background-color: #0008;
     > div > div {
      padding: 0 0 var(--global-spacing, calc(var(--base) / 4));
      width: 100%;
      text-align: center;
      font-family: 'Copperplate Gothic';
     }
    }
   }
  }
  > [icons] {
   display: flex;
   width: 100%;
   justify-content: space-between;
   align-content: center;
   align-items: center;
   > [weight] {
    --shadow-x: 1px;
    --shadow-y: 1px;
    --shadow-color: black;
    top: 0.1em;
    filter:
     drop-shadow(calc(var(--shadow-x) *  0) calc(var(--shadow-y) * -1) var(--shadow-color))
     drop-shadow(calc(var(--shadow-x) *  1) calc(var(--shadow-y) * -1) var(--shadow-color))
     drop-shadow(calc(var(--shadow-x) *  1) calc(var(--shadow-y) *  0) var(--shadow-color))
     drop-shadow(calc(var(--shadow-x) *  1) calc(var(--shadow-y) *  1) var(--shadow-color))
     drop-shadow(calc(var(--shadow-x) *  0) calc(var(--shadow-y) *  1) var(--shadow-color))
     drop-shadow(calc(var(--shadow-x) * -1) calc(var(--shadow-y) *  1) var(--shadow-color))
     drop-shadow(calc(var(--shadow-x) * -1) calc(var(--shadow-y) *  0) var(--shadow-color))
     drop-shadow(calc(var(--shadow-x) * -1) calc(var(--shadow-y) * -1) var(--shadow-color));
    &[type="Werewolf"] { --shadow-color: #6008; color: #D88; }
    &[type="Village"] { --shadow-color: #0068; color: #88D; }
   }
  }
 }
 &[open] {
  height: var(--role-open-height, auto);
  &[select][modified] [info] > [modified], &[select][warn] [info] > [warning] { display: block; }
  > div {
   position: fixed;
   display: grid;
   grid: min(100vh * (2 / 3), calc(150vw - var(--global-spacing, calc(var(--base) / 4)) * 4)) 1fr auto / 100%;
   top: 0; left: 0;
   width: 100%;
   height: 100%;
   min-height: 100%;
   padding: var(--global-spacing, calc(var(--base) / 4));
   gap: var(--global-spacing, calc(var(--base) / 4));
   overflow-y: auto;
   z-index: 1;
   > [image] {
    display: flex;
    justify-content: center;
    width: 100%;
    height: 100%;
    > img {
     width: auto;
     height: 100%;
     aspect-ratio: 2 / 3;
     max-width: 100%;
     object-fit: cover;
     border: calc(var(--global-spacing, calc(var(--base) / 4)) / 2) ridge #0008;
    }
   }
   > [info] {
    padding: 0 var(--base);
    height: 100%;
    > [name] { padding: var(--global-spacing, calc(var(--base) / 4)) 0; }
   }
   > [icons] > [token], [expansion] { width: 1.5em; height: 1.5em; }
  }
 }
 &:not([open]) {
  padding: calc(var(--global-spacing) / 2);
  width: calc(var(--size) + var(--global-spacing, calc(var(--base) / 4)));
  > div {
   padding-bottom: 0.75em;
   display: flex;
   flex-direction: column-reverse;
   justify-content: flex-end;
   align-content: center;
   align-items: center;
   gap: var(--global-spacing, calc(var(--base) / 4));
   > [image] {
    width: calc(100cqw * (2.5 / 3));
    height: calc(100cqw * (2.5 / 3));
    border-radius: calc(100cqw * (1.25 / 3));
    border: calc(100cqw * (0.25 / 3)) solid transparent;
    background-origin: border-box;
    overflow: hidden;
    > img {
     top: 50%;
     left: 50%;
    }
   }
   > [info] {
    height: 100%;
    > [name] {
     background: #201810;
     border: var(--global-spacing, calc(var(--base) / 4)) ridge #403830;
     filter: url(#svg-filter-distressed);
    }
    > [info] { display: none; }
   }
   > [icons] {
    position: absolute;
    bottom: 0;
    > :is([token], [expansion]) { width: calc(100cqw / 3); height: calc(100cqw / 3); }
    > [weight] { font-size: 0.7em; }
   }
  }
 }
}