.painting-page {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 8%, rgba(255,211,78,.34), transparent 22rem),
    radial-gradient(circle at 92% 16%, rgba(255,79,154,.17), transparent 24rem),
    linear-gradient(180deg, #f4fbff 0, #fffaf0 520px);
}

.painting-shell {
  width: min(1040px, calc(100% - 24px));
  margin: 0 auto;
  padding: 22px 0 56px;
  min-width: 0;
}

.painting-topbar {
  text-align: center;
  margin-bottom: 16px;
}
.painting-topbar h1 {
  margin: 8px 0 6px;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1;
}
.painting-topbar p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.painting-panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid rgba(82,22,140,.09);
  border-radius: 30px;
  background: rgba(255,255,255,.97);
  box-shadow: var(--shadow);
}
.painting-panel + .painting-panel { margin-top: 16px; }
.painting-panel h2 {
  margin: 0 0 6px;
  font-size: clamp(1.18rem, 3vw, 1.65rem);
}
.painting-panel-intro {
  margin: 0 0 13px;
  color: var(--muted);
  line-height: 1.45;
}

/* Seletor horizontal: funciona como carrossel por toque. */
.painting-selector {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 164px;
  gap: 11px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 3px 3px 9px;
  scroll-snap-type: x proximity;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.painting-thumb {
  width: 164px;
  min-width: 164px;
  padding: 0;
  overflow: hidden;
  border: 3px solid #eadcf1;
  border-radius: 19px;
  background: white;
  color: inherit;
  text-align: left;
  cursor: pointer;
  scroll-snap-align: start;
  box-shadow: 0 8px 18px rgba(54,26,77,.08);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.painting-thumb:active { transform: scale(.98); }
.painting-thumb.active {
  border-color: var(--purple);
  box-shadow: 0 12px 25px rgba(114,39,184,.2);
}
.painting-thumb img {
  width: 100%;
  height: 124px;
  object-fit: cover;
  object-position: top center;
  background: white;
  border-bottom: 1px solid rgba(82,22,140,.08);
}
.painting-thumb-body {
  min-height: 66px;
  padding: 9px 10px 10px;
  display: grid;
  gap: 3px;
  align-content: center;
}
.painting-thumb-title {
  color: var(--purple-dark);
  font-size: .92rem;
  line-height: 1.12;
  font-weight: 1000;
}
.painting-thumb-sub {
  color: var(--muted);
  font-size: .74rem;
  line-height: 1.2;
}

.painting-toolbar {
  display: grid;
  gap: 11px;
  margin-bottom: 13px;
}
.painting-toolbar-row {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.painting-toolbar-row.scroll-row {
  flex-wrap: nowrap;
  max-width: 100%;
  overflow-x: auto;
  padding: 2px 2px 7px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.paint-tool,
.paint-action,
.brush-size-btn {
  min-height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: 15px;
  background: #f1e9f8;
  color: var(--purple-dark);
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 7px 18px rgba(57,27,78,.08);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.paint-tool.active,
.brush-size-btn.active {
  color: white;
  background: linear-gradient(135deg, #7b31c3, #5b1994);
}
.paint-action.primary {
  color: white;
  background: linear-gradient(135deg, var(--pink), var(--coral));
}
.paint-action:disabled {
  opacity: .45;
  cursor: default;
}

.painting-palette {
  display: flex;
  flex-wrap: nowrap;
  max-width: 100%;
  overflow-x: auto;
  gap: 9px;
  align-items: center;
  padding: 3px 3px 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.paint-color-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 3px solid white;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(82,22,140,.14), 0 6px 16px rgba(57,27,78,.12);
  touch-action: manipulation;
}
.paint-color-btn.active {
  transform: scale(1.08);
  box-shadow: 0 0 0 4px rgba(114,39,184,.23), 0 10px 20px rgba(57,27,78,.16);
}
.color-picker-wrap {
  flex: 0 0 auto;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #f7f0fb;
  color: var(--purple-dark);
  font-weight: 900;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(82,22,140,.08);
}
.color-picker-wrap input[type="color"] {
  width: 34px;
  height: 34px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.brush-options {
  padding: 9px 11px;
  border-radius: 16px;
  background: #fff8dc;
}
.brush-options[hidden] { display: none !important; }
.brush-options-label {
  color: #725000;
  font-weight: 1000;
  white-space: nowrap;
}
.brush-dot {
  display: inline-block;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
  margin-right: 5px;
}
.brush-dot.small { width: 7px; height: 7px; }
.brush-dot.medium { width: 12px; height: 12px; }
.brush-dot.large { width: 18px; height: 18px; }

.painting-stage-title {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.painting-stage-title h3 { margin: 0; font-size: 1.12rem; }
.painting-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 7px 11px;
  border-radius: 999px;
  background: #fff7d6;
  color: #6f4d00;
  font-size: .84rem;
  font-weight: 900;
}

.painting-stage-wrap {
  width: 100%;
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: hidden;
  padding: 8px;
  border-radius: 22px;
  background: linear-gradient(145deg, #f3ebfa, #eef9ff);
}
.painting-stage {
  position: relative;
  display: block;
  width: 100%;
  max-width: 720px;
  min-width: 0;
  overflow: hidden;
  contain: layout paint;
  border-radius: 17px;
  background: white;
  box-shadow: 0 18px 38px rgba(45,26,58,.16);
  user-select: none;
  -webkit-user-select: none;
}
.painting-stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
#paintLineCanvas { pointer-events: none; }
#paintColorCanvas {
  z-index: 1;
  cursor: crosshair;
  touch-action: none;
  overscroll-behavior: contain;
  -webkit-user-select: none;
}
#paintLineCanvas { z-index: 2; mix-blend-mode: normal; }
.painting-help {
  margin: 12px 2px 0;
  color: var(--muted);
  text-align: center;
  font-size: .9rem;
}
.hidden-for-paint {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
}

@media (max-width: 640px) {
  .painting-shell {
    width: min(100% - 10px, 760px);
    padding-top: 10px;
  }
  .painting-topbar { margin-bottom: 11px; }
  .painting-topbar p { display: none; }
  .painting-panel {
    padding: 11px;
    border-radius: 23px;
  }
  .painting-panel + .painting-panel { margin-top: 10px; }
  .painting-panel h2 { font-size: 1.05rem; }
  .painting-panel-intro { display: none; }
  .painting-selector {
    grid-auto-columns: 142px;
    gap: 8px;
  }
  .painting-thumb {
    width: 142px;
    min-width: 142px;
    border-radius: 16px;
  }
  .painting-thumb img { height: 106px; }
  .painting-thumb-body { min-height: 58px; padding: 7px 8px 9px; }
  .painting-thumb-title { font-size: .82rem; }
  .painting-thumb-sub { font-size: .68rem; }
  .painting-toolbar { gap: 8px; margin-bottom: 9px; }
  .painting-toolbar-row { gap: 6px; }
  .paint-tool,
  .paint-action,
  .brush-size-btn {
    min-height: 41px;
    padding: 0 10px;
    border-radius: 13px;
    font-size: .78rem;
  }
  .paint-color-btn { width: 33px; height: 33px; }
  .color-picker-wrap { min-height: 40px; padding: 4px 8px; font-size: .76rem; }
  .color-picker-wrap input[type="color"] { width: 31px; height: 31px; }
  .brush-options { padding: 7px 8px; }
  .brush-options-label { width: 100%; font-size: .78rem; }
  .painting-stage-title { margin-bottom: 7px; }
  .painting-stage-title h3 { font-size: .98rem; }
  .painting-status { display: none; }
  .painting-stage-wrap {
    padding: 3px;
    border-radius: 17px;
  }
  .painting-stage {
    width: 100%;
    max-width: 100%;
    border-radius: 13px;
  }
  .painting-help { font-size: .78rem; margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .painting-thumb { transition: none; }
}

/* Garantia de interação: a camada de cor recebe todos os toques e a arte de linha fica transparente. */
.painting-stage { isolation: isolate; }
#paintColorCanvas { pointer-events: auto !important; }
#paintLineCanvas { pointer-events: none !important; }

/* Pintura Android → Web: galeria e estúdio dentro de um stage lógico 1280×720. */
@font-face {
  font-family: "Painting Lilita";
  src: url("/jogos/pintura/assets/fonts/LilitaOne-Regular.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Painting Baloo";
  src: url("/jogos/pintura/assets/fonts/Baloo2-Variable.ttf") format("truetype");
  font-display: swap;
}

html:has(body.painting-page),
body.painting-page {
  width: 100%;
  min-width: 0;
  min-height: 100%;
  overflow: hidden;
}

body.painting-page {
  position: relative;
  isolation: isolate;
  margin: 0;
  display: grid;
  place-items: center;
  background: #29431d;
  font-family: "Painting Baloo", Nunito, sans-serif;
  overscroll-behavior: none;
}

body.painting-page::before {
  content: "";
  position: fixed;
  z-index: -2;
  inset: -14px;
  background:
    linear-gradient(rgba(24, 36, 16, .14), rgba(24, 36, 16, .2)),
    url("/jogos/pintura/assets/scene/painting-farm-landscape.png") center / cover no-repeat;
  filter: blur(4px) saturate(.94);
  transform: scale(1.025);
  pointer-events: none;
}

body.painting-page::after {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  background: rgba(30, 42, 20, .08);
  pointer-events: none;
}

.painting-game-root {
  position: relative;
  isolation: isolate;
  width: min(1280px, calc(100vw - 32px), calc((100dvh - 32px) * 16 / 9));
  max-width: 1280px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 4px solid rgba(250, 213, 119, .88);
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(239, 250, 255, .06), rgba(255, 248, 220, .12)),
    url("/jogos/pintura/assets/scene/painting-farm-landscape.png") center / cover no-repeat;
  box-shadow: 0 24px 60px rgba(22, 28, 14, .38), inset 0 0 0 2px rgba(255, 255, 255, .38);
  color: #4d235f;
  user-select: none;
  -webkit-user-select: none;
}

.painting-game-root button,
.painting-game-root a {
  font-family: "Painting Baloo", Nunito, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.painting-game-root button:focus-visible,
.painting-game-root a:focus-visible {
  outline: 5px solid #2eb7ea;
  outline-offset: 3px;
}

.painting-game-root [hidden] {
  display: none !important;
}

.painting-gallery-header {
  position: relative;
  z-index: 20;
  height: 88px;
  padding: 9px 14px;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 74px;
  align-items: center;
  gap: 14px;
  background: linear-gradient(180deg, rgba(255, 250, 224, .96), rgba(246, 220, 158, .93));
  border-bottom: 4px solid #d89536;
  box-shadow: 0 6px 18px rgba(74, 45, 20, .18);
}

.painting-gallery-header h1 {
  margin: 0;
  color: #6e2caf;
  font-family: "Painting Lilita", "Painting Baloo", sans-serif;
  font-size: clamp(34px, 3.8vw, 50px);
  font-weight: 400;
  line-height: 1;
  text-align: center;
  text-shadow: 0 3px 0 #fff7cf, 0 6px 12px rgba(90, 39, 135, .2);
}

.painting-icon-btn {
  box-sizing: border-box;
  width: 66px;
  height: 66px;
  min-width: 66px;
  min-height: 66px;
  padding: 3px;
  display: inline-grid;
  place-items: center;
  border: 3px solid #dfa13a;
  border-radius: 20px;
  background: linear-gradient(180deg, #fffbed, #f3d69b);
  color: #5b2877;
  cursor: pointer;
  box-shadow: 0 5px 0 #b96f28, 0 9px 17px rgba(70, 41, 19, .2);
  touch-action: manipulation;
}

.painting-icon-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #b96f28, 0 5px 10px rgba(70, 41, 19, .18);
}

.painting-icon-btn img {
  width: 58px;
  height: 58px;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.painting-home-btn {
  width: 170px;
  padding: 3px 13px 3px 4px;
  grid-template-columns: 58px auto;
  gap: 4px;
  color: #653b18;
  font-size: 22px;
  font-weight: 800;
  text-decoration: none;
}

.painting-home-btn img { width: 56px; height: 56px; }
.painting-sound-btn { justify-self: end; }
.painting-sound-btn img[hidden] { display: none !important; }

.painting-shell {
  width: 100%;
  height: calc(100% - 88px);
  min-height: 0;
  margin: 0;
  padding: 16px 24px 22px;
  display: block;
  overflow: hidden;
}

.painting-gallery-view {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 16px 18px;
  overflow: hidden;
  border: 4px solid rgba(216, 156, 50, .88);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 252, 230, .89), rgba(250, 236, 194, .82));
  box-shadow: 0 14px 34px rgba(64, 43, 25, .2), inset 0 0 0 2px rgba(255, 255, 255, .72);
}

.painting-selector {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 4px 6px 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 270px;
  align-content: start;
  gap: 18px;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: y proximity;
  overscroll-behavior-y: contain;
  scrollbar-color: #8a43c2 rgba(255, 255, 255, .55);
  scrollbar-width: thin;
}

.painting-thumb {
  position: relative;
  box-sizing: border-box;
  width: min(100%, 230px);
  height: 270px;
  min-width: 0;
  justify-self: center;
  padding: 7px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 48px;
  overflow: hidden;
  border: 4px solid #e0a53e;
  border-radius: 24px;
  background: linear-gradient(145deg, #fffdf2, #f8dfa5);
  color: #572080;
  text-align: center;
  cursor: pointer;
  scroll-snap-align: start;
  box-shadow: 0 7px 0 #bd7429, 0 13px 23px rgba(73, 44, 25, .2), inset 0 1px 0 rgba(255, 255, 255, .9);
  transition: transform 140ms ease, border-color 140ms ease, filter 140ms ease, box-shadow 140ms ease;
  touch-action: manipulation;
}

.painting-thumb:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #bd7429, 0 8px 15px rgba(73, 44, 25, .17);
}

.painting-thumb.active {
  border-color: #7c35b8;
  background: linear-gradient(145deg, #fffdf2, #ead2f8);
  box-shadow: 0 0 0 4px rgba(124, 53, 184, .24), 0 7px 0 #8f4dbb, 0 12px 24px rgba(73, 44, 25, .2);
}

.painting-thumb.active::after {
  content: "✓";
  position: absolute;
  top: 13px;
  right: 13px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 2px solid #fff8dc;
  border-radius: 50%;
  background: #6fbf4b;
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 3px 0 #3f842b, 0 5px 10px rgba(46, 92, 32, .25);
}

.painting-thumb img.painting-thumb-image {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 4px;
  display: block;
  object-fit: contain;
  border: 2px solid rgba(222, 172, 79, .58);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #fffaf0);
}

.painting-thumb-body {
  min-width: 0;
  padding: 5px 5px 1px;
  display: grid;
  place-items: center;
}

.painting-thumb-title {
  font-size: 18px;
  font-weight: 850;
  line-height: 1.05;
}

.painting-thumb-sub { display: none; }

.painting-thumb.premium-locked {
  filter: saturate(.86);
}

.painting-thumb .premium-lock-label {
  position: absolute;
  z-index: 4;
  top: 13px;
  right: 13px;
  min-width: 54px;
  min-height: 54px;
  padding: 4px;
  display: grid;
  place-items: center;
  border: 3px solid #fff1a6;
  border-radius: 18px;
  background: linear-gradient(145deg, #7d36b4, #54207f);
  box-shadow: 0 5px 0 #3f155f, 0 8px 15px rgba(51, 21, 74, .28);
}

.painting-thumb .premium-lock-label img {
  width: 43px;
  height: 43px;
  object-fit: contain;
}

body.painting-studio .painting-gallery-header { display: none; }

body.painting-studio .painting-shell {
  height: 100%;
  padding: 0;
}

.painting-studio-view {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 10px;
  display: grid;
  grid-template-columns: 215px minmax(0, 1fr) 184px;
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
}

.painting-tools-column,
.painting-colors-column {
  position: relative;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  border: 3px solid rgba(218, 157, 54, .86);
  border-radius: 24px;
  background: rgba(255, 248, 220, .95);
  box-shadow: 0 8px 18px rgba(75, 46, 23, .2), inset 0 1px 0 rgba(255, 255, 255, .92);
}

.painting-tools-column {
  padding: 9px;
  display: grid;
  grid-template-rows: 66px minmax(0, 1fr);
  gap: 10px;
}

.painting-studio-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.painting-studio-controls .painting-icon-btn {
  width: 100%;
  min-width: 0;
  height: 62px;
  min-height: 62px;
  border-radius: 17px;
}

.painting-studio-controls .painting-icon-btn img {
  width: 55px;
  height: 55px;
}

.painting-toolbar {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(76px, 1fr));
  align-content: stretch;
  gap: 9px;
}

.paint-tool,
.paint-action {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 76px;
  padding: 3px;
  display: grid;
  place-items: center;
  border: 3px solid #e2b55e;
  border-radius: 19px;
  background: linear-gradient(180deg, #fffdf1, #f5dfb2);
  color: #5f287e;
  cursor: pointer;
  box-shadow: 0 4px 0 #c58835, 0 7px 12px rgba(72, 44, 23, .16);
  touch-action: manipulation;
}

.paint-tool > span,
.paint-action > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.paint-tool.active {
  border-color: #a866d7;
  background: linear-gradient(145deg, #8740bf, #62258f);
  box-shadow: 0 4px 0 #4d176f, 0 0 0 4px rgba(151, 79, 205, .2);
}

.paint-action.primary {
  grid-column: 1 / -1;
  border-color: #cb7bb0;
  background: linear-gradient(145deg, #ff6cab, #dd4387);
  box-shadow: 0 4px 0 #a72b68, 0 7px 12px rgba(99, 31, 70, .2);
}

.paint-action:disabled {
  opacity: .42;
  filter: grayscale(.38);
  cursor: default;
}

.painting-tool-icon,
.painting-action-icon {
  width: 70px;
  height: 70px;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.painting-action-icon-undo { transform: scaleX(-1); }

.brush-options {
  position: absolute;
  z-index: 90;
  top: 174px;
  left: calc(100% + 10px);
  width: 222px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(3, 62px);
  justify-content: center;
  gap: 8px;
  border: 3px solid #d9a84e;
  border-radius: 18px;
  background: rgba(255, 250, 229, .98);
  box-shadow: 0 10px 24px rgba(54, 33, 18, .27);
}

.brush-size-btn {
  width: 62px;
  height: 62px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 3px solid #dbaa52;
  border-radius: 17px;
  background: #fff9e5;
  cursor: pointer;
  touch-action: manipulation;
}

.brush-size-btn.active {
  border-color: #7d35b5;
  background: #ead5f8;
  box-shadow: 0 0 0 4px rgba(125, 53, 181, .2);
}

.brush-dot {
  display: block;
  border-radius: 50%;
  background: #562075;
}

.brush-dot.small { width: 10px; height: 10px; }
.brush-dot.medium { width: 22px; height: 22px; }
.brush-dot.large { width: 36px; height: 36px; }

.painting-canvas-column {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.painting-stage-wrap {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 4px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 3px solid rgba(224, 176, 83, .78);
  border-radius: 24px;
  background: rgba(255, 253, 240, .32);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .62);
  touch-action: none;
}

.painting-stage {
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  overflow: hidden;
  border: 3px solid rgba(204, 152, 62, .72);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 9px 24px rgba(50, 31, 20, .22);
}

.painting-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#paintColorCanvas {
  z-index: 1;
  cursor: cell;
  touch-action: none;
}

#paintLineCanvas { z-index: 2; }

.painting-status {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 13px;
  max-width: calc(100% - 34px);
  min-height: 38px;
  padding: 5px 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateX(-50%);
  border: 2px solid rgba(222, 166, 70, .84);
  border-radius: 17px;
  background: rgba(255, 250, 229, .92);
  color: #5d277c;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 5px 12px rgba(64, 38, 20, .16);
}

.painting-colors-column {
  padding: 11px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.painting-palette {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 86px;
  align-content: center;
  gap: 9px;
  overflow: hidden;
}

.paint-color-btn,
.color-picker-wrap {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: 86px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 4px solid #fff9e5;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 0 0 3px #d3a14d, 0 6px 12px rgba(66, 40, 21, .2);
  touch-action: manipulation;
}

.paint-color-btn.active {
  z-index: 2;
  transform: scale(1.08);
  box-shadow: 0 0 0 5px #7d35b5, 0 7px 15px rgba(80, 35, 112, .32);
}

.color-picker-wrap {
  display: grid;
  place-items: center;
  background: conic-gradient(#ff4f9a, #ffd34e, #49b964, #2eb7ea, #7b31c3, #ff4f9a);
}

.color-picker-wrap > span {
  color: #fff;
  font-size: 34px;
  line-height: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .35);
}

.color-picker-wrap input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.painting-pause-modal {
  position: absolute;
  z-index: 2000;
  inset: 0;
  padding: 28px;
  display: grid;
  place-items: center;
  background: rgba(40, 21, 53, .62);
  backdrop-filter: blur(4px);
}

.painting-pause-card {
  width: min(560px, 86%);
  padding: 28px 36px 34px;
  display: grid;
  justify-items: center;
  gap: 12px;
  border: 5px solid #dda03a;
  border-radius: 34px;
  background: linear-gradient(180deg, #fffced, #f7dda7);
  box-shadow: 0 14px 0 #a85f25, 0 24px 48px rgba(30, 17, 10, .34);
}

.painting-pause-card > img {
  width: 130px;
  height: 130px;
  object-fit: contain;
}

.painting-pause-card h2 {
  margin: 0;
  color: #692aa3;
  font-family: "Painting Lilita", "Painting Baloo", sans-serif;
  font-size: 46px;
  font-weight: 400;
}

.painting-pause-card button {
  min-width: 270px;
  min-height: 68px;
  padding: 10px 28px;
  border: 4px solid #7132a2;
  border-radius: 22px;
  background: linear-gradient(145deg, #9450c7, #652991);
  color: #fff;
  font-size: 26px;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 7px 0 #461862, 0 12px 20px rgba(58, 23, 80, .28);
  touch-action: manipulation;
}

body.painting-paused .painting-studio-view { filter: saturate(.82); }

@media (max-width: 900px) and (hover: hover) {
  .painting-gallery-header { grid-template-columns: 150px minmax(0, 1fr) 66px; }
  .painting-home-btn { width: 145px; font-size: 18px; }
  .painting-selector { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .painting-studio-view { grid-template-columns: 190px minmax(0, 1fr) 160px; gap: 8px; }
  .painting-palette { grid-auto-rows: 70px; gap: 7px; }
  .paint-color-btn, .color-picker-wrap { height: 70px; }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  html.lila-portable-touch-game:fullscreen body.painting-page {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  html.lila-portable-touch-game:fullscreen body.painting-page.painting-mobile-stage-active .painting-game-root {
    position: fixed;
    z-index: 1;
    top: 50%;
    left: 50%;
    width: 1280px;
    min-width: 1280px;
    max-width: none;
    height: 720px;
    min-height: 720px;
    aspect-ratio: auto;
    border-radius: 0;
    transform: translate(-50%, -50%) scale(var(--painting-stage-scale, 1));
    transform-origin: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .painting-thumb,
  .painting-icon-btn { transition: none; }
  body.painting-page::before { filter: brightness(.88); }
}
