/* Play page: the 3D world with a toy-brick HUD on top */

.game {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --below-hud: calc(var(--safe-top) + 84px);
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #29b6e6;
  font-family: "Nunito", sans-serif;
  color: #12324f;
  -webkit-tap-highlight-color: transparent;
  /* Thumbs dragging over the game must never select words or the picture */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.game input,
.game textarea {
  -webkit-user-select: text;
  user-select: text;
}

.game ::selection { background: transparent; }
.game input::selection,
.game textarea::selection { background: #b3e5fc; }

.game__viewport {
  position: absolute;
  inset: 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Under water: a soft blue wobble over everything */
.game__viewport.is-underwater::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 0%, rgba(160, 230, 255, 0.35), rgba(0, 90, 160, 0.35));
}

.game__viewport canvas {
  display: block;
}

.game__hud {
  position: absolute;
  top: calc(var(--safe-top) + 16px);
  left: calc(var(--safe-left) + 16px);
  right: calc(var(--safe-right) + 16px);
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.game__hud > * {
  pointer-events: auto;
}

.game.is-playing:not(.is-touch) .game__hud :is(a, button) {
  pointer-events: none;
}

.game__spacer {
  flex-grow: 1;
}

.game__logo {
  font-family: "Lilita One", sans-serif;
  font-size: 30px;
  color: #fff;
  text-decoration: none;
  text-shadow: 3px 3px 0 #1d3f9e;
}

.game__badge {
  padding: 6px 14px;
  background: #f5821f;
  color: #fff;
  font-weight: 800;
}

.game__badge--player {
  background: #7048e8;
}

.game__badge--time {
  background: #1d3f9e;
}

.game__badge--time.is-low {
  background: #e03131;
}

.game__badge--online {
  background: #12b886;
}

.game__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  background: #fff;
  color: #12324f;
  font: 800 17px "Nunito", sans-serif;
  box-shadow: 0 5px 0 #1d3f9e;
  cursor: pointer;
}

.game__crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  background:
    linear-gradient(#fff, #fff) center / 4px 100% no-repeat,
    linear-gradient(#fff, #fff) center / 100% 4px no-repeat;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.6));
}

.game__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(18, 50, 79, 0.35);
}

.game__overlay[hidden],
.game__crosshair[hidden],
.game__badge[hidden] {
  display: none;
}

.game__card {
  max-width: 460px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px - var(--safe-top) - var(--safe-bottom));
  overflow-y: auto;
  padding: 28px 32px;
  background: #fff;
  border: 5px solid #12324f;
  box-shadow: 0 8px 0 #1d3f9e;
  text-align: center;
}

.game__card--wide {
  max-width: 560px;
  text-align: left;
}

.game__card h1 {
  margin: 0 0 8px;
  font: 400 40px "Lilita One", sans-serif;
  color: #1d3f9e;
}

.game__card h2 {
  margin: 20px 0 10px;
  font: 400 24px "Lilita One", sans-serif;
}

.game__card p {
  font-size: 18px;
  font-weight: 600;
}

.game__play {
  min-height: 56px;
  padding: 0 32px;
  border: 0;
  background: #f5821f;
  color: #fff;
  font: 400 28px "Lilita One", sans-serif;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 5px 0 #b85400;
}

.game__hint {
  font-size: 15px !important;
  color: #3b5068;
}

.game__controls {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 16px;
  align-items: center;
  margin: 0;
}

.game__controls dt {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.game__controls dd {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.game kbd {
  display: inline-block;
  min-width: 34px;
  padding: 4px 8px;
  background: #f7c52b;
  border: 3px solid #12324f;
  box-shadow: 0 3px 0 #12324f;
  font: 800 15px "Nunito", sans-serif;
  text-align: center;
}

.game__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

/* Anything hidden stays hidden, even if it is normally flex or grid */
.game [hidden] {
  display: none !important;
}

/* Hotbar: six build menus, the chest and the delete tool */
.game__hotbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + 14px);
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 calc(var(--safe-right) + 16px) 0 calc(var(--safe-left) + 16px);
  pointer-events: none;
}

.game__slot {
  position: relative;
  width: 84px;
  height: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 4px solid #12324f;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 -6px 0 #dbe4ee;
  color: #12324f;
  font: 800 13px "Nunito", sans-serif;
  cursor: pointer;
  pointer-events: auto;
}

/* Eleven slots: smaller ones on narrower screens, so they stay in one row */
@media (max-width: 1080px) {
  .game:not(.is-touch) .game__slot { width: 66px; height: 66px; font-size: 11px; }
  .game:not(.is-touch) .game__hotbar { gap: 5px; }
}

.game.is-playing:not(.is-touch) .game__slot {
  pointer-events: none;
}

@media (hover: hover) {
  .game__slot:hover {
    transform: translateY(-3px);
  }

  .game__door:hover {
    transform: translateY(-4px);
  }
}

.game__slot-symbol {
  font: 400 28px/1 "Lilita One", sans-serif;
  color: #1d3f9e;
}

.game__slot-key {
  position: absolute;
  left: 4px;
  top: 2px;
  font-size: 11px;
  color: #3b5068;
}

.game__slot-count {
  position: absolute;
  right: -8px;
  top: -8px;
  min-width: 24px;
  padding: 2px 6px;
  background: #f5821f;
  color: #fff;
  border: 3px solid #12324f;
}

.game__slot--delete.is-on {
  background: #ffc9c9;
  border-color: #c92a2a;
}

.game__slot--move.is-on {
  background: #d0ebff;
  border-color: #1c7ed6;
}

/* "G: sit on the Chair" under the crosshair */
.game__use-hint {
  position: absolute;
  left: 50%;
  top: calc(50% + 28px);
  margin: 0;
  padding: 4px 12px;
  transform: translateX(-50%);
  background: rgba(18, 50, 79, 0.75);
  color: #fff;
  font: 800 16px "Nunito", sans-serif;
  pointer-events: none;
  white-space: nowrap;
}

.game__use-hint[hidden] {
  display: none;
}

/* Messages */
.game__tool,
.game__toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 18px;
  max-width: calc(100% - 32px);
  font-weight: 800;
  font-size: 17px;
  text-align: center;
  pointer-events: none;
}

.game__tool {
  top: var(--below-hud);
  background: #1d3f9e;
  color: #fff;
}

.game__tool.is-delete {
  background: #c92a2a;
}

.game__toast {
  bottom: 120px;
  background: #fff;
  color: #12324f;
  border: 4px solid #12324f;
}

/* Jail: time left and the fine button */
.game__jail {
  position: absolute;
  top: calc(var(--below-hud) + 50px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 14px;
  background: #1c7ed6;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  border: 4px solid #12324f;
  z-index: 3;
  max-width: calc(100% - 32px);
}

/* Emoji balloons: the last three, and the big grid */
.game__emoji-bar {
  position: absolute;
  bottom: 120px;
  right: 16px;
  display: flex;
  gap: 8px;
  padding: 8px;
  background: #fff;
  border: 4px solid #12324f;
  z-index: 3;
}
.game__emoji-bar > span { display: flex; gap: 8px; }
.game__emoji {
  position: relative;
  min-width: 56px;
  height: 56px;
  font-size: 32px;
  border: 3px solid #12324f;
  background: #fff8db;
  cursor: pointer;
}
.game__emoji kbd {
  position: absolute;
  top: -10px;
  left: -8px;
  min-width: 0;
  padding: 0 4px;
  border-width: 2px;
  box-shadow: none;
  font-size: 11px;
  line-height: 1.3;
}
.game__emoji--more { font-size: 16px; font-weight: 800; padding: 0 10px; }
.game__emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

/* A paintball hit: a quick splash of colour on the screen */
.game__splat {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease-out;
  z-index: 2;
}
.game__splat.is-on { opacity: 0.45; transition: none; }

/* The road map */
.game__card--map { max-width: min(760px, calc(100vw - 32px)); }
.game__map {
  display: block;
  width: min(100%, 64vh);
  aspect-ratio: 1;
  margin: 8px auto;
  border: 4px solid #12324f;
  touch-action: none;
  cursor: crosshair;
}

/* Shows (planetarium, the Moon): words over the picture */
.game__show {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.game__caption {
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  width: min(640px, calc(100% - 32px));
  padding: 14px 20px;
  background: rgba(11, 26, 74, 0.82);
  color: #fff;
  border: 4px solid #ffd43b;
  text-align: center;
  animation: caption-in 0.6s ease-out;
}
.game__caption h2 { margin: 0 0 4px; font-family: "Lilita One", sans-serif; font-size: 34px; color: #ffd43b; }
.game__caption p { margin: 0 0 6px; font-size: 19px; font-weight: 800; }
.game__caption strong { font-size: 22px; color: #8ce99a; }
.game__show-hint {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 14px;
  background: #fff;
  color: #12324f;
  font-weight: 800;
  border: 4px solid #12324f;
}
.game__show-hint:empty { display: none; }
/* The bear's cave: is the bear home? Are you safe up high? */
.game__show-status {
  position: absolute;
  top: 16px;
  left: 16px;
  max-width: calc(100% - 180px);
  margin: 0;
  padding: 6px 14px;
  background: #fff3bf;
  color: #5c3a1a;
  font-weight: 800;
  border: 4px solid #f08c00;
}
.game__show-status:empty { display: none; }
.game__show-skip { position: absolute; top: 16px; right: 16px; pointer-events: auto; }
.game.is-show .game__hud,
.game.is-show .game__hotbar,
.game.is-show .game__crosshair,
.game.is-show .game__use-hint { visibility: hidden; }
@keyframes caption-in {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Menu and chest item grids */
.game__items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.game__item {
  position: relative;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 4px solid #12324f;
  background: #fff8e1;
  color: #12324f;
  font: 800 16px "Nunito", sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 0 #12324f;
}

.game__item:hover {
  background: #ffe8a3;
}

.game__item-icon {
  font-size: 40px;
  line-height: 1;
}

.game__item-count {
  position: absolute;
  right: 6px;
  top: 4px;
  color: #f5821f;
}

/* Grand Prix circuits at the top of the Town menu */
.game__circuits {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 4px dashed #12324f;
  border-radius: 14px;
  background: repeating-conic-gradient(#ffffff 0 25%, #f1f3f5 0 50%) 0 0 / 24px 24px;
}

.game__circuits-title {
  margin: 0;
  text-align: center;
}

.game__circuits-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.game__circuit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border: 4px solid #12324f;
  border-radius: 12px;
  background: #fff8e1;
  color: #12324f;
  font: 800 15px "Nunito", sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 0 #12324f;
}

.game__circuit:hover { background: #ffe8a3; }

.game__circuit canvas {
  width: 100%;
  max-width: 180px;
  aspect-ratio: 1;
}

.game__circuit-name { text-align: center; line-height: 1.15; }
.game__circuit-info { font-size: 12px; color: #1d3f9e; text-align: center; }

@media (max-width: 560px) {
  .game__circuits-row { grid-template-columns: 1fr; }
  .game__circuit { flex-direction: row; text-align: left; }
  .game__circuit canvas { width: 90px; }
}

/* Maths doors */
.game__card--doors {
  max-width: 860px;
  width: 100%;
  text-align: left;
}

.game__doors-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
}

.game__doors {
  flex: 1 1 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.game__door {
  position: relative;
  width: 150px;
  height: 230px;
  border: 6px solid #8a4b10;
  background: #f5821f;
  box-shadow: inset 0 0 0 10px #d96c0d;
  cursor: pointer;
  transition: transform 0.15s;
}

.game__door.is-chosen {
  border-color: #ffd23f;
  box-shadow: inset 0 0 0 10px #d96c0d, 0 0 0 6px #ffd23f;
}

.game__door-sum {
  display: inline-block;
  padding: 10px 12px;
  background: #fff8e7;
  border: 4px solid #12324f;
  font: 400 28px "Lilita One", sans-serif;
  color: #12324f;
}

.game__door-knob {
  position: absolute;
  right: 18px;
  top: 160px;
  width: 12px;
  height: 12px;
  background: #ffd23f;
}

.game__or {
  padding: 6px 14px;
  border: 4px solid #12324f;
  font: 400 24px "Lilita One", sans-serif;
}

.game__answer-panel {
  flex: 0 1 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 220px;
  margin: 0 auto;
}

.game__card .game__prompt {
  margin: 0;
  font-weight: 800;
}

.game__answer {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 14px;
  background: #e7f6fd;
  border: 4px solid #12324f;
  font: 400 36px "Lilita One", sans-serif;
}

.game__keypad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  justify-content: center;
  gap: 6px;
}

.game__key {
  height: 44px;
  padding: 0;
  touch-action: manipulation;
  border: 3px solid #12324f;
  background: #fff;
  box-shadow: 0 4px 0 #12324f;
  font: 800 22px "Nunito", sans-serif;
  color: #12324f;
  cursor: pointer;
}

.game__key:active {
  transform: translateY(4px);
  box-shadow: none;
}

.game__key--ok {
  background: #69db7c;
  font-size: 17px;
}

.game__key--del {
  background: #ffc9c9;
}

.game__card .game__feedback {
  min-height: 24px;
  margin: 0;
  font-weight: 800;
}

.game__feedback.is-right { color: #2b8a3e; }
.game__feedback.is-wrong { color: #c92a2a; }

.game__progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  font-weight: 800;
}

.game__stars {
  display: flex;
  gap: 6px;
}

.game__star {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #12324f;
  background: #dbe4ee;
  color: #fff;
}

.game__star.is-done {
  background: #f5821f;
}

.game__card .game__done-text {
  font: 400 26px "Lilita One", sans-serif;
  text-align: center;
  color: #2b8a3e;
}

.game__actions--center {
  justify-content: center;
}

/* Avatar maker */
.game__card--avatar {
  max-width: 900px;
  width: 100%;
  text-align: left;
}

.game__avatar-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.game__avatar-stage {
  flex: 0 0 220px;
  min-height: 340px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 16px;
  background: #2fa636 radial-gradient(circle at 35% 35%, #4cc153 30%, transparent 32%) 0 0 / 14px 14px;
  border: 4px solid #12324f;
}

.game__avatar-rows {
  flex: 1 1 380px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.game__avatar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.game__avatar-label {
  width: 100px;
  font-weight: 800;
}

.game__swatch {
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  border: 4px solid #12324f;
  background: #fff;
  color: #12324f;
  font: 800 14px "Nunito", sans-serif;
  cursor: pointer;
}

.game__swatch[aria-pressed="true"] {
  outline: 4px solid #f5821f;
  outline-offset: 2px;
}

/* The flat avatar preview, built from blocks */
.avatar-preview {
  position: relative;
  width: 120px;
  height: 280px;
}

.avatar-preview > span,
.avatar-preview__head > span {
  position: absolute;
  display: block;
}

.avatar-preview__head { left: 30px; top: 30px; width: 60px; height: 60px; background: var(--skin); }
.avatar-preview__hair { left: 0; top: 0; width: 60px; height: 14px; background: var(--hair); }
.avatar-preview__eye { top: 26px; width: 8px; height: 8px; background: #12324f; }
.avatar-preview__eye--l { left: 14px; }
.avatar-preview__eye--r { left: 38px; }
.avatar-preview__glasses {
  left: 8px; top: 22px; width: 44px; height: 14px;
  background: linear-gradient(90deg, var(--glasses) 0 20px, transparent 20px 24px, var(--glasses) 24px);
}
.avatar-preview__mouth { left: 20px; top: 46px; width: 20px; height: 4px; background: #c2255c; }
.avatar-preview__body { left: 20px; top: 90px; width: 80px; height: 80px; background: var(--top); }
.avatar-preview__arm { top: 90px; width: 20px; height: 76px; background: var(--top); border-bottom: 14px solid var(--skin); }
.avatar-preview__arm--l { left: 0; }
.avatar-preview__arm--r { left: 100px; }
.avatar-preview__leg { top: 170px; width: 38px; height: 84px; background: var(--trousers); border-bottom: 16px solid var(--shoes); }
.avatar-preview__leg--l { left: 20px; }
.avatar-preview__leg--r { left: 62px; }

/* Girls: long hair at the sides and a ponytail */
.avatar-preview__ponytail { left: 86px; top: 40px; width: 14px; height: 50px; background: var(--hair); display: none !important; }
.avatar-preview[data-kind="girl"] .avatar-preview__ponytail { display: block !important; }
.avatar-preview[data-kind="girl"] .avatar-preview__head { box-shadow: -6px 0 0 0 var(--hair), 6px 0 0 0 var(--hair); }

/* Hats */
.avatar-preview__hat { left: 28px; top: 14px; width: 64px; height: 18px; display: none !important; }
.avatar-preview[data-hat="cap"] .avatar-preview__hat { display: block !important; background: #1c7ed6; box-shadow: 18px 8px 0 -4px #1864ab; }
.avatar-preview[data-hat="crown"] .avatar-preview__hat {
  display: block !important; background: #fcc419;
  clip-path: polygon(0 100%, 0 0, 25% 55%, 50% 0, 75% 55%, 100% 0, 100% 100%);
}
.avatar-preview[data-hat="bobble"] .avatar-preview__hat { display: block !important; background: #e64980; box-shadow: 0 -10px 0 -6px #fff; }
.avatar-preview[data-hat="earmuffs"] .avatar-preview__hat { display: block !important; top: 20px; height: 8px; background: #f783ac; z-index: 2; }
.avatar-preview[data-hat="earmuffs"] .avatar-preview__hat::before,
.avatar-preview[data-hat="earmuffs"] .avatar-preview__hat::after {
  content: ""; position: absolute; top: 24px; width: 16px; height: 24px; background: #fff0f6; border: 3px solid #f783ac;
}
.avatar-preview[data-hat="earmuffs"] .avatar-preview__hat::before { left: -8px; }
.avatar-preview[data-hat="earmuffs"] .avatar-preview__hat::after { right: -8px; }

/* T-shirt pictures */
.avatar-preview .avatar-preview__design {
  position: absolute; left: 20px; top: 14px; width: 40px; height: 40px;
  font-size: 32px; line-height: 40px; text-align: center;
}
.avatar-preview[data-design="stripes"] .avatar-preview__body {
  background: repeating-linear-gradient(var(--top) 0 10px, #fff 10px 20px);
}

.game__play--danger {
  background: #c92a2a;
  box-shadow: 0 5px 0 #7a1414;
}

/* Things only for mouse-and-keyboard players, or only for touch screens */
.game .only-touch,
.game.is-touch .only-mouse {
  display: none !important;
}

.game.is-touch .only-touch {
  display: revert !important;
}

.game__key-hint {
  min-width: 0 !important;
  padding: 0 6px !important;
  border-width: 2px !important;
  box-shadow: none !important;
  font-size: 12px !important;
}

.game.is-touch .game__key-hint,
.game.is-touch .game__slot-key {
  display: none;
}

/* Settings: a wide instruction booklet with three coloured bricks side by side */
.game__card--settings {
  width: min(1040px, 100%);
  max-width: none;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  text-align: left;
}

.game__settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 24px 4px;
}

.game__card .game__settings-head h1 {
  margin: 0;
}

.game__close {
  width: 48px;
  height: 48px;
  flex: none;
  border: 4px solid #12324f;
  background: #fff;
  color: #12324f;
  font: 800 22px "Nunito", sans-serif;
  box-shadow: 0 4px 0 #12324f;
  cursor: pointer;
}

.game__settings-body {
  overflow-y: auto;
  padding: 16px 24px 20px;
}

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

.game__help-group {
  --brick: #1d3f9e;
  --brick-text: #fff;
  position: relative;
  border: 4px solid #12324f;
  background: #fff;
}

.game__help-group--building { --brick: #f7c52b; --brick-text: #12324f; }
.game__help-group--fun { --brick: #f5821f; }

/* The coloured top of each group is a brick, studs and all */
.game__help-group::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: -14px;
  height: 10px;
  background: repeating-linear-gradient(90deg, var(--brick) 0 26px, transparent 26px 40px);
  border-radius: 3px 3px 0 0;
}

.game__card .game__help-group h2 {
  margin: 0;
  padding: 8px 14px 6px;
  background: var(--brick);
  color: var(--brick-text);
  font-size: 24px;
  border-bottom: 4px solid #12324f;
}

.game__help-group dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 12px;
  margin: 0;
  padding: 4px 14px 8px;
}

.game__help-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: center;
  padding: 7px 0;
}

.game__help-row + .game__help-row {
  border-top: 2px dashed #dbe4ee;
}

.game__help-row dt span {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.game__help-row dd {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.game__help kbd {
  min-width: 30px;
  padding: 2px 7px;
  font-size: 14px;
}

.game__card .game__together-help {
  margin: 18px 0 0;
  padding: 12px 14px;
  background: #e6fcf5;
  border: 4px solid #12b886;
  font-size: 16px;
}

.game__actions--settings {
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  padding: 14px 24px calc(16px + var(--safe-bottom));
  background: #e7f6fd;
  border-top: 4px solid #12324f;
}

@media (max-width: 920px) {
  .game__help {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Touch screens: a joystick for the left thumb, and stud buttons for the right */
.game__stick {
  position: absolute;
  left: 0;
  top: 0;
  width: 128px;
  height: 128px;
  margin: -64px 0 0 -64px;
  border: 4px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  background: rgba(18, 50, 79, 0.18);
  pointer-events: none;
}

.game__stick span {
  position: absolute;
  left: 30px;
  top: 30px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #fff 0 30%, #eef3f8 31% 100%);
  box-shadow: 0 5px 0 #b9c6d3, 0 6px 10px rgba(0, 0, 0, 0.25);
}

.game__pad {
  display: none;
  position: absolute;
  right: calc(var(--safe-right) + 16px);
  bottom: calc(var(--safe-bottom) + 16px);
  width: 180px;
  height: 224px;
  pointer-events: none;
}

.game.is-touch.is-playing .game__pad {
  display: block;
}

/* Round like the studs on top of a toy brick */
.game__stud {
  position: absolute;
  width: 62px;
  height: 62px;
  border: 4px solid #12324f;
  border-radius: 50%;
  background: radial-gradient(circle at 28% 22%, rgba(255, 255, 255, 0.5) 0 9%, transparent 10%), var(--stud);
  box-shadow: 0 5px 0 #12324f;
  color: #fff;
  font: 400 16px/1 "Lilita One", sans-serif;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.game__stud:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #12324f;
}

.game__stud--jump { --stud: #f5821f; right: 0; bottom: 0; width: 88px; height: 88px; font-size: 20px; }
.game__stud--fly { --stud: #1d3f9e; right: 117px; bottom: 13px; }
.game__stud--down { --stud: #1d3f9e; right: 87px; bottom: 87px; }
.game__stud--use { --stud: #2fa636; right: 13px; bottom: 117px; }
.game__stud--turn { --stud: #f7c52b; color: #12324f; text-shadow: none; right: 98px; bottom: 160px; }

.game.is-touch .game__crosshair {
  width: 26px;
  height: 26px;
}

/* Touch, sideways (phones on their side, iPads): build bar between the thumbs */
.game.is-touch .game__hotbar {
  --slot: 60px;
  gap: 6px;
  padding: 0 calc(var(--safe-right) + 210px) 0 calc(var(--safe-left) + 24px);
}

.game.is-touch .game__slot {
  width: var(--slot);
  height: var(--slot);
  border-width: 3px;
  font-size: 11px;
}

.game.is-touch .game__slot-symbol {
  font-size: 22px;
}

.game.is-touch .game__toast {
  top: calc(var(--below-hud) + 48px);
  bottom: auto;
}

@media (max-height: 500px) {
  .game.is-touch .game__hotbar { --slot: 52px; }
  .game.is-touch .game__slot-name { font-size: 9px; }
  .game { --below-hud: calc(var(--safe-top) + 72px); }
}

/* Touch, upright (phones, iPads in portrait): build bar under the top bar, thumbs below */
@media (orientation: portrait) {
  .game.is-touch {
    --below-hud: calc(var(--safe-top) + 84px + 2 * var(--slot-row) + 12px);
    --slot-row: 62px;
  }

  .game.is-touch .game__hotbar {
    --slot: 58px;
    top: calc(var(--safe-top) + 76px);
    bottom: auto;
    padding: 0 calc(var(--safe-right) + 12px) 0 calc(var(--safe-left) + 12px);
  }
}

@media (orientation: portrait) and (min-width: 700px) {
  .game.is-touch { --slot-row: 36px; }
  .game.is-touch .game__hotbar { --slot: 68px; }
}

/* Small screens: tighter top bar and cards that fit */
@media (max-width: 640px) {
  .game__hud { gap: 8px; }
  .game__button-text { display: none; }
  .game__button { min-height: 44px; padding: 0 12px; font-size: 15px; }
  .game__badge { padding: 5px 10px; font-size: 14px; }
  .game__overlay { padding: calc(var(--safe-top) + 10px) 10px calc(var(--safe-bottom) + 10px); }
  .game__card { padding: 20px 16px; }
  .game__card h1 { font-size: 32px; }
  .game__actions { flex-wrap: wrap; }
  .game__actions > * { flex: 1 1 auto; justify-content: center; }
  .game__help { grid-template-columns: minmax(0, 1fr); }
  .game__settings-head { padding: 14px 16px 2px; }
  .game__settings-body { padding: 14px 16px 16px; }
  .game__actions--settings { padding: 12px 16px calc(12px + var(--safe-bottom)); }
  .game__actions--settings .game__spacer { display: none; }
  .game__door { width: 118px; height: 180px; }
  .game__door-knob { top: 120px; }
  .game__door-sum { font-size: 22px; padding: 8px; }
  .game__items { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .game__avatar-stage { flex-basis: 100%; min-height: 300px; }
  .game__avatar-label { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .game__slot, .game__door, .game__stud { transition: none; transform: none !important; }
}

.game.is-touch .game__help-row dt .only-touch {
  display: flex !important;
}

.game__help-row dt {
  max-width: 116px;
}

/* Short screens (phones on their side): squeeze the cards so the keypad fits */
@media (max-height: 500px) {
  .game__overlay { padding-top: calc(var(--safe-top) + 8px); padding-bottom: calc(var(--safe-bottom) + 8px); }
  .game__card { padding: 14px 20px; }
  .game__card h1 { font-size: 26px; margin-bottom: 4px; }
  .game__card p { margin: 4px 0; font-size: 16px; }
  .game__doors-layout { flex-wrap: nowrap; gap: 16px; }
  .game__doors { flex: 1 1 auto; gap: 10px; }
  .game__door { width: 104px; height: 156px; }
  .game__door-knob { top: 100px; right: 12px; }
  .game__door-sum { font-size: 20px; padding: 6px 8px; }
  .game__answer-panel { flex: 0 0 250px; gap: 6px; }
  .game__answer { height: 42px; font-size: 28px; }
  .game__key { height: 38px; font-size: 18px; }
  .game__progress { margin-top: 8px; }
  .game__star { width: 26px; height: 26px; }
  .game__actions { margin-top: 10px; }
  .game__settings-head { padding-top: 10px; }
}

/* "Switch player" is a little form (it logs you out), laid out like the other buttons */
.game__switch {
  display: contents;
}

/* "Oops, something went wrong" on the Click to play card */
.game__problem {
  margin: 12px 0 0;
  padding: 8px 12px;
  background: #fff5f5;
  border: 3px solid #c92a2a;
  color: #c92a2a;
  font-weight: 800;
  font-size: 14px;
  text-align: left;
  overflow-wrap: anywhere;
}

/* A code door's keypad, laid out like a phone's (only inside the code-door card) */
.game__card--keypad { max-width: 360px; }
.game__card--keypad .game__keypad { display: flex; flex-direction: column; align-items: stretch; box-sizing: border-box; width: 100%; background: #343a40; border-radius: 18px; padding: 14px; margin: 12px auto; max-width: 260px;
                box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.3); }
.game__keypad-screen { background: #0b3d2e; color: #69db7c; font: 800 1.4rem/1.2 Nunito, sans-serif; text-align: center;
                       border-radius: 10px; padding: 10px 8px; min-height: 1.4em; margin-bottom: 12px; letter-spacing: 0.15em; }
.game__keypad-screen.is-said { font-size: 0.95rem; letter-spacing: 0; }
.game__keys { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.game__card--keypad .game__key { width: 100%; height: auto; min-width: 0; margin: 0; font: 800 1.6rem/1 Nunito, sans-serif; padding: 14px 0; border: 0; border-radius: 12px; cursor: pointer;
             background: #f8f9fa; color: #1d3f9e; box-shadow: 0 5px 0 #adb5bd; touch-action: manipulation; }
.game__card--keypad .game__key:active { transform: translateY(4px); box-shadow: 0 1px 0 #adb5bd; }
.game__card--keypad .game__key[data-key="*"], .game__card--keypad .game__key[data-key="#"] { background: #f7c52b; box-shadow: 0 5px 0 #c99a12; }

/* A Brick Academy award's note */
.game__card--award { background: #fff9db; }
.game__award-note { white-space: pre-line; font-size: 1.15rem; font-weight: 700; line-height: 1.5; font-style: italic; }

/* Small phones: narrower doors so both fit beside the OR */
@media (max-width: 420px) {
  .game__doors { gap: 8px; }
  .game__door { width: 96px; height: 150px; }
  .game__door-knob { top: 100px; right: 12px; }
  .game__door-sum { font-size: 18px; padding: 6px; }
  .game__or { padding: 4px 8px; font-size: 18px; }
}

/* The space jet's Mission Control: a small panel at the side of the cockpit (bottom on tall screens) */
.game__dash {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(330px, 36%);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 8px 10px;
  background: rgba(11, 16, 51, 0.82);
  color: #fff;
  border: 3px solid #f783ac;
  border-radius: 6px;
  pointer-events: auto;
  font-weight: 800;
}
.game__dash[hidden] { display: none; }
.dash__top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.game__dash h2 { margin: 0; font-family: "Lilita One", sans-serif; font-size: 20px; color: #fcc2d7; }
.game__dash h3 { margin: 6px 0 4px; font-size: 13px; color: #ffd43b; }
.dash__fold {
  padding: 4px 8px;
  background: #1c2366;
  color: #fff;
  border: 2px solid #4c5bd4;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  touch-action: manipulation;
}
.game__dash.is-folded .dash__body { display: none; }
.dash__where, .dash__info { margin: 2px 0 0; font-size: 12px; line-height: 1.3; }
.dash__info { margin-top: 6px; padding: 5px 7px; background: rgba(255, 255, 255, 0.1); }
.dash__planets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.dash__speeds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.dash__planet, .dash__speed {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 2px;
  background: #1c2366;
  color: #fff;
  border: 2px solid #4c5bd4;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  line-height: 1.15;
  cursor: pointer;
  touch-action: manipulation;
}
.dash__planet small, .dash__speed small { font-size: 10px; color: #c5cae9; }
.dash__planet:disabled { opacity: 0.55; cursor: default; }
.dash__planet.is-picked, .dash__speed.is-picked { background: #2b8a3e; border-color: #8ce99a; }
.dash__ball {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0, var(--ball) 45%, #000 140%);
}
.dash__go { display: flex; gap: 6px; margin-top: 6px; }
.dash__launch, .dash__out {
  flex: 1;
  padding: 7px 6px;
  border: 3px solid #12324f;
  border-radius: 6px;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
}
.dash__launch { background: #f783ac; color: #fff; }
.dash__launch:disabled { background: #868e96; cursor: default; }
.dash__out { background: #fff; color: #12324f; flex: 0.7; }
@media (max-aspect-ratio: 1/1) {
  .game__dash { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 46%; }
}
