:root {
  --leave-pink: #ffc9d2;
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #201529;
  background: #b492dd;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
#game-screen { flex: 1; }
button, summary, #controls, #game-screen {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
button, summary { touch-action: manipulation; }
[hidden] { display: none !important; }
.join-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  min-block-size: 100vh;
  min-block-size: 100svh;
  padding: 2rem 1.25rem;
  text-align: center;
}
.join-screen .join-brand { width: min(68vw, 17rem); margin: 0; }
#pause-screen { min-block-size: calc(100svh - 4.25rem); }
#pause-screen h2, #pause-screen p { margin: 0; }
.join-brand img { display: block; width: 100%; height: auto; }
.guest-waiting { position: relative; padding-block-start: 4rem; }
.guest-waiting p { margin: 0; font-size: 1.25rem; font-weight: 850; }
#waiting-leave { position: absolute; inset-block-start: .8rem; inset-inline-end: .7rem; }
#join-status {
  max-width: 24rem;
  margin: 0;
  padding: .55rem 1rem;
  background: #fff1d1;
  border: 2px solid #201529;
  border-radius: .45rem;
  box-shadow: 3px 4px #201529;
  font-size: 1.15rem;
  font-weight: 850;
  transform: rotate(-3deg);
}
#join-status, #feedback, #game-feedback { white-space: pre-line; }
.join-loading { display: flex; gap: .5rem; }
.join-loading span {
  width: .65rem;
  height: .65rem;
  border: 1.5px solid #201529;
  border-radius: 50%;
  background: #ffdb4b;
}
.join-loading span:nth-child(2) { background: #ffa9bf; animation-delay: .14s; }
.join-loading span:nth-child(3) { background: #fff1d1; animation-delay: .28s; }
@media (prefers-reduced-motion: no-preference) {
  .join-loading span { animation: join-bounce 1.1s ease-in-out infinite; }
}
@keyframes join-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  28% { transform: translateY(-.38rem); }
}
#launcher {
  width: min(100%, 30rem);
  margin-inline: auto;
  padding: 1.4rem 1.1rem;
}
.controller-header {
  position: sticky;
  z-index: 1;
  top: 0;
  background: #fff1d1;
  border-bottom: 2px solid #201529;
}
.controller-bar {
  display: flex;
  min-height: 4.25rem;
  max-width: 34rem;
  margin-inline: auto;
  align-items: center;
  gap: .6rem;
  padding: .35rem .7rem;
}
.brand { display: block; flex: none; object-fit: contain; }
.controller-bar nav { display: flex; gap: .3rem; margin-inline-start: auto; }
.controller-bar button, #waiting-leave {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 2.75rem;
  block-size: 2.75rem;
  padding: 0;
  font: inherit;
  color: #201529;
  background: #fff9e9;
  border: 1.5px solid #201529;
  border-radius: .55rem;
  touch-action: manipulation;
}
.toolbar-symbol { line-height: 1; font-size: 1.45rem; font-weight: 750; }
.controller-bar button[aria-pressed="true"] { background: #e7d2fa; }
#leave, #waiting-leave { background: var(--leave-pink); }
.controller-bar button:disabled, #waiting-leave:disabled { opacity: .42; }
.controller-bar button:focus-visible, #waiting-leave:focus-visible { outline: 2px solid #573077; outline-offset: 2px; }
.exit-icon {
  position: relative;
  inline-size: 1.35rem;
  block-size: 1.3rem;
}
.exit-icon::before {
  content: "";
  position: absolute;
  inset: 0 0 0 .5rem;
  border: 2px solid currentColor;
  border-left: 0;
  border-radius: 0 .18rem .18rem 0;
}
.exit-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  inline-size: .98rem;
  block-size: .72rem;
  background: currentColor;
  clip-path: polygon(37% 0, 49% 15%, 26% 41%, 100% 41%, 100% 59%, 26% 59%, 49% 85%, 37% 100%, 0 50%);
  transform: translateY(-50%);
}
.controller-dialog {
  width: min(calc(100% - 2.5rem), 23rem);
  max-height: calc(100% - 2.5rem);
  padding: 1.25rem;
  border: 3px solid #201529;
  border-radius: 1rem;
  background: #fff1d1;
  color: #201529;
  box-shadow: 6px 7px #201529;
}
.controller-dialog::backdrop { background: #201529a6; }
.dialog-mark {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  margin-bottom: .8rem;
  border: 2px solid #201529;
  border-radius: .5rem;
  background: #ffa9bf;
  box-shadow: 2px 2px #201529;
  transform: rotate(-6deg);
}
.controller-dialog h2 { margin: 0; font-size: 1.5rem; line-height: 1.15; font-weight: 900; }
.controller-dialog p { margin: .5rem 0 1.1rem; line-height: 1.4; }
.controller-dialog form { display: flex; flex-wrap: wrap; gap: .55rem; }
.controller-dialog button {
  flex: 1 0 auto;
  min-height: 2.75rem;
  padding: .4rem .65rem;
  border: 2px solid #201529;
  border-radius: .55rem;
  background: #fff9e9;
  color: inherit;
  font: inherit;
  font-weight: 800;
}
.controller-dialog button[value="leave"] { background: var(--leave-pink); box-shadow: 2px 2px #201529; }
.controller-dialog button:is([value="home"], [value="ok"]) { background: #ffdb4b; box-shadow: 2px 2px #201529; }
.controller-dialog button:focus-visible { outline: 2px solid #573077; outline-offset: 2px; }
#fullscreen .fullscreen-icon {
  --line: linear-gradient(currentColor, currentColor);
  width: 1.13rem;
  height: 1.13rem;
  background:
    var(--line) top left / 36% 2px,
    var(--line) top left / 2px 36%,
    var(--line) top right / 36% 2px,
    var(--line) top right / 2px 36%,
    var(--line) bottom left / 36% 2px,
    var(--line) bottom left / 2px 36%,
    var(--line) bottom right / 36% 2px,
    var(--line) bottom right / 2px 36%;
  background-repeat: no-repeat;
}
#fullscreen[aria-pressed="true"] .fullscreen-icon { transform: scale(.75); }
#fullscreen-note, #avatar-note {
  max-width: 34rem;
  margin: 0 auto;
  padding: .35rem .7rem .65rem;
  font-size: .85rem;
  line-height: 1.35;
}
.card {
  background: #fff1d1;
  border: 3px solid #201529;
  border-radius: 1.25rem;
  box-shadow: 5px 6px #201529;
  padding: 1.25rem;
}
h1 { font-size: clamp(2.25rem, 12vw, 3.75rem); line-height: 1; margin: .25rem 0 0; }
#status { line-height: 1.4; }
#controls { display: grid; gap: .65rem; }
#launcher:is([data-phase="lobby"], [data-phase="catalogue"]) { padding-block-start: clamp(2rem, 6vh, 3.5rem); }
#launcher:is([data-phase="lobby"], [data-phase="catalogue"]) .card {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0 .25rem;
  text-align: center;
}
#launcher:is([data-phase="lobby"], [data-phase="catalogue"]) #game {
  order: -1;
  max-width: 100%;
  margin: 0 0 1.45rem;
  padding: .65rem .9rem;
  border: 3px solid #201529;
  background: #fff9e9;
  box-shadow: 4px 5px #201529;
  color: #201529;
  font-size: clamp(1.55rem, 8vw, 2.55rem);
  font-weight: 900;
  line-height: 1.05;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  transform: rotate(1.5deg);
}
#launcher:is([data-phase="lobby"], [data-phase="catalogue"]) #controls { width: 100%; }
#launcher button, #retry-join, #join-again {
  min-height: 3.3rem;
  appearance: none;
  font: inherit;
  font-weight: 800;
  text-align: left;
  color: #201529;
  background: #ffdb4b;
  border: 2px solid #201529;
  border-radius: .75rem;
  box-shadow: 2px 3px #201529;
  padding: .6rem .9rem;
  touch-action: manipulation;
}
#join-again { display: grid; place-items: center; text-align: center; text-decoration: none; }
#launcher button:active, #retry-join:active, #join-again:active { transform: translate(2px, 3px); box-shadow: none; }
#launcher button:focus-visible, #retry-join:focus-visible, #join-again:focus-visible { outline: 3px solid #573077; outline-offset: 3px; }
#launcher button:disabled { opacity: .7; }
.lobby-count {
  width: fit-content;
  margin: .75rem 0 1rem;
  padding: .25rem .6rem;
  border: 1px solid #201529;
  border-radius: 2rem;
  background: #e7d2fa;
  font-size: .85rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}
.lobby-full { color: #173725; background: #c8e7ac; }
#lobby-players {
  display: grid;
  gap: .4rem;
  width: min(100%, 19rem);
  margin: 0;
  padding: 0;
  list-style: none;
}
#lobby-players li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .55rem;
  padding: .3rem .5rem;
  border: 2px solid #201529;
  border-radius: .65rem;
  background: #fff1d1;
  text-align: start;
}
.lobby-player-avatar {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: #f4e6ff;
}
.lobby-player-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.lobby-player-status {
  padding: .2rem .45rem;
  border-radius: .45rem;
  background: #ffdb4b;
  font-size: .72rem;
  font-weight: 800;
}
.lobby-player-ready { color: #173725; background: #c8e7ac; }
#launcher .lobby-start { text-align: center; }
#launcher .lobby-start:disabled {
  background: #ece1d1;
  color: #665b58;
  border-color: #96877e;
  box-shadow: none;
  opacity: 1;
}
#lobby-actions {
  display: grid;
  justify-items: center;
  gap: 1rem;
  padding: 1.85rem .4rem 0;
}
#lobby-actions:empty { display: none; }
#lobby-actions .lobby-ready {
  width: min(100%, 19rem);
  min-height: 4.3rem;
  border: 3px solid #201529;
  border-radius: .65rem;
  text-align: center;
  font-size: 1.62rem;
  font-weight: 900;
  box-shadow: 4px 6px #201529;
  transform: rotate(-3deg);
}
#lobby-actions .lobby-ready[aria-pressed="true"] {
  background: #c8e7ac;
  color: #173725;
}
#lobby-actions .lobby-ready:active { box-shadow: none; transform: translate(4px, 6px) rotate(-3deg); }
#start-hint { margin: -.2rem 0 0; font-size: .85rem; line-height: 1.4; text-align: center; }
#join-recovery { display: grid; justify-items: center; gap: .45rem; }
#join-recovery a { color: #201529; font-weight: 800; padding: .65rem; }
#scan-again { margin: 0; font-size: .9rem; }
.catalogue-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
  list-style: none;
  padding: .1rem 0 0;
  margin: 0;
}
.catalogue-options li { display: flex; min-width: 0; }
.catalogue-options:has(> li:only-child) {
  grid-template-columns: minmax(0, 1fr);
  max-width: 13rem;
  margin-inline: auto;
}
#launcher .catalogue-game {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: .55rem;
  width: 100%;
  min-height: clamp(7.5rem, 38vw, 9.5rem);
  padding: .8rem .45rem;
  border: 4px solid #fff1d1;
  border-radius: .85rem;
  box-shadow: 0 0 0 1.5px #201529, 3px 4px #201529, inset 0 0 0 1.5px #201529;
  color: #201529;
  background: #e7d2fa;
  text-align: center;
  font-size: clamp(.95rem, 4.1vw, 1.15rem);
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
#launcher .catalogue-game[data-game="shifumi"] { background: #ffd509; }
#launcher .catalogue-game[data-game="dice-battle"] { background: #b8dfb4; }
#launcher .catalogue-game[data-game="soleil"] { background: #ffa372; }
#launcher .catalogue-game[data-game="minotaur"] { background: #c1a8f4; }
.lobby-roles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .4rem;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: .5rem 0 0;
  border: 0;
  color: #282037;
}
.lobby-roles legend { font-size: 1.05rem; font-weight: 900; }
.lobby-required-role {
  grid-column: 1 / -1;
  margin: 0;
  padding: .4rem .65rem;
  border-radius: .65rem;
  background: #ffe1e9;
  font-size: .82rem;
  font-weight: 800;
}
#launcher .lobby-roles button {
  border: 2px solid #282037;
  border-radius: .65rem;
  background: #eee2ff;
  color: #282037;
  font: inherit;
  font-size: .87rem;
  font-weight: 850;
  padding: .55rem .25rem;
}
#launcher .lobby-roles button[aria-pressed="true"] { background: #ffd477; }
#launcher .lobby-roles button:disabled { opacity: .45; }
#launcher .lobby-roles button:has(small) { min-height: 3.4rem; }
#launcher .lobby-roles small {
  display: block;
  margin-top: .18rem;
  font-size: .7rem;
  font-weight: 650;
}
#launcher .catalogue-game:active {
  box-shadow: 0 0 0 1.5px #201529, inset 0 0 0 1.5px #201529;
  transform: translate(1px, 2px);
}
.avatar-toggle::after {
  content: "";
  width: .45rem;
  height: .45rem;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(-45deg);
}
.catalogue-game img {
  display: block;
  width: clamp(3rem, 17vw, 5rem);
  aspect-ratio: 1;
  object-fit: contain;
  pointer-events: none;
}
#feedback { color: #582f65; font-size: .9rem; margin-bottom: 0; }
#game-feedback {
  position: fixed;
  inset: auto 1rem 1rem;
  margin: 0 auto;
  max-width: 28rem;
  padding: .7rem 1rem;
  border-radius: .5rem;
  background: #201529;
  color: white;
}

#avatar-settings {
  background: #f4e6ff;
  color: #201529;
  border-bottom: 2px solid #201529;
}
.avatar-layout {
  max-width: 34rem;
  margin: 0 auto;
}
#avatar-menu { padding: .45rem .7rem; }
#avatar-menu > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .65rem;
  font-weight: 800;
  min-height: 2.75rem;
}
#avatar-menu > summary::-webkit-details-marker { display: none; }
#avatar-menu > summary:focus-visible { outline: 2px solid #573077; outline-offset: 2px; }
.avatar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 2.75rem;
  min-height: 2.75rem;
  margin-inline-start: auto;
  padding: .25rem .45rem;
  border: 1.5px solid #201529;
  border-radius: .55rem;
  background: #fff9e9;
}
.avatar-toggle::after { transform: translateY(-2px) rotate(45deg); }
#avatar-menu[open] .avatar-toggle::after { transform: translateY(2px) rotate(225deg); }
.avatar-preview {
  overflow: hidden;
  display: grid;
  place-items: center;
  height: 2.65rem;
  width: 2.65rem;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1.5px solid #201529;
  background: #fff1d1;
  font-size: 1.28rem;
}
.avatar-preview canvas { display: block; width: 100%; height: 100%; }
[data-avatar-decoration="horns"] {
  position: relative;
  overflow: visible;
}
[data-avatar-decoration="horns"]::before,
[data-avatar-decoration="horns"]::after {
  content: "";
  position: absolute;
  z-index: 1;
  top: -15%;
  left: 0;
  width: 36%;
  height: 46%;
  background: #ffd477;
  clip-path: polygon(5% 0, 18% 29%, 36% 43%, 70% 50%, 96% 58%, 99% 83%, 74% 100%, 35% 90%, 8% 64%, 0 33%);
  pointer-events: none;
}
[data-avatar-decoration="horns"]::after { left: auto; right: 0; transform: scaleX(-1); }
.avatar-preview canvas { border-radius: 50%; }
.camera-source {
  position: fixed;
  inset: 0 auto auto 0;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}
#avatar-live { font-weight: 650; color: #24563c; }
.avatar-identity { display: grid; min-width: 0; }
#avatar-player-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#avatar-live { font-size: .75rem; }
.avatar-panel { padding: .65rem 0 .3rem; }
.avatar-name-form { display: grid; gap: .35rem; margin-bottom: .75rem; }
.avatar-name-form label { font-size: .85rem; font-weight: 750; }
.avatar-name-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .45rem; }
.avatar-name-row input {
  min-width: 0;
  padding: .4rem .55rem;
  border: 1.5px solid #201529;
  border-radius: .55rem;
  background: #fff9e9;
  color: #201529;
  font: inherit;
  font-size: 1rem;
}
.avatar-panel .avatar-name-row button:not(:disabled) { background: #ffdb4b; }
.avatar-panel .avatar-name-row button {
  display: grid;
  place-items: center;
  inline-size: 2.75rem;
  min-block-size: 2.75rem;
  padding: 0;
}
.save-icon {
  position: relative;
  inline-size: 1.05rem;
  block-size: 1.05rem;
  border: 1.5px solid currentColor;
  border-radius: .16rem;
}
.save-icon::before, .save-icon::after {
  content: "";
  position: absolute;
  inset-inline: .12rem;
  border: 1px solid currentColor;
}
.save-icon::before { inset-block-start: -1px; block-size: .29rem; }
.save-icon::after { inset-block-end: -1px; block-size: .30rem; border-radius: .08rem .08rem 0 0; }
.avatar-name-row button:disabled { opacity: .55; }
#avatar-name-status { margin: 0; font-size: .82rem; font-weight: 750; }
#avatar-name-status[data-state="saved"] { color: #24563c; }
#avatar-name-status[data-state="error"] { color: #952a44; }
#avatar-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 2.75rem));
  gap: .35rem;
  margin-bottom: .5rem;
}
.avatar-panel button {
  display: inline-block;
  border: 1.5px solid #201529;
  background: #fff9e9;
  color: #201529;
  border-radius: .65rem;
  padding: .43rem .75rem;
  min-height: 2.55rem;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
}
#avatar-options button { padding: .25rem; min-height: 2.75rem; font-size: 1.16rem; }
#avatar-options button[aria-pressed="true"] { background: #ffdb4b; }
#avatar-camera[data-resume="true"] { background: #ffdb4b; }
#avatar-camera[aria-pressed="true"] { background: #c8e7ac; }
#avatar-camera:focus-visible { outline: 2px solid #573077; outline-offset: 2px; }
.camera-icon {
  position: relative;
  display: block;
  width: .98rem;
  height: .78rem;
  margin-inline-end: .33rem;
  border: 2px solid currentColor;
  border-radius: .18rem;
}
.camera-icon::before {
  content: "";
  position: absolute;
  left: 100%;
  top: 50%;
  width: .43rem;
  height: .65rem;
  background: currentColor;
  clip-path: polygon(0 33%, 100% 0, 100% 100%, 0 67%);
  transform: translateY(-50%);
}
#avatar-camera[aria-pressed="false"] .camera-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -.28rem;
  width: 1.65rem;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  box-shadow: 0 2px #fff9e9;
  transform: rotate(-42deg);
}
#avatar-camera[data-resume="true"] .camera-icon::after { box-shadow: 0 2px #ffdb4b; }

#controls a { color: #573077; font-weight: 800; }
