.screen {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  overflow: auto;
  pointer-events: none;
}

.screen > * { pointer-events: auto; }
.screen.side { place-items: center start; padding-left: calc(5vw + var(--safe-l)); }
.screen.dim { pointer-events: auto; background: rgb(6 30 35 / 55%); }
#notice { z-index: 6; }

/* loading */
#loading { pointer-events: auto; background: var(--enamel); z-index: 8; }
.loader { text-align: center; }
.loader svg { width: 132px; }
.loader .needle { animation: boil 1.4s ease-in-out infinite alternate; }
.loader p { margin-top: 14px; font-size: 20px; }

@keyframes boil {
  from { transform: rotate(-100deg); }
  to { transform: rotate(105deg); }
}

/* title */
#title { place-items: center start; padding-left: calc(5vw + var(--safe-l)); }
.title-column { width: min(480px, 44vw); min-width: 330px; }
.logo { margin: 0 0 6px; }
.logo svg { width: 100%; overflow: visible; }

.logo .letters path {
  fill: none;
  stroke: var(--porcelain);
  stroke-width: 17;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logo .dials circle { fill: var(--enamel-deep); stroke: var(--brass); stroke-width: 13; }
.logo .dials .tick,
.logo .dials .hot { fill: none; stroke: var(--mint); stroke-width: 4; stroke-linecap: round; }
.logo .dials .hot { stroke: var(--hot); }
.logo .dials .hand { fill: var(--hot); }

.pitch {
  width: fit-content;
  margin-bottom: 18px;
  padding: 4px 12px;
  border-radius: 4px;
  background: rgb(10 52 60 / 82%);
  font-size: 21px;
}

.name-field { display: block; max-width: 330px; }

.name-field span {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
}

.play-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 18px 0;
}

.play-dial {
  position: relative;
  flex: none;
  width: 146px;
  height: 146px;
  padding: 0;
  border: 11px solid var(--brass);
  border-radius: 50%;
  background: var(--enamel-deep);
  color: var(--porcelain);
  font-size: 34px;
}

/* the gauge's scale */
.play-dial::before {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: conic-gradient(from 225deg, var(--mint) 0 190deg, var(--hot) 190deg 270deg, transparent 270deg);
  -webkit-mask: radial-gradient(closest-side, transparent 80%, #000 82%);
  mask: radial-gradient(closest-side, transparent 80%, #000 82%);
}

.play-about {
  display: grid;
  max-width: 240px;
  padding: 10px 14px;
  border-radius: 6px;
  background: rgb(10 52 60 / 82%);
}

.play-about strong { font-size: 21px; }
.play-about span { font-size: 15px; color: var(--mint); }

.menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  max-width: 400px;
}

/* panels are enamel signs on a brass frame */
.panel {
  width: min(430px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 24px;
  border: 6px solid var(--brass);
  border-radius: 10px;
  background: var(--enamel);
}

.panel.wide { width: min(780px, 100%); }
.note { margin-top: 12px; color: var(--mint); font-size: 15px; }

.swatches {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
}

.swatches button {
  min-height: 0;
  padding: 0;
  aspect-ratio: 1;
  border-color: transparent;
  border-radius: 50%;
}

.swatches button.on { border-color: var(--porcelain); box-shadow: 0 0 0 3px var(--enamel-deep) inset; }

.hats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.hats button { min-height: 42px; padding: 6px 10px; }
.hats button.on { background: var(--brass); }

.rounds {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rounds button {
  display: grid;
  grid-template-columns: 38px 1fr;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  text-align: left;
}

.rounds b { grid-row: span 2; align-self: center; font-size: 30px; color: var(--copper); }
.rounds strong { font-size: 19px; }
.rounds small { font-size: 14px; }

#join-form { display: grid; gap: 9px; margin-top: 22px; }
#join-form label span { display: block; margin-bottom: 4px; color: var(--mint); }
#party-code { text-transform: uppercase; font-size: 26px; letter-spacing: 0.14em; }

.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 28px;
}

.options label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
}

.options select { max-width: 55%; }
.options input[type='range'] { width: 45%; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 7px 10px 7px 0; text-align: left; }
thead th { color: var(--mint); }
tbody th { color: var(--brass); }

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

.code-row strong { font-size: 38px; letter-spacing: 0.12em; }

.people {
  display: grid;
  gap: 5px;
  max-height: 26vh;
  margin: 12px 0 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.people li { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 15px; }
.people li span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people em { margin-left: auto; padding-left: 8px; color: var(--mint); font-style: normal; white-space: nowrap; }
.people li.ready em { color: var(--brass); }
.people i { flex: none; width: 16px; height: 16px; border: 3px solid var(--brass); border-radius: 50%; }

.field-size { margin-bottom: 0; color: var(--mint); font-size: 15px; }
.bots h3 { margin-top: 12px; }

.segments {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.segments button { min-height: 42px; padding: 5px 4px; font-size: 14px; line-height: 1.1; }
.segments button.on { border-color: var(--brass-dark); background: var(--brass); }

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.stepper button { flex: none; width: 46px; padding: 0; font-size: 22px; }
.stepper input { flex: 1; min-width: 0; height: 40px; }
.stepper strong { flex: none; width: 2ch; font-size: 22px; font-variant-numeric: tabular-nums; text-align: right; }

/* an on/off switch drawn in front of its label */
.toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  align-items: center;
  width: 100%;
  margin-top: 10px;
  padding: 7px 12px;
  border-radius: 18px;
  text-align: left;
}

.toggle::before {
  content: '';
  grid-row: 1 / span 2;
  width: 44px;
  height: 26px;
  border: 3px solid var(--enamel-deep);
  border-radius: 13px;
  background: radial-gradient(circle at 10px 50%, var(--porcelain) 6px, transparent 7px), var(--enamel);
  transition: background-color 0.15s;
}

.toggle[aria-checked='true'] { border-color: var(--brass-dark); }
.toggle[aria-checked='true']::before {
  background: radial-gradient(circle at calc(100% - 10px) 50%, var(--porcelain) 6px, transparent 7px), var(--copper);
}

.toggle span { font-size: 15px; line-height: 1.15; }
.toggle small { font-size: 12px; font-weight: 600; line-height: 1.2; opacity: 0.8; }

.stack { display: grid; gap: 10px; }

.emotes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.emotes button { padding: 6px 2px; font-size: 14px; }

/* result: a lid for every kettle that started, knocked off for those going home */
#result { place-items: center; }

.result {
  width: min(720px, 100%);
  padding: 20px 24px;
  border-radius: 10px;
  background: rgb(10 52 60 / 90%);
  text-align: center;
}

.result h2 { font-size: clamp(30px, 6vw, 52px); }
.result.good h2 { color: var(--brass); }
.result.bad h2 { color: var(--copper); }
.result .actions, .winner .actions { justify-content: center; }

.lids {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lids li {
  position: relative;
  width: 27px;
  height: 27px;
  border: 4px solid var(--brass);
  border-radius: 50%;
  transition: transform 0.5s ease-in, opacity 0.5s ease-in;
}

.lids li.me { outline: 3px solid var(--porcelain); outline-offset: 2px; }
.lids li.gone { transform: translateY(14px) rotate(70deg) scale(0.6); opacity: 0.22; }

#podium { place-items: end center; }
.winner {
  padding: 18px 26px;
  border: 6px solid var(--brass);
  border-radius: 10px;
  background: rgb(15 74 83 / 92%);
  text-align: center;
}

#toast {
  position: fixed;
  z-index: 9;
  bottom: calc(22px + var(--safe-b));
  left: 50%;
  width: max-content;
  max-width: 90vw;
  padding: 10px 18px;
  border-radius: 6px;
  background: var(--enamel-deep);
  transform: translateX(-50%);
}

/* upright phones: the kettle above, the menu below */
@media (max-aspect-ratio: 9/10) {
  #title {
    place-items: stretch;
    padding-left: calc(18px + var(--safe-l));
    padding-right: calc(18px + var(--safe-r));
  }

  .title-column {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 520px;
    min-width: 0;
    margin: 0 auto;
  }

  .pitch { font-size: 17px; }
  .name-field { max-width: none; margin-top: auto; }
  .play-row { margin: 10px 0; }
  .play-dial { width: 98px; height: 98px; border-width: 8px; font-size: 25px; }
  .menu { max-width: none; }
  .menu button { min-height: 42px; padding: 6px 8px; font-size: 15px; }

  .screen.side { place-items: end center; padding-left: calc(16px + var(--safe-l)); }
  .screen.side .panel { max-height: 56vh; }
  #lobby .panel { max-height: 74vh; }
  #lobby .people { max-height: 18vh; }
}

@media (max-width: 620px) {
  .options,
  .rounds { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 16px; }
  .emotes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  h2 { font-size: 27px; }
}

@media (max-width: 620px) {
  table { table-layout: fixed; font-size: 12px; }
  th, td { padding: 6px 5px 6px 0; vertical-align: top; hyphens: auto; overflow-wrap: anywhere; }
  body.touch th:nth-child(2),
  body.touch td:nth-child(2) { display: none; }   /* a phone has no use for the keyboard's column */
}

/* phones on their side */
@media (max-height: 500px) and (min-aspect-ratio: 9/10) {
  .screen { padding-top: calc(8px + var(--safe-t)); padding-bottom: calc(8px + var(--safe-b)); }
  .title-column { width: 52vw; min-width: 290px; }
  .logo svg { max-height: 64px; }
  .pitch { margin-bottom: 6px; font-size: 15px; }
  .name-field input { min-height: 36px; padding-block: 3px; }
  .play-row { margin: 8px 0; gap: 12px; }
  .play-dial { width: 90px; height: 90px; border-width: 7px; font-size: 23px; }
  .play-about strong { font-size: 17px; }
  .play-about span { font-size: 13px; }
  .menu { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .menu button { min-height: 36px; padding: 4px 6px; font-size: 13px; }
  .panel { padding: 12px 18px; }
  h2 { margin-bottom: 6px; font-size: 25px; }
  h3 { margin: 8px 0 4px; font-size: 15px; }
  .lids li { width: 18px; height: 18px; border-width: 3px; }
  .actions { margin-top: 10px; }
  .screen.side .panel { width: min(370px, 56vw); }
  #lobby .people { max-height: none; }
  .bots h3 { margin-top: 6px; }
  .segments button,
  .stepper button { min-height: 36px; font-size: 13px; }
  .toggle { margin-top: 6px; padding: 4px 10px; }
  .toggle small { display: none; }
  .stepper input { height: 32px; }
  .swatches { gap: 5px; }
  .hats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .hats button { min-height: 34px; padding: 3px 2px; font-size: 11px; }
}

/* Done stays in reach when a panel scrolls */
.panel > .actions {
  position: sticky;
  bottom: -24px;
  padding: 8px 0;
  background: var(--enamel);
}

/* "Spela" is a letter longer than "Play", and has to stay inside the dial's scale */
.play-dial:lang(sv) { font-size: 29px; }

@media (max-aspect-ratio: 9/10), (max-height: 500px) {
  .play-dial:lang(sv) { font-size: 18px; }
}
