html,
body {
  min-height: 100dvh;
}

.fullscreen-toggle {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border: 1px solid #d2dbf8;
  border-radius: 12px;
  background: #f7f9ff;
  color: #222956;
  cursor: pointer;
}

.fullscreen-toggle[hidden] { display: none; }
.fullscreen-toggle:hover { background: #e8edff; }

#panel .playing {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.game-toolbar {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  padding-inline: 8px;
  background: #10182e;
  color: #eef4ff;
  border-bottom: 1px solid #ffffff24;
}

.game-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  height: auto;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
}

.game-toolbar button:hover { background: #ffffff1a; }
.game-toolbar .fullscreen-toggle[hidden] { display: none; }
.game-exit { padding-inline: 8px; font-size: .81rem; font-weight: 750; white-space: nowrap; }
.game-announcement { flex: 1; text-align: center; color: #92f2de; font-size: .8rem; }

.peep-channel { display: flex; width: fit-content; margin: 18px auto 0; }
.peep-invite {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: center;
  overflow: hidden;
  margin-block: 26px 36px;
  border: 1px solid #ccdfed;
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow);
}
.peep-invite img { width: 100%; height: auto; }
.peep-invite-copy { padding: clamp(20px, 4vw, 42px); }
.peep-invite h2 { font-size: clamp(25px, 3vw, 38px); letter-spacing: -.055em; }
.peep-invite p { margin: 9px 0 16px; max-width: 36ch; color: var(--muted); line-height: 1.5; }
.game-peep-callout {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
  padding: 16px; margin-bottom: 26px; border: 1px solid #cfdfed; border-radius: 15px; background: #fff;
}
.game-peep-callout p { color: var(--muted); font-size: .87rem; margin-top: 4px; }
#panel[open]:has(.peep-panel) {
  position: fixed; inset: 0; width: 100%; height: 100dvh; max-width: none; max-height: none;
  margin: 0; overflow: hidden; border: 0; border-radius: 0;
  background: linear-gradient(#fcfeff, #f3f9fe);
}
html:has(#panel[open] .peep-panel), body:has(#panel[open] .peep-panel) { overflow: hidden; }

#panel .peep-panel {
  --peep-edge: clamp(18px, 3.5vw, 52px);
  display: grid;
  grid-template-columns: minmax(0, .78fr) minmax(360px, 1.22fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(12px, 2vw, 26px);
  width: min(100%, 1580px);
  height: 100%;
  margin: 0 auto;
  padding: max(var(--peep-edge), env(safe-area-inset-top)) max(var(--peep-edge), env(safe-area-inset-right))
    max(var(--peep-edge), env(safe-area-inset-bottom)) max(var(--peep-edge), env(safe-area-inset-left));
  color: var(--panel-ink);
}
#panel .peep-panel > .close {
  z-index: 2; top: max(var(--peep-edge), env(safe-area-inset-top)); right: max(var(--peep-edge), env(safe-area-inset-right));
}
.peep-petals { display: none; }
#panel .peep-header {
  display: flex; align-items: center; gap: 11px; grid-column: 1 / -1; padding-inline-end: 53px;
  min-height: 44px;
}
#panel .peep-header img { width: clamp(30px, 3.5vw, 44px); height: auto; }
#panel .peep-header h2 { margin: 0; padding: 0; font-size: clamp(25px, 3vw, 42px); letter-spacing: -.05em; line-height: 1.08; }
#panel .peep-header h2:focus { outline: none; }

.peep-camera-area, .peep-editor { min-width: 0; min-height: 0; }
.peep-camera-area {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}
.peep-camera-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid #cfdfec;
  border-radius: 22px;
  background: radial-gradient(ellipse at 50% 46%, #fff 22%, #edf6fc 82%);
  box-shadow: inset 0 1px #fff;
}
.peep-studio, .peep-viewport, .peep-viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.peep-studio { object-fit: cover; opacity: 0; }
.peep-viewport { cursor: grab; touch-action: none; }
.peep-viewport:active { cursor: grabbing; }
.peep-viewport:focus-visible { outline-offset: -5px; }
.peep-no-webgl { cursor: default; }
.peep-preview-art { position: absolute; inset: 50% auto auto 50%; width: min(45%, 200px); translate: -50% -50%; border-radius: 20px; }
.peep-camera-dock {
  display: grid; justify-items: center; gap: 8px;
  padding: 5px 7px 0;
}
#panel .peep-preview-caption { order: 2; margin: 0; color: var(--panel-muted); font-size: .78rem; text-align: center; }
.peep-camera {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 5px;
  border: 1px solid var(--panel-line); border-radius: 26px; background: #fff;
}
.peep-camera button, .peep-tabs button, .peep-fields button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 5px 10px; border: 1px solid transparent; border-radius: 10px;
  color: var(--panel-ink); background: transparent; font-size: .83rem; font-weight: 750;
}
.peep-camera button { background: linear-gradient(#fff, #edf6fc); border-color: #d3e5f1; border-radius: 22px; }
.peep-camera button:has(.icon) { min-width: 44px; padding: 5px; }
.peep-camera button:hover, .peep-tabs button:hover, .peep-fields button:hover { background: #eaf6ff; }
.peep-camera button[aria-pressed="true"], .peep-fields button[aria-pressed="true"] {
  background: #eaf4fc; border-color: #6e9fc3; color: #174b76;
}

.peep-editor {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  width: 100%;
  height: 100%;
  border: 1px solid var(--panel-line); border-radius: 22px; background: #fff;
  box-shadow: 0 3px 12px #244b7211;
}
.peep-tabs {
  grid-row: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px;
  padding: 10px; background: linear-gradient(#fbfdff, #f0f7fe); border-bottom: 1px solid #d6e7f3;
}
.peep-tabs button {
  gap: 5px; min-width: 0; padding: 4px 2px; border-radius: 12px;
  border-color: #ccdfed; background: linear-gradient(#fff, #f3f8fc);
}
.peep-keycap {
  display: grid; place-items: center; flex: none; width: 21px; aspect-ratio: 1;
  color: #356781;
}
.peep-tabs button[aria-pressed="true"] { background: #e6f1fc; border-color: #6e9fc3; color: #164c78; }
.peep-fields { grid-row: 2; display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 14px 0; }
.peep-fields button { background: #f7fbfe; border-color: #d8e7f1; }
.peep-scroll { grid-row: 3; overflow: auto; overscroll-behavior: contain; scrollbar-color: #9abbd2 #f5fbff; }
.peep-options { min-width: 0; margin: 0; padding: 14px; border: 0; }
.peep-option-group { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; align-items: stretch; }
.peep-option-group h3 { grid-column: 1 / -1; margin: 0 0 3px; font-size: .88rem; color: #284963; }
.peep-fields:not([hidden]) + .peep-scroll .peep-option-group h3 { display: none; }
.peep-options button {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px;
  min-width: 0; padding: 5px 5px 8px; border: 1px solid #d7e6f0; border-radius: 12px;
  background: #fbfdff; color: var(--panel-ink); font-size: .8rem; font-weight: 760; line-height: 1.2; overflow-wrap: anywhere;
}
.peep-options button:hover { background: #eff8ff; border-color: #a7cde5; }
.peep-options button[aria-pressed="true"] {
  border-color: var(--panel-gold); box-shadow: inset 0 0 0 1px var(--panel-gold);
  background: var(--panel-selected);
}
.peep-options button[aria-pressed="true"]::after {
  content: ''; position: absolute; top: 8px; right: 8px; width: 8px; height: 8px;
  border-radius: 50%; background: #9a680b; box-shadow: 0 0 0 2px #fff;
}
.peep-options small { color: #754614; background: #fff1dc; border-radius: 6px; padding: 3px 5px; font-size: .62rem; }
.peep-option-art {
  display: block; width: 100%; aspect-ratio: 1; height: auto; border-radius: 7px; object-fit: contain;
  background: radial-gradient(circle at 50% 43%, white, #edf5fc 86%);
}
.peep-options button[aria-pressed="true"] .peep-option-art {
  background: radial-gradient(circle at 50% 43%, white, #fff1c1 86%);
}
.peep-colors button { justify-content: center; min-height: 68px; }
.peep-swatch {
  flex: none; width: 25px; height: 25px; border: 1px solid #0003; border-radius: 50%;
  box-shadow: inset 0 2px 2px #fff7, 0 2px 3px #17355622;
}
.peep-original-color { background: conic-gradient(#f18dbd, #e9af33, #8ee2bf, #71bde9, #b7a0e0, #f18dbd); }
.peep-reveal { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.peep-reveal i {
  --distance: clamp(28px, 7vw, 112px);
  position: absolute; inset-inline-start: 50%; inset-block-start: 46%;
  width: clamp(8px, 1.4vw, 18px); aspect-ratio: 1; opacity: 0;
  background: #fff5c2; filter: drop-shadow(0 0 6px #fdce76);
  clip-path: polygon(50% 0, 63% 36%, 100% 50%, 63% 64%, 50% 100%, 36% 64%, 0 50%, 36% 36%);
}
.peep-reveal i:nth-child(1) { --x: -1.35; --y: -.9; --delay: 15ms; }
.peep-reveal i:nth-child(2) { --x: .88; --y: -1.14; --delay: 55ms; }
.peep-reveal i:nth-child(3) { --x: -1.54; --y: .38; --delay: 105ms; }
.peep-reveal i:nth-child(4) { --x: 1.18; --y: .58; --delay: 75ms; }
.peep-reveal i:nth-child(5) { --x: 1.7; --y: -.18; --delay: 130ms; }
.peep-footer {
  grid-row: 4; display: grid; gap: 9px; padding: 11px 14px 13px; border-top: 1px solid #dce9f2; background: #f9fcff;
}
.peep-status { display: grid; gap: 4px; justify-items: start; }
#panel .peep-feedback { margin: 0; color: var(--panel-muted); font-size: .82rem; line-height: 1.4; }
#panel .peep-error { color: #9d2748; }
.peep-footer .text-button { color: #075580; font-size: .77rem; }
.peep-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.peep-actions .button {
  min-height: 44px; padding: 5px 14px; font-size: .82rem;
  background: linear-gradient(#fff, #edf7fd);
  color: var(--panel-ink); border-color: var(--panel-line); box-shadow: 0 2px 3px #24496e1c;
}
.peep-actions .button .icon { width: 15px; height: 15px; }
.peep-actions .primary {
  margin-inline-start: auto;
  background: linear-gradient(#fff0a8, #ffda61);
  border-color: #b58318;
}
.peep-actions .button:hover { filter: brightness(1.04); }
.peep-actions [data-peep-sign-out] { min-height: 44px; }
.peep-panel button:disabled { opacity: .55; cursor: default; }

@media (prefers-reduced-motion: no-preference) {
  .peep-camera-area { animation: peep-panel-in 240ms var(--ease-out) both; }
  .peep-editor { animation: peep-panel-in 240ms var(--ease-out) 30ms both; }
  .peep-option-group { animation: peep-panel-in 150ms var(--ease-out) both; }
  .peep-option-art, .peep-swatch { transition: transform 190ms cubic-bezier(.2,.85,.3,1); }
  .peep-options button:hover .peep-option-art { transform: scale(1.045); }
  .peep-options button[aria-pressed="true"] .peep-swatch { transform: scale(1.15); }
  .peep-options button, .peep-tabs button, .peep-fields button {
    transition: background 130ms ease, border-color 130ms ease, scale 130ms ease, box-shadow 170ms ease;
  }
  .peep-options button:active, .peep-tabs button:active, .peep-fields button:active { scale: .974; }
  .peep-reveal[data-reaction] i { animation: peep-sparkle 600ms cubic-bezier(.16,.7,.32,1) var(--delay) both; }
  .peep-reveal[data-reaction="fitStyle"] i:nth-child(n + 3) { animation: none; }
  @keyframes peep-sparkle {
    0% { opacity: 0; transform: translate(calc(var(--distance) * var(--x) * .55), calc(var(--distance) * var(--y) * .55)) scale(.3) rotate(5deg); }
    32% { opacity: 1; }
    62% { opacity: .9; }
    100% { opacity: 0; transform: translate(calc(var(--distance) * var(--x)), calc(var(--distance) * var(--y))) scale(.7) rotate(90deg); }
  }
  @keyframes peep-panel-in { from { opacity: 0; translate: 0 5px; } to { opacity: 1; translate: 0; } }
}
@media (max-width: 760px) and (orientation: portrait), (max-width: 630px) {
  #panel .peep-panel {
    --peep-edge: 10px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(140px, 1fr) minmax(260px, 48dvh);
    gap: 8px;
  }
  #panel .peep-header { padding-inline-start: 4px; }
  .peep-editor { height: 100%; border-radius: 17px; }
  .peep-camera-frame { border-radius: 17px; }
  .peep-camera-dock { justify-content: center; padding: 5px 6px; }
  #panel .peep-preview-caption { display: none; }
  .peep-tabs { padding: 4px 6px; gap: 3px; }
  .peep-tabs button { padding-block: 1px 4px; }
  .peep-fields { padding: 6px 8px 0; }
  .peep-options { padding: 8px; }
  .peep-option-group { gap: 6px; }
  .peep-footer { padding: 7px 8px; gap: 4px; }
  .peep-actions { gap: 5px; }
  .peep-actions .button { padding-inline: 8px; }
}
@media (max-width: 420px) {
  .peep-tabs button { gap: 2px; font-size: .77rem; }
  .peep-keycap { width: 18px; }
  .peep-keycap .icon { width: 15px; height: 15px; }
  .peep-options button { font-size: .73rem; }
}
@media (max-height: 570px) and (orientation: portrait) {
  #panel .peep-panel { grid-template-rows: auto minmax(82px, .55fr) minmax(264px, 1.45fr); }
  .peep-camera button { padding-inline: 6px; }
  .peep-actions .button .icon { display: none; }
}
@media (max-height: 470px) and (orientation: landscape) {
  #panel .peep-panel { --peep-edge: 8px; grid-template-columns: minmax(0, 1fr) minmax(315px, 1fr); gap: 6px; }
  #panel .peep-header h2 { font-size: 25px; }
  #panel .peep-preview-caption { display: none; }
  .peep-camera-dock { padding: 4px 7px; }
  .peep-tabs { padding: 4px; }
  .peep-fields { padding-top: 4px; }
  .peep-options { padding-block: 6px; }
  .peep-footer { padding-block: 5px; gap: 2px; }
}
@media (max-width: 660px) {
  .peep-invite { grid-template-columns: 1fr; }
  .fullscreen-toggle { width: 36px; height: 36px; }
}
