/*
 * Odd One Out on the web. Same look as the app: a deep purple ground, cream
 * and yellow surfaces, thick ink outlines with hard offset shadows, Fredoka.
 * Colours match Palette in app/shared/.../ui/Theme.kt.
 */

@font-face {
  font-family: "Fredoka";
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/fredoka_500.ttf") format("truetype");
}
@font-face {
  font-family: "Fredoka";
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/fredoka_600.ttf") format("truetype");
}
@font-face {
  font-family: "Fredoka";
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/fredoka_700.ttf") format("truetype");
}

:root {
  --ink: #150c33;
  --ground: #2a1a5e;
  --panel: #3b2a80;
  --panel-line: #6a57bd;
  --cream: #fff6e0;
  --cream-line: #e2d2a8;
  --cream-text: #5b4b8a;
  --yellow: #ffcb3d;
  --red: #d42a47;
  --red-line: #f0728a;
  --teal: #3dd6c0;
  --lilac: #cfc6f5;
  --white: #ffffff;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  margin: 0;
}

html {
  background: var(--ground);
  -webkit-text-size-adjust: 100%;
}

body {
  color: var(--white);
  font: 500 18px/1.25 "Fredoka", ui-rounded, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--teal);
  font-weight: 600;
}

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

h1,
h2 {
  font-weight: 700;
  line-height: 1.05;
}

h2 {
  font-size: 24px;
  font-weight: 600;
}

.noscript {
  padding: 40px 24px;
  text-align: center;
}

/* ---- Page frame -------------------------------------------------------- */

.screen {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 440px;
  height: 100dvh;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
}

/* The join form may be taller than the screen: it scrolls with the page. */
.screen.join {
  height: auto;
  min-height: 100dvh;
  gap: 12px;
}

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

.dim {
  color: var(--lilac);
}

.big {
  font-size: 22px;
  font-weight: 600;
}

.hint {
  padding: 6px 0;
  color: var(--lilac);
  font-size: 17px;
  text-align: center;
}

.icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.avatar {
  display: block;
  width: 72px;
  height: 72px;
  overflow: visible;
}

/* ---- Buttons ----------------------------------------------------------- */

button {
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.btn {
  flex: none;
  width: 100%;
  height: 64px;
  margin-bottom: 6px;
  border: 3px solid var(--ink);
  border-radius: 22px;
  background: var(--yellow);
  box-shadow: 0 6px 0 var(--ink);
  color: var(--ink);
  font-size: 24px;
  font-weight: 600;
}

.btn:active:not(:disabled),
.pill:active {
  box-shadow: 0 1px 0 var(--ink);
  transform: translateY(4px);
}

.btn.panel {
  background: var(--panel);
  color: var(--white);
}

.btn.danger {
  background: var(--red);
  color: var(--white);
}

.btn.light {
  background: var(--white);
}

.btn:disabled {
  background: var(--panel);
  color: var(--lilac);
  cursor: default;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 48px;
  margin-bottom: 4px;
  padding: 0 18px 0 10px;
  border: 3px solid var(--ink);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 4px 0 var(--ink);
  font-size: 17px;
  font-weight: 600;
}

.pill.light {
  background: var(--white);
  color: var(--ink);
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 16px;
  border: 3px solid var(--ink);
  border-radius: 19px;
  background: var(--teal);
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---- Join form --------------------------------------------------------- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 0 6px;
  text-align: center;
}

.hero-cards {
  position: relative;
  width: 132px;
  height: 108px;
}

.hero-card {
  position: absolute;
  top: 8px;
  display: grid;
  place-items: center;
  width: 64px;
  height: 90px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 5px 0 var(--ink);
}

.hero-card.word {
  left: 8px;
  background: var(--cream);
  color: var(--ground);
  font-size: 48px;
  font-weight: 700;
  transform: rotate(-11deg);
}

.hero-card.impostor {
  left: 58px;
  top: 12px;
  background: var(--red);
  transform: rotate(9deg);
}

.hero-card .mask {
  width: 44px;
}

.hero h1 {
  color: var(--yellow);
  font-size: 44px;
  text-shadow: 0 4px 0 var(--ink);
}

.tagline {
  color: var(--lilac);
  font-size: 19px;
}

.field {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 600;
}

input {
  width: 100%;
  height: 60px;
  margin-bottom: 5px;
  padding: 0 16px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--cream);
  box-shadow: 0 5px 0 var(--ink);
  color: var(--ink);
  font: 600 22px "Fredoka", ui-rounded, system-ui, sans-serif;
  text-align: center;
}

input::placeholder {
  color: var(--cream-text);
  opacity: 0.7;
}

.code-input {
  height: 68px;
  /* The extra left padding keeps the letter-spaced text centred. */
  padding-left: calc(16px + 0.22em);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.choices {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin: 2px 0 6px;
}

.choice {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
}

.choice .avatar {
  width: 84%;
  height: 84%;
}

.choice[aria-pressed="true"] {
  background: var(--yellow);
  box-shadow: inset 0 0 0 3px var(--ink);
}

.site-footer {
  margin-top: auto;
  padding-top: 10px;
  color: var(--lilac);
  font-size: 16px;
  line-height: 1.6;
  text-align: center;
}

/* ---- In a room --------------------------------------------------------- */

.bar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status {
  color: var(--lilac);
  font-size: 16px;
  text-align: right;
}

.code-card {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  padding: 14px 16px 10px;
  border: 4px solid var(--ink);
  border-radius: 24px;
  background: var(--cream);
  box-shadow: 0 7px 0 var(--ink);
  color: var(--ink);
}

.code-card .caption {
  color: var(--cream-text);
  font-size: 16px;
}

.code {
  /* The same shift as the letter spacing keeps the code optically centred. */
  padding-left: 0.1em;
  font-size: 46px;
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1.05;
}

.players {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(3, 1fr);
  align-content: start;
  gap: 14px 4px;
  min-height: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.players li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  text-align: center;
}

.players .offline {
  opacity: 0.5;
}

.portrait {
  position: relative;
}

.crown {
  position: absolute;
  right: -8px;
  bottom: -4px;
  width: 30px;
  height: 30px;
  fill: var(--yellow);
  stroke: var(--ink);
  stroke-width: 2.4;
  stroke-linejoin: round;
}

.players .name {
  max-width: 100%;
  overflow: hidden;
  font-size: 17px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.players .tag {
  min-height: 1em;
  color: var(--yellow);
  font-size: 14px;
}

/* The area a screen keeps free for its main piece; the piece sizes itself to it. */
.stage {
  display: grid;
  flex: 1;
  place-items: center;
  min-height: 0;
  container-type: size;
}

/* ---- The secret card --------------------------------------------------- */

.secret {
  position: relative;
  /* As large as the stage allows, never beyond the app's 318 x 449. */
  height: min(100cqh, 449px, 141.2cqw);
  aspect-ratio: 318 / 449;
  border: 4px solid var(--ink);
  border-radius: 30px;
  background: var(--panel);
  box-shadow: 0 9px 0 var(--ink);
  container-type: inline-size;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.face {
  position: absolute;
  inset: 4.4cqw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4cqw;
  padding: 0 6cqw;
  border: 3px dashed var(--panel-line);
  border-radius: 5.6cqw;
  text-align: center;
}

.face.front {
  display: none;
}

.card-shown .secret {
  box-shadow: 0 3px 0 var(--ink);
  transform: translateY(6px);
}

.card-shown .secret.player {
  background: var(--cream);
  color: var(--ground);
}

.card-shown .secret.impostor {
  background: var(--red);
}

.card-shown .face.back {
  display: none;
}

.card-shown .face.front {
  display: flex;
}

.secret.player .front {
  border-color: var(--cream-line);
}

.secret.impostor .front {
  gap: 2cqw;
  border-color: var(--red-line);
}

.peek {
  display: grid;
  place-items: center;
  width: 30cqw;
  height: 30cqw;
  margin-bottom: 2cqw;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 5px 0 var(--ink);
  color: var(--ink);
}

.peek .icon {
  width: 15cqw;
  height: 15cqw;
}

.ask {
  font-size: 7.5cqw;
  font-weight: 600;
}

.small {
  font-size: 6.9cqw;
}

.secret.player .small {
  color: var(--cream-text);
}

.word {
  font-weight: 700;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.word.xl {
  font-size: 20.7cqw;
}

.word.l {
  font-size: 17cqw;
}

.word.m {
  font-size: 13.2cqw;
}

.word.s {
  font-size: 10.7cqw;
}

.chip {
  margin-top: 3cqw;
  padding: 2.6cqw 5.6cqw;
  border-radius: 99px;
  background: var(--ground);
  color: var(--white);
  font-size: 5cqw;
}

.medal {
  display: grid;
  place-items: center;
  width: 40cqw;
  height: 40cqw;
  margin-bottom: 3cqw;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 0 5px 0 var(--ink);
}

.medal .mask {
  width: 27cqw;
}

.role {
  font-size: 14.4cqw;
  font-weight: 700;
  line-height: 1.05;
  text-shadow: 0 4px 0 var(--ink);
}

.secret.impostor .small:last-child {
  margin-top: 2cqw;
  font-size: 5.6cqw;
  line-height: 1.3;
}

.speaker {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  height: 48px;
  color: var(--lilac);
  font-size: 19px;
}

.speaker strong {
  overflow: hidden;
  color: var(--white);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.speaker .avatar {
  flex: none;
  width: 44px;
  height: 44px;
}

.when-hidden {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.when-shown,
.card-shown .when-hidden {
  display: none;
}

.card-shown .when-shown {
  display: block;
}

/* ---- Waiting and reveal ------------------------------------------------ */

.notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 8px;
  padding: 30px 22px;
  border: 4px solid var(--ink);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: 0 8px 0 var(--ink);
  text-align: center;
}

.notice h2 {
  color: var(--yellow);
  font-size: 34px;
  font-weight: 700;
  text-shadow: 0 4px 0 var(--ink);
}

.notice p {
  font-size: 20px;
}

.notice .dim {
  font-size: 17px;
}

.avatar.big {
  width: 96px;
  height: 96px;
}

.stage.reveal {
  align-content: center;
  gap: 8px;
  text-align: center;
}

.stage.reveal .dim {
  font-size: 22px;
}

.culprit {
  position: relative;
  display: grid;
  place-items: center;
  /* Shrinks on short screens, where the stage is small. */
  width: min(150px, 46cqh);
  aspect-ratio: 1;
  margin-bottom: 7px;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 7px 0 var(--ink);
}

.culprit .avatar {
  width: 77%;
  height: 77%;
}

.culprit-mask {
  position: absolute;
  right: -7%;
  bottom: -1%;
  display: grid;
  place-items: center;
  width: 37%;
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--cream);
}

.culprit-mask .mask {
  width: 68%;
}

.culprit-name {
  max-width: 100%;
  overflow: hidden;
  color: var(--yellow);
  font-size: min(48px, 15cqh);
  font-weight: 700;
  text-overflow: ellipsis;
  text-shadow: 0 4px 0 var(--ink);
  white-space: nowrap;
}

.word-card {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  padding: 14px 20px;
  border: 4px solid var(--ink);
  border-radius: 24px;
  background: var(--cream);
  box-shadow: 0 7px 0 var(--ink);
  color: var(--cream-text);
}

.word-card strong {
  color: var(--ground);
  font-size: 36px;
  font-weight: 700;
  line-height: 1.05;
  text-align: right;
}

.word-card strong.long {
  font-size: 26px;
}

.faces {
  display: flex;
}

.faces .avatar {
  width: 44px;
  height: 44px;
  margin-right: -8px;
}

/* ---- Messages and dialogs ---------------------------------------------- */

.banner,
.toast {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  z-index: 3;
  width: max-content;
  max-width: min(calc(100vw - 32px), 408px);
  padding: 12px 18px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--cream);
  box-shadow: 0 5px 0 var(--ink);
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  transform: translateX(-50%);
}

.toast {
  top: auto;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 2;
  background: var(--panel);
  color: var(--white);
}

.toast.still {
  position: static;
  transform: none;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(21 12 51 / 72%);
}

.dialog {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(100%, 360px);
  padding: 22px 20px 16px;
  border: 4px solid var(--ink);
  border-radius: 26px;
  background: var(--cream);
  box-shadow: 0 8px 0 var(--ink);
  color: var(--cream-text);
}

.dialog h2 {
  color: var(--ink);
  font-size: 26px;
  font-weight: 700;
}

.dialog p {
  margin-bottom: 6px;
  font-size: 18px;
}

.dialog .btn {
  height: 56px;
  font-size: 20px;
}

/* ---- Text pages (privacy) ---------------------------------------------- */

.page {
  max-width: 680px;
  margin: 0 auto;
  padding: calc(28px + env(safe-area-inset-top)) 24px calc(48px + env(safe-area-inset-bottom));
  font-size: 18px;
  line-height: 1.55;
}

.page h1 {
  margin-bottom: 6px;
  color: var(--yellow);
  font-size: 40px;
  text-shadow: 0 4px 0 var(--ink);
}

.page h2 {
  margin: 30px 0 8px;
  font-size: 23px;
}

.page p,
.page ul {
  margin-bottom: 12px;
}

.page ul {
  padding-left: 22px;
}

.page li {
  margin-bottom: 6px;
}

.page .dim {
  font-size: 16px;
}
