/* The app's look for the web (see shell.js): Poppins, the background picture, glass panels and buttons, on a
   390 point column scaled to the screen. */
@font-face { font-family: "Poppins"; src: url("../fonts/Poppins-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("../fonts/Poppins-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("../fonts/Poppins-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("../fonts/Poppins-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face {
  font-family: "Cairo";
  src: url("../fonts/Cairo-Arabic.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F;
}

html:has(> body.app) {
  height: 100%;
  overflow: hidden;
  background: #1f0c3f;
}

body.app {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1f0c3f url("bg/app.jpg") center / cover no-repeat fixed;
  color: #f8f7fa;
  font-family: "Poppins", "Cairo", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

body.app * {
  box-sizing: border-box;
}

.app-stage {
  position: fixed;
  top: 0;
  width: 390px;
  transform-origin: 0 0;
}

.app-stage > *,
.app-stage * {
  position: absolute;
}

.app-stage .flow,
.app-stage .flow *,
.app-stage .scroll > * {
  position: relative;
}

/* Text: one line unless it wraps; centred vertically like Godot labels. */
.t {
  display: flex;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.25;
  pointer-events: none;
}

.t > span {
  position: static !important;
  max-width: 100%;
  overflow: hidden;
  text-overflow: clip;
}

.t.wrap {
  white-space: pre-line;
}

.i {
  pointer-events: none;
}

.p,
.g {
  pointer-events: none;
}

.g {
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.g.floating {
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.tbar {
  border-radius: 0 0 16px 16px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-top: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.09) 60%, rgba(255, 255, 255, 0.07) 100%);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.16), inset 0 1px 12px rgba(255, 255, 255, 0.08);
}

/* Buttons answer taps even inside panels, which let taps through. */
.app-stage .b,
.app-stage .fb,
.app-stage .in {
  pointer-events: auto;
}

/* Buttons. */
.b {
  cursor: pointer;
  transition: transform 70ms ease;
}

.b:active,
.fb:active {
  transform: scale(0.96);
}

.fb {
  display: flex;
  align-items: center;
  justify-content: center;
  /* Sized by the design, not by the game pages' 50 point minimum for buttons (style.css). */
  min-height: 0;
  padding: 0;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: transform 70ms ease, filter 70ms ease;
}

.fb:active {
  filter: brightness(0.85);
}

.fb:disabled {
  opacity: 0.45;
  cursor: default;
}

.in {
  padding: 0 14px;
  border-radius: 15.5px;
  border: 1px solid #a09aae;
  background: #f1eff5;
  color: #1d1924;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

.in::placeholder {
  color: rgba(29, 25, 36, 0.5);
}

.in.dark {
  border-radius: 11.5px;
  border-color: #625c70;
  background: #302b3a;
  color: #f8f7fa;
}

.in.dark::placeholder {
  color: #a09aae;
}

/* Avatar ring and XP bar. */
.ring .ring-img {
  left: 4px;
  top: 4px;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  border-radius: 50%;
  object-fit: cover;
}

.ring .ring-svg {
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.pb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.3);
  overflow: hidden;
}

.pb .pb-fill {
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: #f5a900;
  min-width: 10px;
}

/* Scrolling lists inside a page. */
.scroll {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.scroll::-webkit-scrollbar {
  display: none;
}

/* Pop-ups. */
.ov {
  position: fixed;
  inset: 0;
  z-index: 200;
  opacity: 0;
  transition: opacity 120ms ease;
}

.ov.shown {
  opacity: 1;
}

.toast-app {
  position: fixed;
  left: 50%;
  bottom: max(84px, calc(env(safe-area-inset-bottom) + 84px));
  width: min(330px, 86vw);
  min-height: 44px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(15, 13, 19, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 250ms ease;
}

.toast-app .t {
  position: static;
  white-space: normal;
}

.toast-app.gone {
  opacity: 0;
}

/* Game Rules. */
.page-shade {
  position: fixed;
  z-index: 150;
  inset: 0;
  background: #1f0c3f url("bg/app.jpg") center / cover no-repeat;
}

.rules h3 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 600;
  color: #f8f7fa;
}

.rules p {
  margin: 0 0 10px;
  color: #e5e2eb;
  line-height: 1.45;
  white-space: normal;
}

.rules p:last-child {
  margin-bottom: 18px;
}

.rules-stage {
  z-index: 151;
}

/* The players' cards on the result frame. */
.result-card {
  border-radius: 12px;
  border: 2px solid #c08a2e;
  background: #28282a center / cover no-repeat;
  overflow: hidden;
}

/* The app's chrome on a game page sits above the game's own layers. */
.app-chrome {
  z-index: 6;
}

.app-chrome,
.app-chrome * {
  position: absolute;
}

/* Anything marked hidden stays hidden, whatever display a class gives it (the game pages get this from style.css). */
[hidden] {
  display: none !important;
}

/* Game Settings: the app's sliders and green switches. */
.settings-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 20px;
  background: transparent;
  accent-color: #f5a900;
}

.settings-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.3);
}

.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: #f5a900;
}

.settings-toggle {
  /* The game pages' style.css makes buttons at least 50 points tall; a switch is 16. */
  min-height: 0;
  width: 30px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.25);
  pointer-events: auto;
  cursor: pointer;
}

.settings-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  transition: left 120ms ease;
}

.settings-toggle.on {
  background: #16a34a;
}

.settings-toggle.on::after {
  left: 16px;
}

/* A round's points as one big number, on its way to the winner's score (match.js roundPoints). */
.round-points {
  z-index: 60;
  pointer-events: none;
}

.round-points .rp-caption,
.round-points .rp-number {
  position: absolute;
  left: 0;
  width: 100%;
  text-align: center;
  white-space: nowrap;
}

.round-points .rp-caption {
  top: 2px;
  font-size: 17px;
  font-weight: 600;
  line-height: 26px;
  color: #f8f7fa;
  text-shadow: 0 0 3px rgba(13, 5, 26, 0.75), 0 0 6px rgba(13, 5, 26, 0.75);
}

.round-points .rp-number {
  top: 26px;
  font-size: 68px;
  font-weight: 700;
  line-height: 80px;
  color: #f5a900;
  text-shadow: 0 0 4px rgba(13, 5, 26, 0.8), 0 0 10px rgba(13, 5, 26, 0.75);
}

/* A sideways game on a phone held upright: messages turn with it and sit along its bottom edge, which is the
   phone's left side. */
body.turned .toast-app,
body.turned .toast {
  left: max(56px, calc(env(safe-area-inset-left) + 56px));
  top: 50%;
  bottom: auto;
  width: min(330px, 80vh);
  transform: translate(-50%, -50%) rotate(90deg);
}

/* Free coins from ads (ads.js): the floating button on the home screen and the strip under the solo games. */
.ad-fab {
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.ad-fab-ball {
  position: relative !important;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, #ffd66b 0%, #f5a900 55%, #c27a00 100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  animation: ad-fab-breathe 4s ease-in-out infinite;
}

.ad-fab-tag {
  position: absolute !important;
  top: -4px;
  right: -6px;
  padding: 1px 6px;
  border-radius: 9px;
  background: #16a34a;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.ad-fab .ad-dots {
  position: relative !important;
}

/* A slow, small swell every few seconds: noticed, never in the way. */
@keyframes ad-fab-breathe {
  0%, 82%, 100% { transform: scale(1); }
  90% { transform: scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .ad-fab-ball { animation: none; }
}

.ad-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.ad-dots i {
  position: relative !important;
  display: block;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.ad-dots i.on {
  background: #f5a900;
  border-color: #ffd66b;
}

.ad-dots-row {
  display: flex;
  justify-content: center;
}

.ad-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: linear-gradient(90deg, rgba(245, 169, 0, 0.16) 0%, rgba(57, 43, 89, 0.55) 60%);
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  pointer-events: auto;
}

.ad-strip > * {
  position: relative !important;
}

.ad-strip-play {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f5a900;
}

.ad-strip-words {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  color: #f8f7fa;
  text-align: start;
  line-height: 1.2;
}

.ad-strip-words > * {
  position: static !important;
  display: block;
}

.ad-strip-words b {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ad-strip-words small {
  font-size: 10px;
  color: rgba(248, 247, 250, 0.7);
  white-space: nowrap;
}

/* The chat (chat.js): a page over the app with Public, Friends and Clubs, messages, and the line to write in. */
.chat-page > * {
  position: absolute;
}

.chat-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 2px 8px;
  pointer-events: auto;
}

.chat-list > * {
  position: relative !important;
  flex: none;
}

.chat-empty {
  margin: 40px 16px;
  text-align: center;
  color: rgba(248, 247, 250, 0.65);
  font-size: 13px;
}

.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 86%;
}

.chat-msg.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg > *,
.chat-bubble > *,
.chat-pick > *,
.chat-pick-words > * {
  position: static !important;
}

.chat-pic {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}

.chat-pic.big {
  width: 44px;
  height: 44px;
}

.chat-bubble {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 11px;
  border-radius: 14px 14px 14px 4px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f8f7fa;
  min-width: 60px;
}

.chat-msg.mine .chat-bubble {
  border-radius: 14px 14px 4px 14px;
  background: rgba(245, 169, 0, 0.22);
  border-color: rgba(245, 169, 0, 0.45);
}

.chat-name {
  font-size: 11px;
  font-weight: 600;
  color: #f5a900;
}

.chat-text {
  font-size: 13.5px;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-time {
  align-self: flex-end;
  font-size: 9.5px;
  color: rgba(248, 247, 250, 0.55);
}

.chat-bar {
  background: rgba(29, 25, 36, 0.92);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  pointer-events: auto;
}

.chat-bar > * {
  position: absolute;
}

.chat-tabs > * {
  position: absolute;
}

.chat-pick {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 0;
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f8f7fa;
  text-align: start;
  pointer-events: auto;
  cursor: pointer;
}

.chat-pick-words {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-pick-words b {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-pick-words small {
  font-size: 11px;
  color: rgba(248, 247, 250, 0.65);
}

.chat-go {
  font-size: 22px;
  color: #f5a900;
}

/* The Test-Pi gift in the Store (tabs.js): a round gold mark with the Pi sign. */
.pi-gift-mark {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd66b 0%, #f5a900 55%, #c27a00 100%);
  color: #1d1924;
  font-size: 30px;
  font-weight: 700;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}
