:root {
  /* black lacquer, gold leaf and temple vermilion: the palette of a lai rod nam cabinet */
  --night: #120c0a;
  --card: #1c130f;
  --card-solid: #1c130f;
  --glass: rgba(24, 15, 11, 0.86);
  --line: rgba(226, 182, 92, 0.42);
  --line-soft: rgba(226, 182, 92, 0.18);
  --gold: #e2b65c;
  --gold-deep: #b7832c;
  --ink: #2a1608;
  --red: #a3301d;
  --red-hi: #bd3d26;
  --text: #f6ead2;
  --muted: #c4ad8b;
  --pink: #e98aa0;
  --display: 'Chonburi', 'IBM Plex Sans Thai Looped', serif;
  --lift: 0 14px 30px -12px rgba(0, 0, 0, 0.75);
  --safe-t: max(10px, env(safe-area-inset-top));
  --safe-b: max(10px, env(safe-area-inset-bottom));
  --safe-l: max(10px, env(safe-area-inset-left));
  --safe-r: max(10px, env(safe-area-inset-right));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--night);
  color: var(--text);
  font-family: 'IBM Plex Sans Thai Looped', 'Leelawadee UI', 'Thonburi', sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  caret-color: var(--gold);
}

[hidden] { display: none !important; }
::selection { background: var(--gold); color: var(--ink); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
* { scrollbar-color: rgba(226, 182, 92, 0.35) transparent; }
.ic { width: 1em; height: 1em; display: block; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.ic .fill { fill: currentColor; stroke: none; }
.ic.inline { display: inline-block; vertical-align: -0.15em; }
button, input, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; border: 0; }
input, textarea { -webkit-user-select: text; user-select: text; }

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#labels { position: fixed; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.tag, .wish, .floaty { position: absolute; left: 0; top: 0; will-change: transform; }
.tag { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tag .name {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(18, 12, 10, 0.8);
  border: 1px solid var(--line-soft);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.tag.me .name { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.tag .bubble {
  max-width: 220px;
  padding: 6px 12px;
  border-radius: 12px;
  background: #fbf2df;
  color: var(--ink);
  font-size: 14px;
  text-align: center;
  overflow-wrap: anywhere;
}
.wish {
  max-width: 250px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(24, 15, 11, 0.88);
  border: 1px solid var(--line);
  color: #f0d293;
  font-size: 13px;
  text-align: center;
  overflow-wrap: anywhere;
  transition: opacity 0.6s;
}
.wish b { display: block; color: #fff; font-size: 13px; }
.wish i { display: block; font-style: normal; margin-top: 2px; }
.floaty { font-size: 30px; animation: floatUp 2s ease-out forwards; }
@keyframes floatUp {
  from { opacity: 1; margin-top: 0; }
  to { opacity: 0; margin-top: -110px; }
}

#loading {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(circle at 50% 42%, #2b1911, #0c0706 70%);
  padding: 24px; text-align: center; color: var(--muted);
}
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid rgba(226, 182, 92, 0.2); border-top-color: var(--gold);
  animation: spin 0.9s linear infinite; margin: 6px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- shared controls ---------- */
h1, h2 { font-family: var(--display); font-weight: 400; letter-spacing: 0.01em; text-wrap: balance; }
h1 { margin: 0; font-size: clamp(20px, 3.2vw, 27px); line-height: 1.3; color: var(--gold); }
h2 { margin: 0 0 14px; font-size: 21px; line-height: 1.35; color: var(--gold); }
/* a gold-leaf rule under every panel title: line, lozenge, line */
.card h2::after {
  content: ''; display: block; width: 132px; height: 10px; margin: 8px auto 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 132 10'%3E%3Cg fill='%23e2b65c'%3E%3Crect x='0' y='4.5' width='54' height='1' opacity='.55'/%3E%3Crect x='78' y='4.5' width='54' height='1' opacity='.55'/%3E%3Cpath d='M66 0l5 5-5 5-5-5z'/%3E%3Ccircle cx='58' cy='5' r='1.3'/%3E%3Ccircle cx='74' cy='5' r='1.3'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

input[type="text"], textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: rgba(246, 234, 210, 0.06);
  font-size: 16px;
  outline: none;
  resize: none;
  transition: border-color 0.15s, background-color 0.15s;
}
input[type="text"]:focus, textarea:focus { border-color: var(--gold); background: rgba(246, 234, 210, 0.09); }
::placeholder { color: rgba(246, 234, 210, 0.5); }

.primary, .secondary, .ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 22px; border-radius: 8px;
  font-size: 16px; font-weight: 700; text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.primary .ic, .secondary .ic { font-size: 19px; }
.primary {
  background: var(--red); color: #fbeacb; border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 2px var(--red), inset 0 0 0 3px rgba(226, 182, 92, 0.35), 0 8px 18px -8px rgba(0, 0, 0, 0.8);
}
.primary:hover { background: var(--red-hi); box-shadow: inset 0 0 0 2px var(--red-hi), inset 0 0 0 3px rgba(226, 182, 92, 0.45), 0 8px 18px -8px rgba(0, 0, 0, 0.8); }
.secondary { background: transparent; border: 1px solid var(--line); color: var(--gold); }
.secondary:hover { background: rgba(226, 182, 92, 0.1); border-color: var(--gold); }
.ghost { background: transparent; color: var(--muted); font-size: 15px; min-height: 40px; }
.ghost:hover { color: var(--text); }
.primary:active, .secondary:active, .round:active, .floatBtn:active { transform: scale(0.96); }

.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 6px;
  background: rgba(246, 234, 210, 0.05); border: 1px solid var(--line-soft);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--line); }
.chip .ic { font-size: 17px; }
.chip.on { background: var(--gold); border-color: var(--gold); color: var(--ink); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; justify-content: center; }
.note { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.note.big { font-size: 16px; color: var(--text); text-align: center; }
.warn { margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; font-size: 13px; background: rgba(226, 150, 60, 0.12); border: 1px solid rgba(226, 150, 60, 0.45); }
.field { display: block; margin-top: 14px; }
.field span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 14px; }
.banner { margin: 0 0 12px; padding: 10px 14px; border-radius: 8px; background: rgba(233, 138, 160, 0.12); border: 1px solid rgba(233, 138, 160, 0.5); text-align: center; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  background: rgba(10, 6, 4, 0.55);
  animation: dim 0.2s ease-out;
}
.overlay.clear { background: rgba(10, 6, 4, 0.2); }
#mapStep { align-items: flex-end; background: none; }
/* a lacquer panel framed by a double gold rule, like the edge of a scripture cabinet */
.card {
  width: min(680px, 100%); max-height: 100%; overflow-y: auto;
  padding: 22px 24px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: inset 0 0 0 5px var(--card), inset 0 0 0 6px var(--line-soft), 0 28px 60px -18px rgba(0, 0, 0, 0.85);
  text-align: center;
  animation: rise 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes dim { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .overlay, .card { animation: none; } }
.card.small { width: min(430px, 100%); }
.card .field, .card .note { text-align: left; }
.card .note.big { text-align: center; }

.maps { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.map {
  padding: 14px 10px; border-radius: 8px; text-align: center;
  background: rgba(246, 234, 210, 0.04); border: 1px solid var(--line-soft);
  transition: border-color 0.15s, background-color 0.15s;
}
.map:hover { border-color: var(--line); }
.map .emoji { font-size: 28px; display: block; }
.map b { display: block; font-family: var(--display); font-weight: 400; font-size: 17px; margin-top: 6px; }
.map small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.map.on { border-color: var(--gold); background: rgba(226, 182, 92, 0.12); box-shadow: inset 0 0 0 1px var(--gold); }
.map.on b { color: var(--gold); }

.pairRow {
  display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 12px 14px;
  border-radius: 8px; background: rgba(233, 138, 160, 0.12); border: 1px solid rgba(233, 138, 160, 0.5);
  text-align: left; font-size: 15px;
}
.pairRow input { width: 22px; height: 22px; accent-color: var(--pink); flex: 0 0 auto; }
.pairKrathong { width: 120px; height: 120px; display: block; margin: 0 auto; }
.photo { width: 100%; border-radius: 6px; display: block; border: 1px solid var(--line); }

/* ---------- wardrobe sheet ---------- */
.sheet {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: 57dvh;
  display: flex; flex-direction: column;
  background: var(--card); border-top: 1px solid var(--line);
  box-shadow: inset 0 5px 0 var(--card), inset 0 6px 0 var(--line-soft), 0 -20px 40px -20px rgba(0, 0, 0, 0.7);
  border-radius: 12px 12px 0 0;
  padding: 12px var(--safe-r) var(--safe-b) var(--safe-l);
}
.sheetHead { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; }
.sheetHead h1 { text-align: center; }
.nameRow { display: flex; gap: 8px; align-items: center; }
.strip { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; touch-action: pan-x; cursor: grab; }
.strip::-webkit-scrollbar { display: none; }
.rows { flex: 1 1 auto; overflow-y: auto; margin-top: 6px; padding-right: 2px; scrollbar-width: thin; }
.rowLabel { margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices.center { justify-content: center; }
.swatch {
  width: 38px; height: 38px; border-radius: 50%;
  border: 2px solid rgba(246, 234, 210, 0.22);
  display: grid; place-items: center; font-size: 14px; background: rgba(246, 234, 210, 0.05);
}
.thumb {
  padding: 0; width: 72px; border-radius: 8px; overflow: hidden;
  background: rgba(246, 234, 210, 0.05); border: 1px solid var(--line-soft);
  font-size: 11px; line-height: 1.2;
  transition: border-color 0.15s;
}
.thumb:hover { border-color: var(--line); }
.thumb canvas { display: block; width: 70px; height: 68px; }
.thumb.face canvas { height: 51px; }
.thumb span { display: block; padding: 3px 2px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swatch.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--gold); }
.thumb.on { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); background: rgba(226, 182, 92, 0.12); }
.thumb.on span { color: var(--gold); }
.sheetFoot { flex: 0 0 auto; display: flex; justify-content: center; padding-top: 8px; }
.sheetFoot .primary { width: min(360px, 100%); }

@media (min-aspect-ratio: 5/4) and (min-height: 560px) {
  /* roomy side panel: show every chip instead of a scrolling strip */
  .sheet .strip { flex-wrap: wrap; overflow-x: visible; }
}
@media (min-aspect-ratio: 5/4) {
  .sheet {
    left: auto; top: 0; bottom: 0; right: 0; height: auto; width: min(46vw, 520px);
    border-radius: 0; border-top: 0; border-left: 1px solid var(--line);
    box-shadow: inset 5px 0 0 var(--card), inset 6px 0 0 var(--line-soft), -20px 0 40px -20px rgba(0, 0, 0, 0.7);
    padding: var(--safe-t) var(--safe-r) var(--safe-b) 16px;
  }
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud button, #hud form, #hud .poseMenu, #hud .soundPanel { pointer-events: auto; }

.topLeft { position: absolute; top: var(--safe-t); left: var(--safe-l); max-width: min(330px, calc(100vw - 80px)); }
.topRight { position: absolute; top: var(--safe-t); right: var(--safe-r); display: flex; flex-direction: column; gap: 8px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 6px;
  background: var(--glass); border: 1px solid var(--line-soft);
  color: var(--text); font-size: 13px; font-weight: 600;
}
.badge .ic { font-size: 16px; color: var(--gold); }
.chatLog {
  margin-top: 8px; max-height: 26vh; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 3px;
  font-size: 13px; text-shadow: 0 1px 3px #000, 0 0 8px #000;
}
.chatLog b { color: var(--gold); font-weight: 600; }
.chatLog .sys { color: #e3d3b4; }

.round {
  width: 46px; height: 46px; border-radius: 10px;
  background: var(--glass); border: 1px solid var(--line);
  color: var(--gold); font-size: 22px;
  display: grid; place-items: center;
  box-shadow: var(--lift);
  transition: background-color 0.15s, border-color 0.15s;
}
.round:hover { border-color: var(--gold); background: rgba(40, 25, 17, 0.92); }
.topRight { align-items: flex-end; }
.soundPanel {
  width: min(250px, calc(100vw - 24px)); padding: 12px 14px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--line); font-size: 14px;
}
.soundPanel.closed { position: fixed; left: -9999px; top: 0; }
.soundPanel .note { font-size: 12px; margin-top: 8px; }
.gfxLabel { margin-top: 12px; }
.gfxRow { display: flex; flex-wrap: wrap; gap: 6px; }
.gfxRow .chip { padding: 6px 10px; font-size: 13px; }
.soundPanel label { display: block; margin-bottom: 8px; color: var(--muted); }
.volRow { display: flex; align-items: center; gap: 8px; }
.volRow input[type="range"] { flex: 1 1 auto; min-width: 0; height: 28px; accent-color: var(--gold); }
.volRow output { width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.actionsCol {
  position: absolute; right: var(--safe-r); bottom: calc(var(--safe-b) + 58px);
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}
/* the one big action: a vermilion seal ringed in gold leaf */
.floatBtn {
  width: 92px; height: 92px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-family: var(--display); font-size: 12.5px; color: #fbeacb;
  background: radial-gradient(circle at 50% 30%, var(--red-hi), #7e2213 78%);
  border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 4px rgba(126, 34, 19, 0.9), inset 0 0 0 5px rgba(226, 182, 92, 0.55), 0 14px 28px -10px rgba(0, 0, 0, 0.85);
  transition: transform 0.1s, filter 0.15s;
}
.floatBtn:hover { filter: brightness(1.08); }
.floatBtn span { font-size: 30px; line-height: 1; color: var(--gold); }
.poseMenu {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  padding: 10px; border-radius: 10px; width: 230px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--lift);
}
.poseMenu button {
  padding: 8px 4px; border-radius: 6px; background: rgba(246, 234, 210, 0.05); border: 1px solid transparent;
  font-size: 12px; line-height: 1.3;
}
.poseMenu button:hover { border-color: var(--line-soft); }
.poseMenu button span { display: block; font-size: 22px; }

.chatForm {
  position: absolute; left: var(--safe-l); bottom: var(--safe-b);
  display: flex; gap: 6px; width: min(420px, calc(100vw - var(--safe-l) - var(--safe-r)));
}
.chatForm input { background: var(--glass); min-height: 44px; }
.hint {
  position: absolute; left: 50%; bottom: calc(var(--safe-b) + 58px); transform: translateX(-50%);
  margin: 0; padding: 6px 14px; border-radius: 6px; background: var(--glass);
  font-size: 13px; color: var(--muted); white-space: nowrap; transition: opacity 1s;
}

.joy {
  position: fixed; z-index: 11; width: 120px; height: 120px; margin: -60px 0 0 -60px;
  border-radius: 50%; background: rgba(18, 12, 10, 0.35); border: 1px solid var(--line);
  pointer-events: none;
}
.joyKnob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: var(--gold); box-shadow: inset 0 0 0 4px rgba(42, 22, 8, 0.25);
}

.toast {
  position: fixed; left: 50%; top: 16%; transform: translateX(-50%); z-index: 40;
  max-width: 90vw; padding: 12px 20px; border-radius: 8px;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: inset 0 0 0 4px var(--card), inset 0 0 0 5px var(--line-soft), var(--lift);
  text-align: center; pointer-events: none;
}

/* short screens (phones in landscape) */
@media (max-height: 480px) {
  h1 { font-size: 18px; }
  .card { padding: 12px 16px; }
  .round { width: 40px; height: 40px; font-size: 18px; }
  .floatBtn { width: 74px; height: 74px; font-size: 11px; }
  .floatBtn span { font-size: 22px; }
  .actionsCol { flex-direction: row; align-items: flex-end; bottom: var(--safe-b); }
  .chatForm { width: min(300px, 38vw); }
  .chatLog { max-height: 22vh; }
  .hint { display: none; }
  .thumb { width: 62px; }
  .thumb canvas { width: 58px; height: 58px; }
  .maps { grid-template-columns: repeat(4, 1fr); }
  .map { padding: 8px 6px; }
  .map .emoji { font-size: 22px; }
}

@media (max-width: 520px) {
  .chatForm { width: calc(100vw - var(--safe-l) - var(--safe-r)); }
  .maps { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}

/* ---------- fairground: coins, stalls, shop, top-up, games ---------- */
.badge.coin { margin-left: 6px; color: #fff; border-color: var(--gold); }
#hud .badge.coin { pointer-events: auto; }
.genderRow { display: flex; gap: 8px; }
.genderRow .chip { flex: 1 1 0; text-align: center; font-size: 15px; padding: 9px 10px; }
.stallBtn {
  position: absolute; left: 50%; bottom: calc(var(--safe-b) + 64px); transform: translateX(-50%);
  padding: 12px 22px; border-radius: 8px; font-size: 16px; font-weight: 700; color: #fbeacb; white-space: nowrap;
  background: var(--red); border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 2px var(--red), inset 0 0 0 3px rgba(226, 182, 92, 0.4), 0 0 0 0 rgba(226, 182, 92, 0.5), var(--lift);
  animation: pulse 1.8s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}
@keyframes pulse { 70%, 100% { box-shadow: inset 0 0 0 2px var(--red), inset 0 0 0 3px rgba(226, 182, 92, 0.4), 0 0 0 10px rgba(226, 182, 92, 0), var(--lift); } }
@media (prefers-reduced-motion: reduce) { .stallBtn { animation: none; } }
.thumb { position: relative; }
.thumb.locked canvas { opacity: 0.55; }
.lockTag {
  position: absolute; left: 3px; top: 3px; padding: 1px 6px; border-radius: 4px;
  background: rgba(18, 12, 10, 0.88); border: 1px solid var(--gold); color: var(--gold);
  font-size: 10px; font-style: normal; font-weight: 700;
}
.balance { margin: 0 0 12px; color: var(--muted); }
.balance b { color: var(--gold); font-size: 18px; }
.shopGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
.shopItem {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 8px;
  border-radius: 8px; background: rgba(246, 234, 210, 0.04); border: 1px solid var(--line-soft);
}
.shopItem canvas { width: 92px; height: 92px; }
.shopItem .bigEmoji { font-size: 56px; line-height: 92px; height: 92px; }
.shopItem b { font-size: 14px; }
.shopItem small { color: var(--muted); }
.shopItem .primary, .shopItem .secondary { min-height: 38px; padding: 6px 16px; font-size: 14px; }
.shopItem .primary:disabled { opacity: 0.45; box-shadow: none; }
.ownedTag { color: #8fe0a8; font-weight: 700; font-size: 14px; min-height: 38px; display: grid; place-items: center; }
.payQr { display: block; width: min(220px, 60vw); margin: 12px auto 4px; border-radius: 12px; background: #fff; }
.payBox {
  display: flex; flex-direction: column; gap: 2px; margin-top: 10px; padding: 12px;
  border-radius: 8px; background: rgba(246, 234, 210, 0.05); border: 1px solid var(--line);
}
.payBox b { font-size: 22px; letter-spacing: 1px; color: var(--gold); -webkit-user-select: text; user-select: text; }
.slipBtn { margin-top: 14px; cursor: pointer; }
.note.good { color: #8fe0a8; }
.note.bad { color: #ff9a9a; }
.keyDetails { margin-top: 14px; text-align: left; font-size: 14px; color: var(--muted); }
.keyDetails summary { cursor: pointer; }
.restoreRow { margin-top: 10px; }
.gameCard { width: min(700px, 100%); }
.gameCanvas { display: block; width: 100%; max-height: 62dvh; aspect-ratio: 4 / 3; object-fit: contain; border-radius: 6px; border: 1px solid var(--line-soft); touch-action: none; cursor: crosshair; background: #1a100c; }
@media (max-height: 480px) {
  .gameCanvas { max-height: 56dvh; width: auto; margin: 0 auto; }
  .stallBtn { bottom: calc(var(--safe-b) + 54px); padding: 9px 16px; font-size: 14px; }
}

/* narrow phones: keep the movement hint clear of the float button */
@media (max-width: 520px) {
  .hint { left: var(--safe-l); right: 120px; transform: none; white-space: normal; text-align: center; border-radius: 14px; font-size: 12px; }
  .stallBtn { bottom: calc(var(--safe-b) + 118px); font-size: 14px; padding: 10px 16px; }
}

/* The page itself never zooms or rubber-bands on phones; only lists scroll. */
html, body { touch-action: none; position: fixed; inset: 0; width: 100%; }
button, a, label, input, textarea { touch-action: manipulation; }
.rows, .card, .chatLog { touch-action: pan-y; }
.strip { touch-action: pan-x; }

/* Sound and settings panels float at a fixed spot beside the button column on every screen size. */
.soundPanel {
  position: fixed; z-index: 12; top: var(--safe-t); right: calc(var(--safe-r) + 58px);
  max-height: calc(100dvh - var(--safe-t) - var(--safe-b)); overflow-y: auto;
}
.soundPanel.closed { display: none; }
.fsBtn { width: 100%; margin-top: 10px; min-height: 42px; font-size: 15px; }

/* Small or short screens: the top-right buttons form two columns so they never reach the action buttons. */
@media (max-height: 720px) {
  .topRight { display: grid; grid-template-columns: repeat(2, auto); gap: 8px; }
  .soundPanel { right: calc(var(--safe-r) + 108px); }
}
@media (max-height: 720px) and (max-width: 520px) {
  .soundPanel { right: var(--safe-r); top: calc(var(--safe-t) + 168px); }
}

/* The page never resizes its own text (phones in landscape otherwise inflate it, which reads as zooming). */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Every icon button carries a caption so nobody has to guess what it does. */
.round[data-label] { width: 56px; height: 54px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 21px; line-height: 1; }
.round[data-label]::after { content: attr(data-label); font-size: 10.5px; font-weight: 600; color: var(--text); white-space: nowrap; }
.soundPanel { right: calc(var(--safe-r) + 66px); }
.actionsCol { bottom: calc(var(--safe-b) + 58px); }
.tips { list-style: none; margin: 0; padding: 0; text-align: left; display: flex; flex-direction: column; gap: 10px; }
.tips li { display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; border-radius: 8px; background: rgba(246, 234, 210, 0.04); border: 1px solid var(--line-soft); }
.tips li > span { font-size: 24px; line-height: 1; color: var(--gold); padding-top: 2px; }
.tips b { color: var(--gold); }
.tips p { margin: 2px 0 0; font-size: 14px; color: var(--text); }
.sheetTip { flex: 0 0 auto; margin: 6px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
@media (max-height: 720px) {
  .round[data-label] { width: 50px; height: 46px; font-size: 17px; border-radius: 14px; }
  .round[data-label]::after { font-size: 9.5px; }
  .soundPanel { right: calc(var(--safe-r) + 116px); }
}
@media (max-height: 720px) and (max-width: 520px) {
  .soundPanel { right: var(--safe-r); top: calc(var(--safe-t) + 212px); }
}

/* Double-tap must never zoom the page. iOS Safari only understands "manipulation"
   (it ignores "none" and "pan-y"), so that value goes on everything; the 3D canvas
   keeps "none" for browsers that support it. */
*, *::before, *::after { touch-action: manipulation; }
#game, .gameCanvas { touch-action: none; }

/* ---------- layout lives inside the visible viewport ----------
   --app-h / --app-top are kept up to date from window.visualViewport. The transform makes
   <body> the containing block for every fixed-position layer, so nothing can end up under
   a phone browser's toolbars or the on-screen keyboard. */
html, body { inset: auto; }
body {
  position: fixed; left: 0; top: var(--app-top, 0px); width: 100%; height: var(--app-h, 100%);
  transform: translateZ(0);
}

/* ---------- one menu instead of a column of icons ---------- */
.topRight { display: block; }
.menuGrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.menuItem {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 76px; padding: 10px 4px 8px; border-radius: 8px; gap: 8px;
  background: rgba(246, 234, 210, 0.04); border: 1px solid var(--line-soft);
  font-size: 13px; font-weight: 600;
  transition: border-color 0.15s, background-color 0.15s;
}
.menuItem:hover { border-color: var(--line); background: rgba(226, 182, 92, 0.08); }
.menuItem span { font-size: 24px; line-height: 1; color: var(--gold); }
.menuItem em { font-style: normal; }
.menuSection { margin-top: 14px; text-align: left; }
.menuSection label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.actionsCol { flex-direction: row; align-items: flex-end; bottom: var(--safe-b); gap: 8px; }
.actionsCol .poseMenu { position: absolute; right: 0; bottom: calc(100% + 8px); }
.chatForm { width: min(360px, calc(100% - var(--safe-l) - var(--safe-r) - 290px)); min-width: 150px; }
.stallBtn { bottom: calc(var(--safe-b) + 106px); }

/* narrow phones held upright: chat gets its own row under the action buttons */
@media (max-width: 560px) {
  .actionsCol { bottom: calc(var(--safe-b) + 56px); }
  .chatForm { width: calc(100% - var(--safe-l) - var(--safe-r)); }
  .stallBtn { bottom: calc(var(--safe-b) + 164px); }
}

/* very short screens: a phone on its side with the browser's bars showing */
@media (max-height: 340px) {
  .round[data-label] { width: 46px; height: 40px; font-size: 15px; border-radius: 12px; }
  .round[data-label]::after { font-size: 9px; }
  .floatBtn { width: 62px; height: 62px; font-size: 10px; box-shadow: 0 0 0 3px rgba(255, 210, 122, 0.22); }
  .floatBtn span { font-size: 19px; }
  .badge { font-size: 11px; padding: 4px 9px; }
  .chatLog { max-height: 34px; font-size: 11px; margin-top: 4px; }
  .chatForm input { min-height: 36px; padding: 6px 10px; font-size: 16px; }
  .chatForm .chip { padding: 6px 10px; }
  .stallBtn { bottom: calc(var(--safe-b) + 72px); padding: 7px 14px; font-size: 13px; }
  .card { padding: 10px 14px; border-radius: 16px; }
  .card h2 { font-size: 17px; margin-bottom: 6px; }
  .menuItem { min-height: 54px; font-size: 12px; }
  .menuItem span { font-size: 20px; }
  .menuGrid { grid-template-columns: repeat(6, 1fr); }
  .tips li { padding: 6px 10px; }
  .tips p { font-size: 12px; }
}

/* Wardrobe sheet: the whole sheet scrolls, with the category tabs and the main button pinned.
   (Previously only the option list scrolled, so on a short screen the heading used up all the
   height and the button to continue was pushed off the bottom.) */
.sheet { display: block; overflow-y: auto; overscroll-behavior: contain; }
.sheet .rows { overflow: visible; margin-top: 0; }
.sheet #tabs { position: sticky; top: -1px; z-index: 2; background: var(--card-solid); padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.sheetFoot { position: sticky; bottom: 0; z-index: 2; background: var(--card-solid); padding: 10px 0 4px; border-top: 1px solid var(--line-soft); }
@media (max-height: 520px) {
  .sheet { padding-top: 8px; }
  .sheet h1, .sheetTip, .sheet .byBrand { display: none; }
  .sheet .strip { flex-wrap: nowrap; overflow-x: auto; }
  .sheet .chip { padding: 6px 12px; }
  .sheetFoot .primary { min-height: 40px; }
}

/* Pose menu: anchored inside the screen at every size (it used to open above the buttons and
   could run off the top of a short screen). */
.actionsCol .poseMenu {
  position: fixed; right: var(--safe-r); bottom: calc(var(--safe-b) + 76px);
  max-height: calc(var(--app-h, 100vh) - var(--safe-b) - 90px); overflow-y: auto;
}
@media (max-width: 560px) { .actionsCol .poseMenu { bottom: calc(var(--safe-b) + 132px); max-height: calc(var(--app-h, 100vh) - var(--safe-b) - 146px); } }
#hud .badge.coin { min-height: 34px; padding-top: 6px; padding-bottom: 6px; }

@media (max-height: 480px) {
  /* carnival games on a phone held sideways: the play area gets the full height, text sits beside it */
  .gameCard { display: grid; grid-template-columns: auto minmax(120px, 1fr); column-gap: 14px; align-items: center; width: auto; max-width: 100%; }
  .gameCard .gameCanvas { grid-column: 1; grid-row: 1 / span 3; height: calc(var(--app-h, 100vh) - 44px); width: auto; max-height: none; margin: 0; }
  .gameCard h2, .gameCard .note, .gameCard .actions { grid-column: 2; margin: 0; }
  .gameCard .note.big { font-size: 13px; text-align: left; }
}
@media (max-height: 340px) {
  .actionsCol .poseMenu { grid-template-columns: repeat(6, 1fr); width: min(440px, calc(100% - 2 * var(--safe-r))); bottom: calc(var(--safe-b) + 68px); padding: 6px; gap: 4px; }
  .poseMenu button { padding: 4px 2px; font-size: 10px; }
  .poseMenu button span { font-size: 18px; }
}

/* ---------- lacquer theme: leftovers from the old gold-glow look ---------- */
.badge.coin { color: var(--text); border-color: var(--line); }
.badge.coin .plus { margin-left: 2px; padding: 1px 7px; border-radius: 4px; background: var(--gold); color: var(--ink); font-size: 11px; font-weight: 700; }
.badge.coin:hover { border-color: var(--gold); }
.shopItem .primary:disabled { opacity: 0.4; }
.ownedTag { color: #9fd6a8; }
.payQr { border: 6px solid #fff; box-shadow: 0 0 0 1px var(--line); }
@media (max-height: 340px) {
  .floatBtn { box-shadow: inset 0 0 0 3px rgba(126, 34, 19, 0.9), inset 0 0 0 4px rgba(226, 182, 92, 0.55), var(--lift); }
  .floatBtn span { font-size: 20px; }
  .card { border-radius: 8px; }
  .card h2::after { margin-top: 4px; height: 7px; }
}
.shopItem .bigEmoji { display: grid; place-items: center; width: 92px; color: var(--gold); font-size: 54px; }
.map .emoji { color: var(--gold); display: flex; justify-content: center; }
.map.on .emoji { color: var(--gold); }

/* ---------- phones ---------- */
@media (pointer: coarse) {
  /* every tap target reaches ~44px; hover tints never stick after a tap */
  .chip { min-height: 42px; }
  .chatForm .chip { min-height: 44px; }
  .ghost { min-height: 44px; }
  .chip:hover, .map:hover, .thumb:hover, .menuItem:hover, .round:hover, .poseMenu button:hover { border-color: inherit; }
  .chip:hover { border-color: var(--line-soft); }
  .chip.on:hover { border-color: var(--gold); }
  .map:hover, .thumb:hover, .menuItem:hover { border-color: var(--line-soft); }
  .map.on:hover, .thumb.on:hover { border-color: var(--gold); }
  .round:hover { border-color: var(--line); background: var(--glass); }
  .primary:hover { background: var(--red); }
  .floatBtn:hover { filter: none; }
}

/* toast sizes to its text instead of shrinking to half the screen */
.toast { width: max-content; max-width: min(88vw, 440px); }
/* scrolling chip rows fade out at the edge so it is obvious there is more to swipe */
.strip { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); padding-right: 24px; }
@media (min-aspect-ratio: 5/4) and (min-height: 560px) { .sheet .strip { -webkit-mask-image: none; mask-image: none; padding-right: 0; } }
.card, .sheet, .rows { scrollbar-width: thin; }
@media (pointer: coarse) { .card, .sheet, .rows { scrollbar-width: none; } .card::-webkit-scrollbar, .sheet::-webkit-scrollbar { display: none; } }
/* narrow phones: dialog buttons stack full width, main action first */
@media (max-width: 520px) {
  .card { padding: 18px 16px; }
  .card .actions { flex-direction: column; align-items: stretch; gap: 8px; }
  .card .actions .primary, .card .actions .secondary { width: 100%; }
  .card .actions .ghost { align-self: center; }
}

/* ---------- settings screen ---------- */
.secondary.wide { width: 100%; margin-top: 14px; }
.settingsCard { width: min(560px, 100%); text-align: left; display: flex; flex-direction: column; }
.settingsCard h2 { text-align: center; }
.tabBar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 10px; background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line-soft); margin-bottom: 6px; }
.tabBtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px;
  border-radius: 7px; background: transparent; color: var(--muted); font-size: 15px; font-weight: 700;
  transition: background-color 0.15s, color 0.15s;
}
.tabBtn .ic { font-size: 18px; }
.tabBtn:hover { color: var(--text); }
.tabBtn.on { background: var(--gold); color: var(--ink); }
.setPane { display: flex; flex-direction: column; }
.setPane[hidden] { display: none; }
.setRow {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 2px; border-bottom: 1px solid var(--line-soft); cursor: default;
}
label.setRow { cursor: pointer; }
.setRow:last-child { border-bottom: 0; }
.setRow[hidden] { display: none; }
.setText { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 200px; cursor: inherit; }
.setText b { font-size: 15px; font-weight: 700; color: var(--text); }
.setText small { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.setRow .volRow { flex: 1 1 220px; max-width: 280px; }
.setRow output { color: var(--gold); font-weight: 700; width: 44px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 8px; background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line-soft); }
.seg .chip { border-color: transparent; background: transparent; padding: 7px 12px; min-height: 36px; }
.seg .chip.on { background: var(--gold); color: var(--ink); }
input[type="range"] { accent-color: var(--gold); }
input[type="range"]:disabled { opacity: 0.4; }

/* toggle switch drawn on a plain checkbox, so labels, keyboard and screen readers keep working */
.switch {
  -webkit-appearance: none; appearance: none; flex: 0 0 auto; margin: 0;
  width: 50px; height: 28px; border-radius: 999px; position: relative; cursor: pointer;
  background: rgba(246, 234, 210, 0.12); border: 1px solid var(--line-soft);
  transition: background-color 0.18s, border-color 0.18s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.18s;
}
.switch:checked { background: var(--red); border-color: var(--gold); }
.switch:checked::after { transform: translateX(22px); background: var(--gold); }
.settingsFoot { justify-content: space-between; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
@media (max-width: 520px) {
  .setRow .volRow, .seg { flex: 1 1 100%; max-width: none; }
  .seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); }
  .settingsFoot { flex-direction: row !important; }
  .settingsFoot .primary { width: auto !important; flex: 1 1 auto; }
}
@media (max-height: 480px) { .setRow { padding: 9px 2px; } .setText small { display: none; } }

/* ---------- FPS counter ---------- */
.fpsMeter {
  position: fixed; z-index: 15; top: var(--safe-t); left: 50%; transform: translateX(-50%);
  padding: 4px 10px; border-radius: 6px; pointer-events: none;
  background: rgba(12, 8, 6, 0.78); border: 1px solid var(--line-soft);
  font: 700 12px/1.2 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-variant-numeric: tabular-nums;
  color: #9fd6a8; letter-spacing: 0.02em;
}
.fpsMeter[data-level="ok"] { color: var(--gold); }
.fpsMeter[data-level="bad"] { color: #ff8a7a; }

/* ---------- mouse captured ---------- */
#labels.hideNames .tag .name { display: none; }
#labels.hideWishes .wish { display: none; }
.lockHint {
  position: absolute; left: 50%; bottom: calc(var(--safe-b) + 8px); transform: translateX(-50%);
  margin: 0; padding: 6px 12px; border-radius: 8px; white-space: nowrap;
  background: rgba(12, 8, 6, 0.7); border: 1px solid var(--line-soft); color: var(--muted); font-size: 12px;
}
.lockHint kbd {
  display: inline-block; margin: 0 3px 0 8px; padding: 1px 6px; border-radius: 4px;
  font: 700 11px/1.4 ui-monospace, Menlo, Consolas, monospace; color: var(--text);
  background: rgba(246, 234, 210, 0.1); border: 1px solid var(--line-soft); border-bottom-width: 2px;
}
.lockHint kbd:first-child { margin-left: 0; }
body.mouseLocked .chatForm, body.mouseLocked .actionsCol, body.mouseLocked .topRight { opacity: 0.55; }
body.mouseLocked .stallBtn { bottom: calc(var(--safe-b) + 52px); }
@media (max-width: 560px) {
  /* narrow screens: the room badge owns the top edge, so the counter sits under the menu button */
  .fpsMeter { left: auto; right: var(--safe-r); transform: none; top: calc(var(--safe-t) + 62px); }
}
@media (max-width: 900px) { .lockHint { display: none; } }

/* price badges on locked items: coin + number, kept small so the thumbnail stays visible */
.lockTag { display: inline-flex; align-items: center; gap: 2px; padding: 1px 5px 1px 3px; font-variant-numeric: tabular-nums; }
.lockTag .ic { font-size: 11px; }
/* the "tap to enter" prompt hides while any window is open over the game */
body:has(.overlay:not([hidden])) .stallBtn { display: none; }
#payQrNote { text-align: center; margin-top: 4px; }
@media (max-width: 380px) {
  /* very narrow phones (iPhone SE): tab labels stay on one line, choice rows stay in neat columns */
  .tabBtn .ic { display: none; }
  .tabBtn { font-size: 14px; white-space: nowrap; }
}
@media (max-width: 520px) {
  #gfxRow { grid-template-columns: repeat(4, 1fr); }
  #artRow { grid-template-columns: repeat(2, 1fr); }
  #gfxRow .chip, #artRow .chip { padding: 7px 4px; }
}
@media (max-height: 480px) {
  /* phones on their side: dialogs fit without scrolling to reach their buttons */
  .menuGrid { grid-template-columns: repeat(6, 1fr); }
  .menuItem { min-height: 60px; gap: 5px; font-size: 12px; }
  .menuItem span { font-size: 20px; }
  .secondary.wide { margin-top: 8px; min-height: 40px; }
  .card h2 { margin-bottom: 8px; }
  .card h2::after { display: none; }
  .card .actions { margin-top: 8px; }
  .card textarea { height: 46px; }
  .card .field { margin-top: 8px; }
  #pairHint { display: none; }
  #floatDlg .thumb { width: 54px; }
  #floatDlg .thumb canvas { width: 52px; height: 46px; }
}
/* a switch always stays on the right of its label, even on the narrowest phones */
label.setRow { flex-wrap: nowrap; }
label.setRow .setText { flex: 1 1 auto; }

/* ---------- festival actions: fireworks, lanterns and the krathong are the stars of the HUD ---------- */
@property --cd { syntax: '<number>'; inherits: false; initial-value: 0; }
.festBtn {
  position: relative; flex: 0 0 auto; width: 66px; height: 66px; border-radius: 50%; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-family: var(--display); font-size: 11px; line-height: 1; color: #fbeacb;
  border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.32), inset 0 0 0 4px rgba(226, 182, 92, 0.5), 0 12px 24px -10px rgba(0, 0, 0, 0.85);
  transition: transform 0.1s, filter 0.15s;
}
.festBtn .ic { font-size: 26px; color: var(--gold); }
.festBtn span { white-space: nowrap; }
.festBtn.fw { background: radial-gradient(circle at 50% 28%, #57449a, #1d153d 78%); }
.festBtn.lantern { background: radial-gradient(circle at 50% 28%, #dc8a32, #74350f 78%); }
.festBtn.lantern .ic { color: #fff0c9; }
.festBtn:hover { filter: brightness(1.12); }
.festBtn:active { transform: scale(0.94); }
/* after use, a shade sweeps away round the dial until the button is ready again */
.festBtn::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: conic-gradient(rgba(12, 7, 5, 0.66) calc(var(--cd) * 360deg), transparent 0);
}
.festBtn.cooling::before { animation: festCool var(--cd-time, 1.2s) linear forwards; }
@keyframes festCool { from { --cd: 1; } to { --cd: 0; } }
/* the krathong seal breathes a gold halo so a first-timer finds it */
.floatBtn { position: relative; }
.floatBtn::after {
  content: ''; position: absolute; inset: -5px; border-radius: 50%; pointer-events: none;
  border: 2px solid rgba(226, 182, 92, 0.55); animation: floatHalo 2.6s ease-in-out infinite;
}
@keyframes floatHalo { 0%, 100% { opacity: 0; transform: scale(0.96); } 50% { opacity: 1; transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) { .floatBtn::after { animation: none; opacity: 0.6; } }
.chatForm { width: min(360px, calc(100% - var(--safe-l) - var(--safe-r) - 318px)); }
@media (max-width: 560px) {
  .festBtn { width: 58px; height: 58px; font-size: 10px; }
  .festBtn .ic { font-size: 22px; }
  .floatBtn { width: 84px; height: 84px; }
  .chatForm { width: calc(100% - var(--safe-l) - var(--safe-r)); }
}
@media (max-height: 480px) {
  .festBtn { width: 56px; height: 56px; font-size: 9.5px; gap: 2px; }
  .festBtn .ic { font-size: 21px; }
}
@media (max-height: 340px) {
  .festBtn { width: 50px; height: 50px; font-size: 9px; }
  .festBtn .ic { font-size: 18px; }
  .floatBtn::after { inset: -3px; }
}

/* shown only when JavaScript is off */
.noJs { max-width: 560px; margin: 15vh auto 0; padding: 0 16px; text-align: center; color: var(--text); }
.noJs h1 { font-family: var(--display); color: var(--gold); }

/* ---------- tuck the dressing-room panel away ---------- */
.sheet { transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
.sheetToggle {
  position: fixed; z-index: 21; display: grid; place-items: center;
  background: var(--card-solid, var(--card)); color: var(--gold); border: 1px solid var(--line);
  box-shadow: var(--lift); transition: right 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), bottom 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.2s;
}
.sheetToggle[hidden] { display: none; }
.sheetToggle:hover { border-color: var(--gold); }
.sheetToggle .ic { font-size: 20px; transition: transform 0.32s; }
/* phones: a tab on top of the bottom sheet; the sheet slides down */
.sheetToggle { left: 50%; bottom: calc(57dvh - 1px); width: 64px; height: 26px; transform: translateX(-50%); border-radius: 10px 10px 0 0; border-bottom: 0; }
.sheetToggle .ic { transform: rotate(90deg); }
body.sheetHidden .sheet { transform: translateY(100%); }
body.sheetHidden .sheetToggle { bottom: var(--safe-b, 0px); border-radius: 10px 10px 0 0; }
body.sheetHidden .sheetToggle .ic { transform: rotate(-90deg); }
/* wide screens: a tab on the panel's left edge; the panel slides right */
@media (min-aspect-ratio: 5/4) {
  .sheetToggle { left: auto; top: 50%; bottom: auto; right: calc(min(46vw, 520px) - 1px); width: 28px; height: 68px; transform: translateY(-50%); border-radius: 10px 0 0 10px; border-bottom: 1px solid var(--line); border-right: 0; }
  .sheetToggle .ic { transform: none; }
  body.sheetHidden .sheet { transform: translateX(100%); }
  body.sheetHidden .sheetToggle { right: var(--safe-r, 0px); bottom: auto; }
  body.sheetHidden .sheetToggle .ic { transform: rotate(180deg); }
}
@media (prefers-reduced-motion: reduce) { .sheet, .sheetToggle, .sheetToggle .ic { transition: none; } }

/* ---------- bytesms credit ---------- */
.byBrand { display: inline-flex; align-items: center; gap: 6px; align-self: center; margin: -2px auto 2px; padding: 3px 10px 3px 4px; border-radius: 999px; border: 1px solid var(--line-soft); color: var(--muted); font-size: 12px; text-decoration: none; background: rgba(246, 234, 210, 0.03); }
.byBrand img { width: 18px; height: 18px; border-radius: 5px; }
.byBrand:hover { color: var(--text); border-color: var(--line); }
#loading .byBrand { position: absolute; bottom: calc(var(--safe-b, 0px) + 18px); left: 50%; transform: translateX(-50%); margin: 0; }
.menuBrand { display: flex; width: max-content; margin: 12px auto 0; }
@media (max-height: 480px) { .menuBrand { display: none; } }

/* ---------- Google sign-in on the top-up window ---------- */
.googleBox { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 6px 0 12px; padding: 12px; border: 1px solid var(--line-soft); border-radius: 8px; background: rgba(246, 234, 210, 0.03); }
.googleBox .note { margin: 0; text-align: center; }
.googleBtn { min-height: 44px; display: flex; justify-content: center; }
.googleBtn[hidden] { display: none; }
.ghost.small { min-height: 32px; font-size: 13px; }
.privacyLink { display: block; margin: 6px auto 0; width: max-content; font-size: 12px; color: var(--muted); }
@media (max-height: 480px) { .privacyLink { display: none; } }
