/* Colours and type in one place, taken from the original Articulate game.
   Contrast (WCAG 2.1 AA): black on purple 5.5:1, black on orange 5.9:1, black on beige 8.2:1, orange on black 5.9:1,
   black on white and white on black 16.7:1. White on orange fails (2.8:1), so never use it.
   The game has its own light, orange and dark screens, so it looks the same in the phone's dark mode. */
:root {
  --white: #ffffff;
  --black: #1e1e1e;
  --orange: #f57500;
  --purple: #b07fd8; /* Start page. Deeper purples make the black text too faint. */
  --beige: #e9a873;
  --error: #b3261e; /* 6.6:1 on white */
  --edge: var(--black); /* The edge of fields and options. */
  --line: #d5d9da; /* Decoration only: too pale for the edge of a field or button. */
  --sans: "Albert Sans", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}

/* Each screen sets the page colours; the focus outline always has 3:1 against them. */
body,
body[data-tone="light"] { --bg: var(--white); --ink: var(--black); --focus: var(--black); }
body[data-tone="purple"] { --bg: var(--purple); --ink: var(--black); --focus: var(--black); }
/* The start page follows the language button: purple in German, orange in Japanese. */
html[lang="ja"] body[data-tone="purple"] { --bg: var(--orange); }
body[data-tone="dark"] { --bg: var(--black); --ink: var(--white); --focus: var(--orange); }

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 1.125rem/1.5 var(--sans);
}

h1, h2 { font-weight: 700; line-height: 1.2; margin: 0; }
h1 { font-size: clamp(1.6rem, 5vw, 2.4rem); }
h2 { font-size: 1.25rem; }
p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }

a { color: inherit; text-underline-offset: 0.2em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
h1:focus-visible { outline-offset: 6px; }
h1:focus:not(:focus-visible) { outline: none; } /* Headings get focus from the game, not the keyboard. */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.icon { width: 1.5rem; height: 1.5rem; vertical-align: middle; }
.icon-large { width: 2.25rem; height: 2.25rem; }

/* ---------- Layout ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem 0;
  min-height: 3.75rem;
}
.topbar-right { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }
.language-button {
  min-height: 2.75rem;
  padding: 0.4rem 1rem;
  font-weight: 600;
  background: var(--white);
  color: var(--black);
  border: 2px solid var(--edge);
  border-radius: 999px;
}

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  min-height: calc(100vh - 4rem);
  padding: 1rem 1rem 3rem;
  text-align: center;
}
.screen[hidden] { display: none; }

.title { font-size: clamp(2.5rem, 10vw, 3.75rem); }
.intro { max-width: 40rem; font-size: 1.25rem; }
.big { font-size: 1.25rem; }

/* The tilted label with a coloured background, used for names and numbers. */
.tag {
  display: inline-block;
  margin: 0 0.15em;
  padding: 0 0.3em;
  background: var(--tag-bg);
  color: var(--tag-ink);
  box-shadow: 3px 3px 3px rgb(0 0 0 / 0.5);
  transform: rotate(-3deg);
}
.tilt-right { transform: rotate(3deg); }
.tag-white { --tag-bg: var(--white); --tag-ink: var(--black); }
.tag-orange { --tag-bg: var(--orange); --tag-ink: var(--black); }
.tag-black { --tag-bg: var(--black); --tag-ink: var(--white); }

/* ---------- Buttons and fields ---------- */

button { font: inherit; color: inherit; cursor: pointer; }

.button {
  min-width: 14rem;
  min-height: 2.75rem;
  padding: 0.6rem 1.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  border: 2px solid var(--edge);
  border-radius: 999px;
}
.button-white { background: var(--white); color: var(--black); }
.button-black { background: var(--black); color: var(--white); }
.button-small { min-width: 8rem; font-size: 1rem; }

.choice-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; }
.choice {
  min-width: 10rem;
  min-height: 2.75rem;
  padding: 0.6rem 1rem;
  font-weight: 600;
  background: var(--beige);
  color: var(--black);
  border: 2px solid var(--edge);
  border-radius: 1rem;
}

.text-button,
.round-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  background: transparent;
  border: 0;
  font-size: 1.1rem;
}
.round-button {
  justify-content: center;
  width: 3rem;
  height: 3rem;
  background: var(--white);
  border: 2px solid var(--edge);
  border-radius: 50%;
}
.text-button .icon { width: 2rem; height: 2rem; }
body[data-tone="dark"] .text-button .icon { filter: invert(1); }

#names-form { display: grid; gap: 1.25rem; justify-items: center; width: 100%; max-width: 30rem; }
.name-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 1rem; width: 100%; }
.field { display: grid; gap: 0.3rem; text-align: left; }
.field label { font-weight: 600; }
.field input {
  width: 100%;
  min-height: 2.75rem;
  font: inherit;
  padding: 0.5rem 0.75rem;
  color: var(--black);
  background: var(--white);
  border: 2px solid var(--edge);
  border-radius: 1rem;
}
.field input[aria-invalid="true"] { border-color: var(--error); border-width: 3px; }
.error { color: var(--error); font-weight: 600; font-size: 1rem; }
.error:empty { display: none; }
.error:not(:empty)::before { content: "⚠ "; }

.player-list { display: grid; gap: 0.6rem; font-size: 1.25rem; font-weight: 600; }
.score-list { display: grid; gap: 0.6rem; font-size: 1.25rem; }
.end-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.25rem; }

/* ---------- The round ---------- */

#screen-play { justify-content: flex-start; }
.round-title { font-size: 1.75rem; }
.round-number {
  display: inline-block;
  padding: 0 0.6rem;
  background: var(--white);
  color: var(--black);
  border-radius: 1rem;
}

.play-grid {
  display: grid;
  gap: 1.5rem;
  width: 100%;
  max-width: 70rem;
}
.play-info { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.timer { display: flex; align-items: center; gap: 0.5rem; font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hurry .timer { color: var(--orange); }
.forbidden {
  width: 100%;
  padding: 1rem;
  border: 4px solid var(--white);
}
.forbidden h2 { font-weight: 300; font-size: 1.1rem; margin-bottom: 0.5rem; }
.forbidden ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 1.25rem; font-size: 1.5rem; font-weight: 600; }
.score { font-size: 1.25rem; font-weight: 600; }
.score-number { color: var(--orange); }

.play-painting { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.describe { font-size: 1.25rem; font-weight: 600; }
.painting {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  width: auto;
  height: auto;
}
.painting-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; }
.painting-buttons .button { min-width: 11rem; }

@media (min-width: 48rem) {
  .play-grid { grid-template-columns: 3fr 5fr; align-items: start; }
  .forbidden ul { flex-direction: column; }
}

/* ---------- Big message and menu ---------- */

.flash {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgb(0 0 0 / 0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.flash.visible { opacity: 1; pointer-events: auto; }
.flash-text {
  font-size: clamp(2.5rem, 12vw, 5rem);
  font-weight: 700;
  text-align: center;
  transform: rotate(-5deg) scale(0);
  transition: transform 0.25s;
}
.flash.visible .flash-text { transform: rotate(-5deg) scale(1); }

dialog {
  --focus: var(--black);
  width: min(30rem, calc(100% - 2rem));
  padding: 3rem 1.5rem 2rem;
  border: 0;
  border-radius: 1.25rem;
  background: var(--white);
  color: var(--black);
  text-align: center;
}
dialog[open] { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
dialog::backdrop { background: rgb(0 0 0 / 0.65); }
dialog h2 { font-size: 1.9rem; }
.close-form { position: absolute; top: 0.5rem; right: 0.5rem; }
.close-button { border-color: transparent; }

@media (prefers-reduced-motion: reduce) {
  .flash, .flash-text { transition: none; }
  .flash-text, .flash.visible .flash-text { transform: rotate(-5deg); }
}

/* ---------- Plain pages (404) ---------- */

.page { max-width: 38rem; margin: 0 auto; padding: 3rem 1.25rem; }
