/* --- FONTS --- */

@font-face {
  font-family: "jua";
  src: url("../assets/fonts/Jua-Regular.ttf") format("truetype");
}

/* --- VARIABLES --- */

:root {
  /* layout */
  --game-width: min(100vw, calc(100vh * 16 / 9) * 0.8);
  /* 80% of the 16:9 area */

  /* colours */
  --page-bg: #ffce49;
  --duck-yellow: #ffc21a;
  /* button fill */
  --duck-orange: #d98f00;
  /* button + chat borders */
  --duck-orange-dark: #b36f00;
  /* button bottom shadow */
  --duck-frame: #ffb300;
  /* game wrapper border */
  --duck-frame-dark: #c77f00;
  /* game wrapper shadow */
  --highlight: #ffd23f;
  /* hover / focus / equipped */
  --text-brown: #5a3a00;
  --input-bg: #fff8e0;
  --panel-bg: rgba(109, 110, 30, 0.85);
  /* profile card */
  --panel-inner-bg: rgba(53, 53, 14, 0.55);
  /* duck + inventory boxes */

  /* shared bits */
  --chat-border: 3.5px solid var(--duck-orange);
  --text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  --card-shadow: 0 8px 0 rgba(0, 0, 0, 0.25), 0 20px 40px rgba(0, 0, 0, 0.35);
}

/* --- RESET --- */

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

/* make the hidden attribute always win, even if an element has its own display value */
[hidden] {
  display: none !important;
}

/* --- BODY --- */

body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
  font-family: "jua", sans-serif;
  background: var(--page-bg);
  user-select: none;
  /* nothing in game can be highlighted */
}

/* --- BUTTONS --- */
/* default pill style, used by every button and the nav links */

button,
.nav-link {
  padding: 0.5rem 1rem;
  font-family: inherit;
  /* buttons don't inherit the font by default */
  font-size: 1.5rem;
  color: var(--text-brown);
  text-decoration: none;
  background: var(--duck-yellow);
  border: 3px solid var(--duck-orange);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--duck-orange-dark);
  cursor: pointer;
}

button:hover,
.nav-link:hover {
  transform: translateY(-2px);
  /* lift */
  box-shadow: 0 5px 0 var(--duck-orange-dark);
}

button:active,
.nav-link:active {
  transform: translateY(2px);
  /* press */
  box-shadow: 0 1px 0 var(--duck-orange-dark);
}

/* --- NAV --- */

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: var(--game-width);
  max-width: 56rem;
  margin-bottom: 1rem;

}

.nav-link {
  font-size: 1.75rem;
  margin-bottom: 0rem;
}

#navTitle {
  font-size: 3.5rem;
  color: var(--text-brown);
}

#navTitle span {
  font-size: 1.5rem;
  opacity: 0.5;
  color: var(--text-brown);
  margin-left: 0.5rem;
}

/* --- GAME --- */

.wrapper {
  --chat-input-h: max(28px, 3cqw);
  /* one height, shared by input and panel */
  container-type: inline-size;
  /* children can use cqw = 1% of wrapper width */

  position: relative;
  width: var(--game-width);
  border: 6px solid var(--duck-frame);
  border-radius: 20px;
  box-shadow: 0 8px 0 var(--duck-frame-dark), 0 20px 40px rgba(0, 0, 0, 0.35);
}

canvas {
  display: block;
  width: 100%;
  /* fill the wrapper, height follows the canvas aspect ratio */
  border-radius: 14px;
}

/* --- JOIN --- */

/* the whole screen: solid olive with a faint sunburst, two columns (duck | form) */
#join {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 2cqw;
  padding: 3cqw 6cqw;
  overflow: hidden;
  color: white;
  background:
    repeating-conic-gradient(from 0deg at 28% 50%, rgba(255, 255, 255, 0.07) 0 8deg, transparent 8deg 16deg),
    #6d6e1e;
  /* same olive as --panel-bg, but solid so the game doesn't show through */
  border-radius: 14px;
}

/* left: title, then the big duck */
#joinLeft {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1cqw;
}

#joinTitle {
  font-size: max(30px, 5.5cqw);
  line-height: 1;
  color: var(--highlight);
  text-shadow: var(--text-shadow);
}

#joinTagline {
  font-size: max(12px, 1.8cqw);
  opacity: 0.85;
}

#signupPreview {
  width: max(120px, 22cqw);
  height: auto;
}

#signupTints {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1cqw;
  max-width: 26cqw;
}

/* right: the form, one column. flex-basis 100% on a child = its own row */
#joinForm {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8cqw;
  width: min(100%, 36cqw);
  justify-self: center;
}

/* input and button share the pill look, sized from the wrapper (em = this font-size) */
#join input,
#join button {
  padding: 0.4em 0.9em;
  font-size: max(12px, 1.8cqw);
  border-width: max(2px, 0.25cqw);
}

/* the input isn't a global button, so it needs the pill look itself */
#join input {
  flex: 1 1 100%;
  text-align: center;
  font-family: inherit;
  color: var(--text-brown);
  background: var(--input-bg);
  border: max(2px, 0.25cqw) solid var(--duck-orange);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--duck-orange-dark);
}

#join input:focus {
  border-color: var(--highlight);
  outline: none;
}

/* every button gets its own row (swatches excluded, they're small dots)... */
#join button:not(.swatch) {
  flex: 1 1 100%;
}

/* ...except on the main form, where sign up + guest share one row */
#join:not(.signup) #registerBtn,
#join:not(.signup) #joinBtn {
  flex: 1 1 0;
}

/* :not(:disabled) so the greyed-out button doesn't wiggle */
#join button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 var(--duck-orange-dark);
}

#join button:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--duck-orange-dark);
}

#join button:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* back looks like text, same as the report cancel button */
#join.signup #backBtn {
  flex: 0 0 auto;
  margin: 0 auto;
  color: white;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  opacity: 0.8;
}

/* reserve the error's space so the form doesn't jump when a message appears */
#joinError {
  flex-basis: 100%;
  min-height: 1.4em;
  text-align: center;
  font-size: max(11px, 1.5cqw);
  color: #ffb199;
}

/* two selectors beat "#join button", so these stay small round dots */
#join .swatch {
  width: max(16px, 2.4cqw);
  height: max(16px, 2.4cqw);
  padding: 0;
  border-radius: 50%;
}

#join .swatch.active {
  border-color: white;
  transform: translateY(-2px);
}

/* --- SIGN-UP EXTRAS --- */
#signupNote,
#ageNote {
  flex: 1 1 100%;
  text-align: center;
  font-size: max(10px, 1.3cqw);
  opacity: 0.9;
}

#signupNote a {
  color: var(--highlight);
}

/* number box without the up/down arrows, they eat the little space it has */
#ageInput {
  appearance: textfield;
}

#ageInput::-webkit-inner-spin-button,
#ageInput::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

/* --- CHAT --- */

.chat-panel {
  position: absolute;
  bottom: var(--chat-input-h);
  /* sits right above the input */
  left: 0;
  width: 30%;
  height: 30%;
  padding: 8px;
  overflow-y: auto;
  scrollbar-width: none;
  font-size: max(10px, 1.8cqw);
  color: white;
  text-shadow: var(--text-shadow);
  background: rgba(109, 110, 30, 0.55);
  background-clip: padding-box;
  border: var(--chat-border);
  border-radius: 16px 16px 0 0;
  opacity: 0;
  /* hidden until shown */
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.chat-messages p {
  padding: 4px 10px;
  margin-bottom: 4px;
  line-height: 1.3;
  overflow-wrap: break-word;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 12px;
}

/* alternate shading */
.chat-messages p:nth-child(even) {
  background: rgba(255, 255, 255, 0.24);
}

.chat-input {
  display: none;
  /* shown when typing */
  position: absolute;
  bottom: 0;
  left: 0;
  width: 30%;
  height: var(--chat-input-h);
  padding: 0 10px;
  font-family: "jua", sans-serif;
  font-size: max(10px, 1.5cqw);
  outline: none;
  background: rgba(255, 255, 255, 0.9);
  background-clip: padding-box;
  border: var(--chat-border);
  border-radius: 0 0 16px 16px;
}

/* --- PROFILE --- */
/* all sizes are cqw (% of the game width) so the card scales with the game */

.profile {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* center in the wrapper */
  padding: 1.2cqw;
  font-family: inherit;
  text-align: center;
  color: white;
  background: var(--panel-bg);
  border: var(--chat-border);
  border-radius: 2.4cqw;
  box-shadow: var(--card-shadow);
}

/* images fill their parent's width (id rules further down override this) */
.profile img {
  display: block;
  width: 100%;
  margin: 0 auto;
  image-rendering: auto;
}

/* buttons in the card shrink too (max keeps them readable) */
.profile button {
  width: fit-content;
  padding: 0.3em 0.9em;
  font-size: max(11px, 1.6cqw);
}

/* top bar: coins/add (left) | username (middle) | close (right) */

.profile-top-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 1cqw;
}

.coin-section {
  display: flex;
  align-items: center;
  padding: 0.2cqw 1cqw 0.2cqw 0.5cqw;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 999px;
}

#coinImg {
  width: 2.4cqw;
  margin: 0 0.5cqw 0 0;
}

#profileCoins {
  font-size: max(12px, 1.6cqw);
}

/* every item gets a fixed cell, so a hidden item can't shift the others */
.coin-section,
#profileAddBtn {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  /* coins and + friend never show together, so they share the cell */
}

#profileUsername {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  padding: 0 1cqw;
  font-size: max(14px, 2cqw);
  font-weight: bold;
  text-shadow: var(--text-shadow);
}

#profileCloseBtn {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

/* body: duck (left) | inventory (right) */

.profile-body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 1cqw;
}

/* clothing layers are positioned relative to this, and their 100% width = this width */
#profileDuck {
  position: relative;
  width: 30cqw;
  overflow: hidden;
  background: var(--panel-inner-bg);
  border-radius: 1.6cqw;
}

/* sits exactly on top of the base duck */
.clothing-layer {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  /* cancels the auto margin from .profile img */
}

/* --- INVENTORY DRAWER --- */
/* hides behind the card's edge. the tab pulls it out and rides on its outer edge */

#inventoryPanel {
  --dir: 1;
  /* 1 = opens to the right, -1 = opens to the left */
  --tab-w: 4cqw;
  position: absolute;
  top: 4cqw;
  left: calc(100% + 3.5px);
  /* starts at the card's outer edge, the card's own border is the drawer's border */
  width: max-content;
  /* otherwise it shrinks to the sliver of room left of the card */
  padding-right: var(--tab-w);
  /* room for the tab, which is taken out of the row below */
  /* the window: cuts off the card side, leaves room for shadows everywhere else */
  clip-path: inset(-3cqw -3cqw -3cqw 0);
}

/* the part that moves. closed = pushed fully behind the card edge, so only the tab is left in the window */
#inventorySlide {
  position: relative;
  /* the tab is placed against this */
  transform: translateX(calc(-100% * var(--dir)));
  transition: transform 0.3s cubic-bezier(0.25, 0.9, 0.3, 1);
  /* eases out, no overshoot: overshooting opens a gap against the card */
}

#inventoryPanel.open #inventorySlide {
  transform: none;
}

#inventoryBody {
  padding: 1cqw;
  background: var(--panel-bg);
  border: var(--chat-border);
  border-left: none;
  /* the card's border is already there */
  border-radius: 0 1.6cqw 1.6cqw 0;
  /* card side stays square, it's coming out of the card */
  box-shadow: var(--card-shadow);
}

#inventoryBody h3 {
  margin-bottom: 0.6cqw;
  font-size: max(12px, 1.6cqw);
  text-shadow: var(--text-shadow);
}

/* the handle. it sits just outside the body (left: 100%), so when the body is pushed behind the card it ends up
   flush against the card. .profile in front beats ".profile button", and the resets undo the pill look */
.profile #inventoryTab {
  position: absolute;
  top: 1.5cqw;
  left: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tab-w);
  height: 9cqw;
  padding: 0;
  color: var(--text-brown);
  background: var(--duck-yellow);
  border: var(--chat-border);
  border-left: none;
  /* the side touching the card/drawer has no border, so it looks attached */
  border-radius: 0 1.4cqw 1.4cqw 0;
  box-shadow: none;
  transition: width 0.15s, background 0.15s;
}

.profile #inventoryTab svg {
  width: max(14px, 2.4cqw);
  height: max(14px, 2.4cqw);
}

.profile #inventoryTab:hover {
  background: var(--highlight);
  transform: none;
  box-shadow: none;
}

/* closed tab grows outward on hover, like your drag tab: the card side stays planted, so no gap */
.profile #inventoryPanel:not(.open) #inventoryTab:hover {
  width: calc(var(--tab-w) + 0.6cqw);
}

/* no room on the right? js adds .flip and everything mirrors */
#inventoryPanel.flip {
  --dir: -1;
  left: auto;
  right: calc(100% + 3.5px);
  padding-right: 0;
  padding-left: var(--tab-w);
  clip-path: inset(-3cqw 0 -3cqw -3cqw);
}

#inventoryPanel.flip #inventoryBody {
  border: var(--chat-border);
  border-right: none;
  border-radius: 1.6cqw 0 0 1.6cqw;
}

.profile #inventoryPanel.flip #inventoryTab {
  left: auto;
  right: 100%;
  border: var(--chat-border);
  border-right: none;
  border-radius: 1.4cqw 0 0 1.4cqw;
}

#inventory {
  display: grid;
  grid-template-columns: repeat(3, 6cqw);
  grid-auto-rows: 6cqw;
  gap: 0.6cqw;
}

/* every box, empty or not (id selector beats .profile img) */
#inventory .slot {
  width: 6cqw;
  height: 6cqw;
  margin: 0;
  padding: 0.5cqw;
  object-fit: contain;
  /* fit the whole item in the box, no stretching */
  background: rgba(0, 0, 0, 0.25);
  border: max(2px, 0.25cqw) solid var(--duck-orange);
  border-radius: 1.2cqw;
}

/* only boxes with an item in them are clickable */
#inventory img.slot {
  cursor: pointer;
}

#inventory img.slot:hover {
  transform: translateY(-2px);
  border-color: var(--highlight);
}

/* the item you're currently wearing */
#inventory img.slot.equipped {
  background: rgba(255, 210, 63, 0.3);
  border-color: var(--highlight);
}

#profileInfo {
  margin-top: 0.5cqw;
  font-size: max(11px, 1.4cqw);
}

/* --- SAFETY (block / report) --- */

:root {
  --danger: #e0674a;
  --danger-dark: #a8432c;
  --good: #6fcf5b;
  --good-dark: #3f8a30;
}

#profileSafety {
  margin-top: 1cqw;
  /* thin divider so it reads as a separate, quieter area of the card 

  padding-top: 0.8cqw;
  border-top: 2px solid rgba(255, 255, 255, 0.15);*/
}

.safety-row {
  display: flex;
  justify-content: center;
  gap: 1cqw;
}

/* smaller than the main card buttons so they don't shout */
#profileSafety button {
  padding: 0.2em 0.8em;
  font-size: max(10px, 1.3cqw);
}

#profileReportBtn {
  background: var(--danger);
  border-color: var(--danger-dark);
  box-shadow: 0 3px 0 var(--danger-dark);
  color: white;
}

#profileReportBtn:hover {
  box-shadow: 0 5px 0 var(--danger-dark);
}

#profileReportBtn:active {
  box-shadow: 0 1px 0 var(--danger-dark);
}

/* the picker pops open under the buttons */
#reportPicker {
  margin-top: 0.8cqw;
  padding: 0.8cqw;
  background: var(--panel-inner-bg);
  border-radius: 1.4cqw;
  animation: pop 0.15s ease-out;
}

#reportPicker p {
  margin-bottom: 0.6cqw;
  font-size: max(10px, 1.3cqw);
  opacity: 0.85;
}

.reason-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6cqw;
}

/* cancel looks like text, not another big button */
#profileSafety button.ghost {
  color: white;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  opacity: 0.7;
}

/* --- SOCIAL POLISH --- */

/* the open tab stays pressed in and highlighted */
.social-tabs button.active {
  background: var(--highlight);
  border-color: var(--duck-orange);
  box-shadow: 0 1px 0 var(--duck-orange-dark);
  transform: translateY(2px);
}

.social-row {
  transition: background 0.15s;
}

.social-row:hover {
  background: rgba(53, 53, 14, 0.85);
}

#socialList>p {
  padding: 1cqw;
  font-size: max(11px, 1.4cqw);
  opacity: 0.6;
  text-align: center;
}

/* accept is green, destructive actions are red */
.social button.act-friendAccept {
  background: var(--good);
  border-color: var(--good-dark);
  box-shadow: 0 3px 0 var(--good-dark);
}

.social button.act-friendRemove {
  background: var(--danger);
  border-color: var(--danger-dark);
  box-shadow: 0 3px 0 var(--danger-dark);
  color: white;
}

/* glowing dot for friends who are online */
.dot.on {
  box-shadow: 0 0 0.8cqw #5ddf5d;
}

/* --- SOCIAL PANEL --- */

#socialBtn {
  position: absolute;
  top: 1cqw;
  right: 1cqw;
  padding: 0.3em 0.9em;
  font-size: max(11px, 1.6cqw);
}

.social {
  position: absolute;
  top: 5cqw;
  right: 1cqw;
  width: 24cqw;
  padding: 1cqw;
  color: white;
  background: var(--panel-bg);
  border: var(--chat-border);
  border-radius: 2.4cqw;
  box-shadow: var(--card-shadow);
}

.social-tabs {
  display: flex;
  gap: 0.5cqw;
  margin-bottom: 0.8cqw;
}

.social button {
  padding: 0.2em 0.7em;
  font-size: max(10px, 1.3cqw);
  border-width: max(2px, 0.2cqw);
}

#socialCloseBtn {
  margin-left: auto;
}

#socialList {
  max-height: 24cqw;
  overflow-y: auto;
  scrollbar-width: none;
}

.social-row {
  display: flex;
  align-items: center;
  gap: 0.6cqw;
  padding: 0.4cqw 0.6cqw;
  margin-bottom: 0.4cqw;
  font-size: max(11px, 1.5cqw);
  background: var(--panel-inner-bg);
  border-radius: 1.2cqw;
}

.social-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  width: 1cqw;
  height: 1cqw;
  border-radius: 50%;
  background: #777;
}

.dot.on {
  background: #5ddf5d;
}

/* greyed-out buttons on the card ("request sent", "friends") */
.profile button:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

/* --- TOASTS --- */

#toasts {
  position: absolute;
  top: 1cqw;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6cqw;
  pointer-events: none;
  /* clicks pass through to the game */
}

.toast {
  padding: 0.3em 1em;
  font-size: max(11px, 1.6cqw);
  color: var(--text-brown);
  background: var(--highlight);
  border: var(--chat-border);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--duck-orange-dark);
  transition: opacity 0.4s;
  animation: pop 0.15s ease-out;
  /* reuses the report picker's keyframes */
}

.toast.out {
  opacity: 0;
}

/* --- PICKUP PROMPT --- */

.prompt {
  position: absolute;
  left: 50%;
  bottom: 6cqw;
  transform: translateX(-50%);
  z-index: 3;
  padding: 1cqw 1.6cqw;
  text-align: center;
  font-size: max(12px, 1.8cqw);
  color: white;
  text-shadow: var(--text-shadow);
  background: var(--panel-bg);
  border: var(--chat-border);
  border-radius: 2.4cqw;
  box-shadow: var(--card-shadow);
}

.prompt-row {
  display: flex;
  justify-content: center;
  gap: 1cqw;
  margin-top: 0.6cqw;
}

.prompt button {
  padding: 0.2em 0.9em;
  font-size: max(11px, 1.5cqw);
  border-width: max(2px, 0.2cqw);
}

/* yes is green, same as accept in the social panel */
#pickupYes {
  background: var(--good);
  border-color: var(--good-dark);
  box-shadow: 0 3px 0 var(--good-dark);
}

/* --- ROOM TAB + PORTRAITS --- */

/* five tabs can be wider than the panel */
.social-tabs {
  flex-wrap: wrap;
}

/* tiny head-and-outfit portrait: no background, zoomed on the head. tune scale/origin by eye */
.mini-duck {
  position: relative;
  flex: none;
  width: 3cqw;
  height: 3cqw;
  overflow: hidden;
  cursor: pointer;
}

.mini-duck img {
  display: block;
  width: 100%;
  transform: scale(1.8);
  transform-origin: 50% 25%;
  /* same on base and layers, so they stay lined up */
}

.social-name {
  cursor: pointer;
}

.social-name:hover {
  text-decoration: underline;
}

/* --- ICON TABS --- */

.social-tabs .tab-btn {
  position: relative;
  /* the badge sits on the corner */
  padding: 0.25em 0.5em;
}

/* png icon: fixed square so every tab is the same size. export at 64x64, shown at ~2cqw */
.tab-btn .ico {
  display: block;
  width: max(16px, 2.2cqw);
  height: max(16px, 2.2cqw);
  object-fit: contain;
}

.tab-btn .badge {
  position: absolute;
  top: -0.5cqw;
  right: -0.5cqw;
  min-width: 1.6cqw;
  padding: 0 0.3cqw;
  font-size: max(9px, 1.1cqw);
  line-height: 1.6cqw;
  text-align: center;
  color: white;
  background: var(--danger);
  border-radius: 999px;
}

/* grip tab: sticks out of the panel's top edge, dots say "grab me" */
.drag-tab {
  position: absolute;
  top: calc(-2.4cqw - 3.5px);
  /* sits above the panel, bottom edge covers the panel's border */
  left: 50%;
  width: 7cqw;
  height: calc(2.4cqw + 3.5px);
  background:
    radial-gradient(circle, var(--duck-orange-dark) 1.5px, transparent 2px) center / 8px 8px,
    var(--duck-yellow);
  border: var(--chat-border);
  border-bottom: none;
  border-radius: 1.2cqw 1.2cqw 0 0;
  transform: translateX(-50%);
  cursor: grab;
  touch-action: none;
  /* stops the page scrolling on phones */
  transition: top 0.15s, height 0.15s;
}

/* grows upward, the bottom edge stays on the panel so there's no gap */
.drag-tab:hover {
  top: calc(-2.8cqw - 3.5px);
  height: calc(2.8cqw + 3.5px);
}

.drag-tab:active {
  cursor: grabbing;
}

/* social button is just the icon now */
#socialBtn {
  padding: 0.25em 0.4em;
  line-height: 0;
  /* stops the img leaving a gap under itself */
  background: white;
}

#socialBtn img {
  display: block;
  width: max(22px, 2.6cqw);
  height: auto;
}

/* red request count, pinned to the button's top-right corner */
#socialBadge {
  position: absolute;
  /* the button is already positioned, so this is relative to it */
  top: -0.6cqw;
  right: -0.6cqw;
  min-width: max(16px, 1.8cqw);
  height: max(16px, 1.8cqw);
  padding: 0 0.4cqw;
  font-size: max(10px, 1.2cqw);
  line-height: max(16px, 1.8cqw);
  /* same as height, centres the number */
  text-align: center;
  color: white;
  background: var(--danger);
  border: 2px solid var(--danger-dark);
  border-radius: 999px;
}

/* --- CLOSE BUTTONS --- */

/* two classes beat .profile button / .social button, so these win */
.profile .close-btn,
.social .close-btn {
  padding: 0.25em;
  /* the button's size = icon + this padding */
  line-height: 0;
  /* stops the img leaving a gap under itself */
}

/* the icon sets the size, the button wraps around it */
.profile .close-btn img,
.social .close-btn img {
  display: block;
  width: max(14px, 1.7cqw);
  height: max(14px, 1.7cqw);
  margin: 0;
  object-fit: contain;
}

/* flex rows stretch children to the tallest one, so opt out */
.social .close-btn {
  align-self: center;
}

/* --- TOOLTIP --- */

#tip {
  position: absolute;
  z-index: 6;
  /* above toasts (5) and panels */
  padding: 0.25em 0.8em;
  font-size: max(10px, 1.4cqw);
  white-space: nowrap;
  color: var(--input-bg);
  background: var(--text-brown);
  border: max(2px, 0.2cqw) solid var(--duck-orange);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--duck-orange-dark);
  pointer-events: none;
  /* never steals the hover from what's under it */
  animation: pop 0.15s ease-out;
  /* reuses your keyframes */
}

/* --- TINT PICKER --- */
#tintPicker {
  display: grid;
  grid-template-columns: repeat(3, 6cqw);
  gap: 0.6cqw;
}

/* id selector beats ".profile button" so the swatch stays a small colour square */
#tintPicker .swatch {
  width: 6cqw;
  height: 3cqw;
  padding: 0;
  border-radius: 1.2cqw;
}

#tintPicker .swatch.active {
  border-color: white;
}

/* --- LOADING SCREEN --- */

#loading {
  position: absolute;
  inset: 0;
  z-index: 4;
  /* above the game, under toasts (5) */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1.5cqw;
  font-size: max(14px, 2.4cqw);
  color: var(--text-brown);
  background: var(--page-bg);
  border-radius: 14px;
  animation: fade-in 0.2s 0.15s both;
  /* 0.15s delay, so quick loads never show it */
}

.spinner {
  width: 5cqw;
  height: 5cqw;
  border: 0.8cqw solid var(--duck-orange);
  border-top-color: var(--highlight);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* --- FORGOT PASSWORD --- */

/* looks like text, own row under the buttons */
#join #forgotBtn {
  flex-basis: 100%;
  font-size: max(10px, 1.3cqw);
  color: white;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  transform: none;
  opacity: 0.8;
}

/* --- TOUCH / MOBILE --- */

body {
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  /* no long-press menu on images */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  /* no double-tap zoom */
}

/* safari can't type into an input that inherits user-select: none */
input {
  -webkit-user-select: text;
  user-select: text;
}

canvas {
  touch-action: none;
  /* a drag on the game must never scroll or zoom the page */
}

#actionBar {
  display: none;
  position: absolute;
  right: 1cqw;
  bottom: 1cqw;
  gap: 1cqw;
}

#actionBar button {
  padding: 0.3em 0.5em;
  font-size: max(22px, 3cqw);
  line-height: 1;
}

#rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  font-size: 1.8rem;
  text-align: center;
  color: var(--text-brown);
  background: var(--page-bg);
}

/* touch screens: show the buttons, and 16px inputs so iOS doesn't zoom in on focus */
@media (pointer: coarse) {
  #actionBar {
    display: flex;
  }

  .chat-input,
  #join input {
    font-size: 16px;
  }
}

/* portrait phone: ask for landscape */
@media (orientation: portrait) and (pointer: coarse) and (max-width: 700px) {
  #rotate {
    display: flex;
  }
}

/* landscape phone: the game gets the whole screen. dvh = height without the browser's url bar */
@media (pointer: coarse) and (max-height: 500px) {
  :root {
    --game-width: min(100vw, calc(100dvh * 16 / 9));
  }

  body {
    height: 100dvh;
  }

  .navbar {
    display: none;
  }

  /* the border would push the height past the screen */
  .wrapper {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  canvas {
    border-radius: 0;
  }
}