/* V23 rebaseline: warm storybook bistro, one clear action plane. */

:root {
  --v23-ink: #21182a;
  --v23-cream: #fff0c7;
  --v23-paper: #f4dfad;
  --v23-teal: #173f46;
  --v23-teal-light: #4d9a8d;
  --v23-indigo: #11172d;
  --v23-gold: #e2b560;
  --v23-danger: #c94f4b;
}

.scene-counter-occluder { display: none; }

@media (min-width: 721px) and (min-height: 500px) {
  body {
    background: #111326;
  }

  .viewport-backdrop img,
  .scene-backdrop img,
  .scene-counter-occluder img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transform: none;
  }

  .game-shell {
    position: relative;
    width: min(100vw, calc(100vh * 16 / 9));
    height: min(100vh, calc(100vw * 9 / 16));
    min-height: 0;
    margin: auto;
    overflow: hidden;
    isolation: isolate;
    background: #111326;
    border-radius: 0;
    box-shadow: 0 0 44px #050714b8;
  }

  .scene-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: block;
    pointer-events: none;
  }

  .scene-backdrop::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #08102424 0%, transparent 25%, transparent 78%, #0c142229 100%);
    pointer-events: none;
  }

  .scene-counter-occluder {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: block;
    clip-path: inset(49.7% 0 42.5% 0);
    pointer-events: none;
  }

  .topbar {
    position: absolute;
    z-index: 20;
    top: 12px;
    left: 50%;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: 58px 20px;
    width: min(92%, 920px);
    min-height: 0;
    padding: 0;
    transform: translateX(-50%);
    background: none;
    border: 0;
    box-shadow: none;
  }

  .topbar .brand,
  .topbar .served-stat,
  .topbar .star-stat {
    display: none;
  }

  .hud {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-columns: repeat(3, 82px);
    justify-content: center;
    gap: 10px;
    width: auto;
    height: 58px;
    max-width: none;
    padding: 0;
    aspect-ratio: auto;
    background: none;
  }

  .hud .pill {
    position: relative;
    display: grid;
    place-items: end center;
    width: 82px;
    height: 58px;
    min-width: 0;
    padding: 0 4px 2px;
    overflow: visible;
    color: var(--v23-cream);
    font: 700 16px/1 "Galactic UI", "Noto Sans CJK SC", sans-serif;
    letter-spacing: 0;
    text-shadow: 0 2px 2px #120b12, 0 0 5px #120b12;
    background-position: center top;
    background-size: 52px 52px;
    background-repeat: no-repeat;
    border: 0;
  }

  .hud .pill::before {
    content: attr(data-label);
    position: absolute;
    top: 2px;
    left: 50%;
    width: 72px;
    transform: translateX(-50%);
    color: #fff4d5;
    font-size: 8px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    text-shadow: 0 1px 2px #160b12;
  }

  .hud .timer { background-image: url("../assets/meowa/ui/v23/timer-badge.png"); }
  .hud .life { background-image: url("../assets/meowa/ui/v23/heart-badge.png"); }
  .hud .score { background-image: url("../assets/meowa/ui/v23/coin-badge.png"); }

  .top-actions {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
    display: flex;
    gap: 6px;
    margin-top: 3px;
  }

  .top-actions .icon-btn {
    width: 48px;
    min-width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    color: #fff0c7;
    font-size: 10px;
    text-shadow: 0 2px 2px #140b11;
    background-color: transparent;
    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;
    border: 0;
    box-shadow: none;
  }

  #audioBtn { background-image: url("../assets/meowa/ui/v23/energy-badge.png"); }
  #helpBtn { background-image: url("../assets/meowa/ui/v23/timer-badge.png"); }
  #restartBtn { background-image: url("../assets/meowa/ui/v23/coin-badge.png"); }

  .hud-subline {
    grid-column: 1 / 4;
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 20px;
    padding: 0;
    color: #fbe9bd;
    font-size: 10px;
    text-shadow: 0 1px 2px #100813;
  }

  .shift-progress {
    order: 2;
    width: min(54vw, 430px);
    height: 5px;
    overflow: hidden;
    background: #122d38cc;
    border: 1px solid #d9a95d;
    border-radius: 999px;
  }

  .substat {
    min-width: 66px;
    padding: 3px 8px;
    color: #fff1c9;
    background: #132b35d9;
    border: 1px solid #b78946;
    border-radius: 999px;
  }

  .combo-stat { order: 1; text-align: center; }
  .currency-stat { order: 3; text-align: center; }
  .currency-icon { width: 12px; height: 12px; }

  .shop {
    position: absolute;
    z-index: 4;
    top: 72px;
    right: 4.8%;
    left: 4.8%;
    height: 310px;
    min-height: 0;
    overflow: visible;
    background: none;
    border: 0;
    box-shadow: none;
  }

  .shop .awning,
  .shop .sign {
    display: none;
  }

  .shift-brief {
    position: absolute;
    z-index: 10;
    top: 18px;
    left: 50%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: 1fr 4px;
    align-items: center;
    width: min(440px, 46vw);
    min-height: 50px;
    padding: 8px 32px 9px;
    transform: translateX(-50%);
    color: #fff2cc;
    background: transparent url("../assets/meowa/ui/v23/primary-button.png") center / contain no-repeat;
    border: 0;
    box-shadow: none;
  }

  .shift-act {
    padding-right: 8px;
    color: #f2c76e;
    font-size: 9px;
  }

  .shift-copy {
    min-width: 0;
    text-align: center;
  }

  .shift-copy strong {
    display: inline;
    margin-right: 6px;
    font-family: "Galactic Display", serif;
    font-size: 14px;
    font-weight: 400;
  }

  .shift-copy span { font-size: 10px; }
  .shift-count { font-size: 11px; }
  .shift-track { grid-column: 1 / 4; width: 100%; height: 3px; background: #0e2632; }
  .shift-track span { background: #70c1a9; }

  .customers {
    position: absolute;
    inset: 60px 4% 0;
    display: grid;
    grid-template-columns: 1fr 1fr 0.48fr;
    gap: 5%;
    align-items: end;
    overflow: visible;
  }

  .customer {
    position: relative;
    display: block;
    width: 100%;
    height: 250px;
    min-width: 0;
    min-height: 0;
    padding: 0;
    overflow: visible;
    transform: none;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .customer:focus-visible {
    outline: 3px solid #fff19a;
    outline-offset: 3px;
    border-radius: 20px;
  }

  .customer .speech {
    position: absolute;
    z-index: 9;
    top: 2px;
    left: 50%;
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    grid-template-rows: 26px 22px 14px;
    width: 212px;
    height: 114px;
    min-height: 0;
    padding: 22px 24px 15px 22px;
    transform: translateX(-50%);
    color: var(--v23-ink);
    text-align: left;
    background: transparent url("../assets/meowa/ui/v23/order-ticket-left.png") center / contain no-repeat;
    border: 0;
    filter: drop-shadow(0 7px 7px #160d1766);
  }

  .customer:nth-child(2) .speech {
    background-image: url("../assets/meowa/ui/v23/order-ticket-right.png");
  }

  .customer .order-dish {
    grid-column: 1;
    grid-row: 1 / 4;
    align-self: center;
    width: 52px;
    height: 52px;
    object-fit: contain;
    filter: drop-shadow(0 2px 2px #331c2580);
  }

  .customer .order-line {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-width: 0;
    font-size: 12px;
    line-height: 1.1;
  }

  .customer .order-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .customer .order-level { flex: 0 0 auto; font-size: 10px; }
  .customer .preference { grid-column: 2; grid-row: 2; font-size: 9px; }
  .customer .trait-line { grid-column: 2; grid-row: 2; justify-self: end; font-size: 9px; }
  .customer .patience { grid-column: 2; grid-row: 3; align-self: center; width: 100%; height: 5px; }

  .customer .alien-wrap {
    position: absolute;
    z-index: 4;
    right: 0;
    bottom: -10px;
    left: 0;
    display: grid;
    place-items: end center;
    width: auto;
    height: 198px;
    margin: 0;
    overflow: visible;
    transform: none;
    background: none;
  }

  .customer:nth-child(2) .alien-wrap { transform: none; }

  .customer .alien-figure {
    display: grid;
    place-items: end center;
    width: 220px;
    height: 198px;
    overflow: visible;
  }

  .customer .alien-art,
  .customer .alien-art.character-insect {
    width: 210px;
    height: 210px;
    max-width: none;
    max-height: none;
    object-fit: contain;
    object-position: center bottom;
    filter: drop-shadow(0 10px 8px #140a1455);
  }

  .customer .customer-reaction {
    z-index: 11;
    top: 120px;
    bottom: auto;
    left: 50%;
    max-width: 160px;
    padding: 5px 10px;
    transform: translateX(-50%);
    color: #fff3ce;
    font-size: 11px;
    background: #153640e8;
    border: 1px solid #d9ad64;
    border-radius: 999px;
  }

  .customer.preview {
    width: 100%;
    height: 210px;
    opacity: 0.82;
  }

  .customer.preview .speech {
    top: 48px;
    width: 116px;
    height: 138px;
    grid-template-columns: 1fr;
    grid-template-rows: 20px 56px 30px;
    padding: 14px 18px 18px;
    text-align: center;
    background-image: url("../assets/meowa/ui/v23/order-ticket-next.png");
  }

  .customer.preview .preview-tag {
    position: static;
    grid-row: 1;
    color: #89602f;
    font-size: 9px;
  }

  .customer.preview .order-dish {
    grid-column: 1;
    grid-row: 2;
    justify-self: center;
    width: 50px;
    height: 50px;
  }

  .customer.preview .order-line {
    grid-column: 1;
    grid-row: 3;
    display: block;
    font-size: 9px;
    text-align: center;
  }

  .customer.preview .preference,
  .customer.preview .alien-wrap { display: none; }

  .merge-panel {
    position: absolute;
    z-index: 12;
    top: 405px;
    right: 5.4%;
    bottom: 22px;
    left: 5.4%;
    display: grid;
    grid-template-columns: 172px minmax(420px, 520px) 172px;
    justify-content: center;
    align-items: center;
    gap: 18px;
    min-height: 0;
    height: auto;
    padding: 0;
    overflow: visible;
    transform: none;
    background: none;
    border: 0;
    box-shadow: none;
  }

  .board-wrap {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    place-items: center;
    width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 0;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
  }

  .board {
    display: grid;
    grid-template-columns: repeat(5, 62px);
    grid-template-rows: repeat(4, 62px);
    gap: 5px;
    width: auto;
    height: auto;
    padding: 0;
    background: none;
    border: 0;
  }

  .cell {
    width: 62px;
    height: 62px;
    min-width: 62px;
    min-height: 62px;
    padding: 8px;
    overflow: visible;
    background: transparent url("../assets/meowa/ui/v23/board-slot.png") center / contain no-repeat;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .cell img { width: 46px; height: 46px; object-fit: contain; }

  .cell.selected,
  .cell.merge-target {
    filter: brightness(1.12) drop-shadow(0 0 8px #ffe58d);
  }

  .ops-panel { display: contents; }

  .review-strip,
  .selected-tray,
  .quick-guide,
  .dock-title { display: none; }

  .purchase-dock,
  .mutation-dock {
    position: static;
    width: 172px;
    min-width: 0;
    height: auto;
    min-height: 0;
    padding: 0;
    overflow: visible;
    background: none;
    border: 0;
    box-shadow: none;
  }

  .purchase-dock { grid-column: 1; grid-row: 1; }
  .mutation-dock { grid-column: 3; grid-row: 1; }

  .controls,
  .supply-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
    width: 100%;
  }

  .buy-btn {
    position: relative;
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) 18px;
    align-items: center;
    width: 172px;
    height: 61px;
    min-height: 61px;
    padding: 8px 10px 8px 9px;
    overflow: visible;
    color: #fff0c7;
    background-color: transparent;
    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;
    border: 0;
    box-shadow: none;
  }

  .buy-btn[data-chain="egg"] { background-image: url("../assets/meowa/ui/v23/ingredient-egg.png"); }
  .buy-btn[data-chain="tentacle"] { background-image: url("../assets/meowa/ui/v23/ingredient-tentacle.png"); }
  .buy-btn[data-chain="stardust"],
  .buy-btn[data-chain="crystal"] { background-image: url("../assets/meowa/ui/v23/ingredient-stardust.png"); }

  .buy-btn .supply-medallion {
    width: 46px;
    height: 46px;
    background: none;
    border: 0;
  }

  .buy-btn .supply-art { width: 42px; height: 42px; object-fit: contain; }
  .buy-btn .supply-copy { min-width: 0; min-height: 28px; gap: 2px; color: #fff0c7; text-align: left; }
  .buy-btn .supply-copy b { font-size: 11px; }
  .buy-btn .supply-copy span { font-size: 9px; }
  .buy-btn .supply-key { width: 17px; height: 17px; font-size: 9px; }
  .buy-btn.needed:not(:disabled) { filter: brightness(1.08) drop-shadow(0 0 7px #ffe7a2); }

  .supply-tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 2px;
  }

  .cargo-refresh,
  .recycle {
    min-width: 0;
    height: 43px;
    min-height: 43px;
    padding: 7px 8px;
    color: #fff1ca;
    font-size: 10px;
    background: transparent url("../assets/meowa/ui/v23/primary-button.png") center / contain no-repeat;
    border: 0;
    box-shadow: none;
  }

  .mutation-bar {
    display: grid;
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: 54px 54px;
    justify-content: center;
    gap: 7px 6px;
    width: 172px;
  }

  .energy-label {
    grid-column: 1 / 4;
    display: grid;
    place-items: end center;
    height: 54px;
    padding-bottom: 4px;
    color: #fff3cb;
    font-size: 13px;
    text-shadow: 0 2px 2px #140b12;
    background: transparent url("../assets/meowa/ui/v23/energy-badge.png") center / 52px 52px no-repeat;
  }

  .mutation-btn {
    width: 52px;
    min-width: 52px;
    height: 52px;
    min-height: 52px;
    padding: 0 2px 3px;
    color: #fff1ca;
    font-size: 9px;
    text-shadow: 0 1px 2px #140b12;
    background: transparent url("../assets/meowa/ui/v23/mutation-button.png") center / contain no-repeat;
    border: 0;
    box-shadow: none;
  }

  .mutation-btn[data-mutation="blazing"] { filter: sepia(.18) saturate(1.25); }
  .mutation-btn[data-mutation="glowing"] { filter: hue-rotate(18deg) brightness(1.06); }
  .mutation-btn[data-mutation="viscous"] { filter: hue-rotate(78deg); }
  .mutation-btn:disabled { filter: grayscale(.55) brightness(.72); color: #d9cfb4; }

  .contract-chip {
    position: absolute;
    right: 0;
    bottom: -4px;
    z-index: 3;
    width: 150px;
    min-height: 44px;
    color: #fff0c8;
    background: transparent url("../assets/meowa/ui/v23/primary-button.png") center / contain no-repeat;
    border: 0;
  }

  .modal {
    background: radial-gradient(circle at 50% 42%, #162744d9 0%, #0b1024f2 58%, #070a17fa 100%);
    backdrop-filter: blur(3px) saturate(.8);
  }

  .paper-card.star-tide-card {
    width: min(84vw, 760px);
    min-height: 350px;
    padding: 74px 88px 62px;
    color: #fff0cd;
    background: transparent url("../assets/meowa/ui/v23/event-panel.png") center / contain no-repeat;
    border: 0;
    box-shadow: none;
  }

  .star-tide-card h2 { margin: 0 0 6px; color: #fff2cc; }
  .star-tide-card > p { color: #d9e8e4; }
  .event-choices { gap: 8px; }

  .star-tide-card .event-choice {
    min-height: 74px;
    padding: 15px 24px;
    color: #fff1cc;
    background: transparent url("../assets/meowa/ui/v23/primary-button.png") center / contain no-repeat;
    border: 0;
    box-shadow: none;
  }

  .star-tide-card .event-choice span { color: #d9ebe4; }

  .star-tide-card .event-choice strong {
    font-size: 12px;
    line-height: 1.1;
    white-space: nowrap;
  }

  .star-tide-card .event-choice span {
    font-size: 9px;
    line-height: 1.15;
  }

  .toast {
    z-index: 80;
    color: #fff2cd;
    background: #15343ce8;
    border: 1px solid #d8ad62;
    border-radius: 999px;
  }
}

/* A tall desktop window must gain vertical room instead of squeezing the
   16:9 scene into a short strip.  The painting is cropped proportionally;
   neither the scene nor its counter occluder is stretched. */
@media (min-width: 721px) and (min-height: 500px) and (max-aspect-ratio: 3 / 2) {
  .game-shell {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
  }

  .viewport-backdrop img,
  .scene-backdrop img,
  .scene-counter-occluder img {
    object-fit: cover;
  }

  .topbar {
    top: 8px;
    width: 94%;
  }

  .shop {
    top: 74px;
    right: 3%;
    left: 3%;
    height: 304px;
  }

  .shift-brief {
    top: 8px;
    width: min(430px, 51vw);
  }

  .customers {
    inset: 52px 2% 0;
    grid-template-columns: 1fr 1fr .44fr;
    gap: 3%;
  }

  .customer {
    height: 242px;
  }

  .customer .speech {
    top: -10px;
    left: 38%;
    width: 196px;
    height: 106px;
    grid-template-columns: 52px minmax(0, 1fr);
    grid-template-rows: 24px 20px 14px;
    padding: 20px 22px 14px 20px;
  }

  .customer:nth-child(2) .speech { left: 62%; }

  .customer .order-dish {
    width: 47px;
    height: 47px;
  }

  .customer .alien-wrap,
  .customer .alien-figure {
    height: 184px;
  }

  .customer .alien-wrap {
    right: -4%;
    left: 22%;
  }

  .customer:nth-child(2) .alien-wrap {
    right: 22%;
    left: -4%;
  }

  .customer .alien-art,
  .customer .alien-art.character-insect {
    width: 194px;
    height: 194px;
  }

  .customer.preview .speech {
    width: 108px;
    height: 132px;
    padding: 14px 16px 17px;
  }

  .merge-panel {
    top: 390px;
    right: 4%;
    bottom: 18px;
    left: 4%;
    height: auto;
    grid-template-columns: 160px 300px 160px;
    gap: 10px;
    overflow: visible;
    transform: none;
  }

  .board {
    grid-template-columns: repeat(5, 56px);
    grid-template-rows: repeat(4, 56px);
    gap: 5px;
  }

  .cell {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    padding: 7px;
  }

  .cell img {
    width: 42px;
    height: 42px;
  }

  .purchase-dock,
  .mutation-dock,
  .mutation-bar {
    width: 160px;
  }

  .buy-btn {
    width: 160px;
    height: 56px;
    min-height: 56px;
    grid-template-columns: 46px minmax(0, 1fr) 17px;
  }

  .buy-btn .supply-medallion {
    width: 42px;
    height: 42px;
  }

  .buy-btn .supply-art {
    width: 39px;
    height: 39px;
  }

  .cargo-refresh,
  .recycle {
    height: 40px;
    min-height: 40px;
  }
}

@media (min-width: 721px) and (min-height: 500px) and (max-height: 690px) {
  .topbar { top: 7px; transform: translateX(-50%) scale(.9); transform-origin: top center; }
  .shop { top: 56px; height: 270px; }
  .customers { top: 50px; }
  .customer { height: 220px; }
  .customer .speech { transform: translateX(-50%) scale(.88); transform-origin: top center; }
  .customer .alien-wrap { height: 174px; }
  .customer .alien-art,
  .customer .alien-art.character-insect { width: 184px; height: 184px; }
  .merge-panel { top: 348px; bottom: 12px; transform: scale(.88); transform-origin: center; }
}

@media (max-width: 720px), (max-height: 499px) {
  .scene-counter-occluder { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .customer .alien-wrap,
  .customer .alien-art,
  .buy-btn,
  .mutation-btn { animation: none !important; transition: none !important; }
}
