:root {
  --ink: #30282b;
  --muted: #74696c;
  --panel: rgba(255, 253, 248, 0.94);
  --panel-solid: #fffaf2;
  --rose: #db6f83;
  --rose-deep: #b84d63;
  --green: #5f9e69;
  --line: rgba(48, 40, 43, 0.13);
  --shadow: 0 18px 42px rgba(99, 74, 65, 0.16), 0 3px 10px rgba(99, 74, 65, 0.08);
  --inner-line: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

html {
  min-height: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  position: relative;
  margin: 0;
  min-height: 100svh;
  overflow-x: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.46) 0 1px, transparent 1px 18px),
    linear-gradient(180deg, #f8e1e5 0%, #fff4e4 46%, #e4f1d7 100%);
  color: var(--ink);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.22), transparent 24%, rgba(255,255,255,0.18) 55%, transparent),
    repeating-linear-gradient(0deg, rgba(78, 58, 48, 0.018) 0 1px, transparent 1px 5px);
  opacity: 0.86;
}

body.standalone .topbar {
  padding-top: 4px;
}

input,
textarea {
  user-select: text;
  -webkit-user-select: text;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.game-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 12px calc(76px + env(safe-area-inset-bottom));
}

.topbar,
.top-actions,
.scene-head,
.card-title-row,
.pafu-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.top-actions {
  gap: 8px;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: var(--rose-deep);
  font-size: 12px;
  font-weight: 900;
}

h1 {
  margin-top: 2px;
  font-size: 26px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  line-height: 1.1;
}

.wallet {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 96px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(255,248,238,0.9));
  box-shadow: 0 12px 32px rgba(99, 74, 65, 0.16), inset 0 1px 0 rgba(255,255,255,0.86);
  font-size: 18px;
}

.wallet span {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff8b8, #f2be50 60%, #b87b22);
}

.app-button,
.music-button,
.soft-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--rose-deep);
  font-size: 13px;
  font-weight: 900;
}

.app-button,
.music-button {
  min-width: 58px;
  height: 44px;
}

.app-button {
  padding: 0 12px;
}

.music-button.playing {
  background: #30282b;
  color: #fff8f1;
}

.pause-button.playing {
  background: #30282b;
  color: #fff8f1;
}

.scene-card,
.pafu-card,
.controls,
.event-card,
.catalog-tile,
.dashboard article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow), var(--inner-line);
}

.app-nav {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: min(94vw, 520px);
  padding: 7px;
  transform: translateX(-50%);
  border: 1px solid rgba(48, 40, 43, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 16px 42px rgba(48, 40, 43, 0.2), inset 0 1px 0 rgba(255,255,255,0.86);
  backdrop-filter: blur(14px);
}

.app-nav button {
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdf8, #fff3e8);
  color: var(--muted);
  font-size: 13px;
  font-weight: 950;
  touch-action: manipulation;
}

.app-nav button.active,
.app-nav button:active {
  background: linear-gradient(180deg, #30282b, #49353a);
  color: #fff8ef;
}

.scene-card {
  overflow: hidden;
  border-color: rgba(91, 81, 70, 0.14);
  background: linear-gradient(180deg, rgba(255,253,248,0.985), rgba(255,248,239,0.955));
  box-shadow: 0 24px 62px rgba(88, 68, 56, 0.18), 0 2px 0 rgba(255,255,255,0.76) inset;
}

.nav-pop {
  animation: nav-pop 0.42s ease;
}

@keyframes nav-pop {
  0% { outline: 0 solid rgba(198, 72, 93, 0); }
  38% { outline: 4px solid rgba(198, 72, 93, 0.22); }
  100% { outline: 0 solid rgba(198, 72, 93, 0); }
}

.scene-head {
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(76, 60, 50, 0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.54), rgba(255,250,244,0.18));
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

#goalText {
  text-align: right;
}

canvas {
  display: block;
  width: 100%;
  height: min(72vh, 720px);
  min-height: 470px;
  background: #d8edc0;
  filter: saturate(1.04) contrast(1.02);
  touch-action: none;
}

.pafu-card {
  display: grid;
  grid-template-columns: 126px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  margin-top: 10px;
  background: linear-gradient(180deg, rgba(255,253,248,0.98), rgba(255,247,238,0.94));
}

.dog-faces {
  display: grid;
  width: 122px;
  min-height: 70px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  align-items: center;
  align-self: start;
  transform: translateY(-4px);
}

.dog-face {
  position: relative;
  width: 58px;
  height: 64px;
  border: 3px solid rgba(255, 253, 247, 0.94);
  border-radius: 17px;
  overflow: hidden;
  --dog-body: #fff8ec;
  --dog-shadow: #eadfd2;
  --dog-ear: #f2c84f;
  --dog-ear-dark: #d9a43c;
  --dog-muzzle: #fff2df;
  --dog-cheek: #f6b8b5;
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.92), transparent 24%),
    linear-gradient(180deg, #fff9ef, #f4e8d9);
  box-shadow:
    0 10px 24px rgba(79, 57, 42, 0.15),
    0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.dog-face img {
  display: none;
}

.dog-face::before {
  position: absolute;
  content: "";
  z-index: 2;
  left: 50%;
  top: 14%;
  width: 72%;
  height: 66%;
  transform: translateX(-50%);
  border-radius: 47% 47% 43% 43%;
  background:
    radial-gradient(circle at 32% 25%, rgba(255, 255, 255, 0.82), transparent 18%),
    linear-gradient(180deg, var(--dog-body), var(--dog-shadow));
  box-shadow:
    0 7px 13px rgba(68, 43, 35, 0.13),
    0 -1px 0 rgba(255, 255, 255, 0.75) inset;
}

.dog-face::after {
  position: absolute;
  z-index: 1;
  left: 19%;
  right: 19%;
  bottom: -14%;
  height: 42%;
  content: "";
  border-radius: 999px 999px 38% 38%;
  background: linear-gradient(180deg, var(--dog-body), var(--dog-shadow));
  box-shadow: 0 8px 15px rgba(68, 43, 35, 0.12);
}

.pafu-face {
  --dog-body: #fffdf2;
  --dog-shadow: #eadfd2;
  --dog-ear: #f2c84f;
  --dog-ear-dark: #d9a43c;
  --dog-muzzle: #fff3df;
  --dog-cheek: #ffb9b7;
}

.mayuan-face {
  position: relative;
  right: auto;
  bottom: auto;
  width: 58px;
  height: 64px;
  border-radius: 17px;
  --dog-body: #b98b68;
  --dog-shadow: #80614e;
  --dog-ear: #40352f;
  --dog-ear-dark: #241d1b;
  --dog-muzzle: #e7c998;
  --dog-cheek: #e9a390;
  box-shadow:
    0 10px 24px rgba(79, 57, 42, 0.15),
    0 10px 22px rgba(79, 57, 42, 0.16);
}

.ear,
.eye,
.nose,
.cheek {
  position: absolute;
  display: block;
}

.ear {
  z-index: 1;
  top: 13%;
  width: 19%;
  height: 30%;
  border-radius: 65% 65% 42% 42%;
  background: linear-gradient(180deg, var(--dog-ear), var(--dog-ear-dark));
  box-shadow: 0 4px 7px rgba(68, 43, 35, 0.12);
}

.ear.left {
  left: 18%;
  transform: rotate(-28deg);
}

.ear.right {
  right: 18%;
  transform: rotate(28deg);
}

.eye {
  z-index: 3;
  top: 39%;
  width: 7%;
  height: 7%;
  border-radius: 50%;
  background: #30282b;
  box-shadow: 0 0 0 1px rgba(55, 40, 35, 0.06);
}

.eye.left {
  left: 38%;
}

.eye.right {
  right: 38%;
}

.nose {
  z-index: 3;
  left: 50%;
  top: 51%;
  width: 12%;
  height: 9%;
  transform: translateX(-50%);
  border-radius: 60% 60% 55% 55%;
  background: #2f272a;
}

.nose::after {
  position: absolute;
  left: 50%;
  top: 70%;
  width: 150%;
  height: 85%;
  content: "";
  transform: translateX(-50%);
  border-radius: 0 0 999px 999px;
  border-bottom: 1.5px solid rgba(47, 39, 42, 0.45);
}

.cheek {
  z-index: 2;
  top: 50%;
  width: 15%;
  height: 12%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--dog-cheek), rgba(255, 185, 183, 0));
  opacity: 0.8;
}

.cheek.left {
  left: 28%;
}

.cheek.right {
  right: 28%;
}

.mayuan-face .eye {
  background: #1f1818;
}

.mayuan-face .cheek {
  opacity: 0.55;
}

.card-title-row {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.card-title-row strong {
  padding: 5px 8px;
  border-radius: 999px;
  background: #fff0f2;
  color: var(--rose-deep);
  font-size: 12px;
}

#tipText {
  min-height: 36px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.pafu-actions {
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.soft-button {
  min-height: 34px;
  padding: 0 10px;
  background: linear-gradient(180deg, #fffdf8, #fff2ea);
  box-shadow: none;
}

.soft-button:active,
.action-button:active,
.pig-chip:active {
  transform: translateY(1px);
}

meter {
  width: 100%;
  height: 15px;
  margin-top: 8px;
}

meter::-webkit-meter-bar {
  border: 0;
  border-radius: 999px;
  background: #eadfd9;
}

.find-list {
  display: flex;
  max-height: 34px;
  gap: 6px;
  margin-top: 7px;
  overflow-x: auto;
}

.find-item {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid #eadfd9;
  border-radius: 999px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
}

meter::-webkit-meter-optimum-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), #e0bd5f);
}

.controls {
  position: sticky;
  z-index: 5;
  bottom: max(0px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
  padding: 8px;
  border-color: rgba(112, 88, 70, 0.13);
  background: rgba(255, 251, 244, 0.94);
  box-shadow: 0 16px 40px rgba(72, 56, 47, 0.16), inset 0 1px 0 rgba(255,255,255,0.86);
  backdrop-filter: blur(18px) saturate(1.08);
}

.action-button {
  position: relative;
  display: grid;
  gap: 3px;
  min-height: 60px;
  align-content: center;
  padding: 7px 4px;
  border-radius: 8px;
  border: 1px solid rgba(48, 40, 43, 0.08);
  background: linear-gradient(180deg, #fffdf8, #f4e9df);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 5px 12px rgba(92, 67, 54, 0.07);
  text-align: center;
  overflow: hidden;
}

.action-button::before {
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 1px;
  content: "";
  background: rgba(255, 255, 255, 0.9);
}

.action-button.active {
  background: linear-gradient(180deg, #45383c, #2f292b);
  color: white;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 7px 16px rgba(48, 40, 43, 0.18);
}

.danger-button {
  color: #8c3f4c;
}

.danger-button strong {
  color: #9b3548;
}

.action-button:disabled,
.soft-button:disabled {
  cursor: default;
  opacity: 0.48;
}

.action-button strong {
  font-size: 13px;
  font-weight: 900;
}

.action-button small {
  color: var(--muted);
  font-size: 11px;
}

.action-button.active small {
  color: rgba(255, 255, 255, 0.75);
}

.dashboard {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.dashboard article {
  padding: 12px;
  background: linear-gradient(180deg, rgba(255,253,248,0.98), rgba(255,248,240,0.94));
}

.pig-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.pig-chip {
  position: relative;
  display: grid;
  gap: 4px;
  min-height: 82px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdf9, #fff5eb);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.78);
  text-align: left;
  overflow: hidden;
}

.pig-chip::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  content: "";
  background: linear-gradient(180deg, rgba(219,111,131,0.32), rgba(95,158,105,0.26));
}

.pig-chip.listed {
  outline: 2px solid rgba(219, 111, 131, 0.3);
}

.pig-chip.selected {
  outline: 3px solid rgba(101, 167, 109, 0.42);
  background: linear-gradient(180deg, #f4fff0, #fff8ef);
}

.pig-chip.dead {
  border-color: rgba(155, 53, 72, 0.28);
  background: linear-gradient(180deg, #fff7f7, #f1e7e1);
  box-shadow: inset 4px 0 0 rgba(155, 53, 72, 0.45), inset 0 1px 0 rgba(255,255,255,0.78);
}

.pig-chip.dead strong::after {
  content: " 待处理";
  color: #9b3548;
}

.pig-chip strong {
  font-size: 14px;
}

.pig-chip small,
.log {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.log {
  display: grid;
  gap: 5px;
  max-height: 160px;
  margin-top: 10px;
  overflow: auto;
}

.event-card {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.86), rgba(255,246,232,0.92)),
    radial-gradient(circle at 12% 10%, rgba(255, 218, 92, 0.28), transparent 36%);
}

.event-card strong {
  color: #7a4d22;
  font-size: 16px;
  font-weight: 950;
}

.event-card p,
.event-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.catalog-tile {
  display: grid;
  gap: 3px;
  min-height: 78px;
  padding: 10px;
  background: linear-gradient(180deg, #fffdf8, #f4fff0);
}

.catalog-tile strong {
  color: var(--rose-deep);
  font-size: 18px;
  font-weight: 950;
}

.catalog-tile span {
  font-size: 13px;
  font-weight: 900;
}

.catalog-tile small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  background: rgba(48, 40, 43, 0.36);
  backdrop-filter: blur(8px);
}

.breed-panel {
  width: min(100%, 720px);
  max-height: min(78vh, 720px);
  margin: 0 auto;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 56px rgba(48, 40, 43, 0.24);
  padding: 14px;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: #fff3f0;
  color: var(--rose-deep);
  font-size: 22px;
  font-weight: 900;
}

.modal-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.breed-grid {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.breed-option {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 78px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdf8, #fff7ef);
  text-align: left;
}

.breed-option.selected {
  outline: 3px solid rgba(101, 167, 109, 0.42);
  background: linear-gradient(180deg, #f4fff0, #fff8ef);
}

.breed-option strong {
  font-size: 14px;
}

.breed-option small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.pig-photo {
  display: block;
  width: 82px;
  aspect-ratio: 1.28;
  overflow: hidden;
  border: 1px solid rgba(48, 40, 43, 0.1);
  border-radius: 8px;
  background: #fff8ec;
}

.pig-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pig-option-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.pig-panel {
  width: min(100%, 620px);
}

.pig-profile {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.pig-profile .pig-photo {
  width: 112px;
}

.pig-profile-main {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.pig-profile-main strong {
  color: var(--ink);
  font-size: 15px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.stat-cell {
  display: grid;
  gap: 4px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf3;
  font-size: 11px;
}

.stat-cell b,
.stat-cell em {
  font-style: normal;
}

.stat-cell i {
  display: block;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #eadfd9;
}

.stat-cell i::before {
  display: block;
  width: var(--value);
  height: 100%;
  content: "";
  border-radius: inherit;
}

.stat-cell.good i::before {
  background: #6faf72;
}

.stat-cell.warn i::before {
  background: #d9a94c;
}

.stat-cell.bad i::before {
  background: #d66d73;
}

.name-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.name-row input {
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
}

.death-actions {
  margin-top: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 40;
  max-width: min(90vw, 420px);
  transform: translateX(-50%);
  padding: 13px 18px;
  border: 1px solid rgba(48, 40, 43, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: 0 22px 52px rgba(48, 40, 43, 0.22), inset 0 1px 0 rgba(255,255,255,0.86);
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  text-align: center;
}

.confirm-button {
  width: min(180px, 48%);
}

.confirm-button:disabled {
  background: linear-gradient(180deg, #fffaf3, #f7eee7);
  color: var(--muted);
}

.contest-panel {
  width: min(100%, 680px);
}

.king-panel {
  width: min(100%, 560px);
  background:
    radial-gradient(circle at 50% 8%, rgba(255, 222, 91, 0.36), transparent 34%),
    linear-gradient(180deg, #fffdf7, #fff1dc);
}

.king-body {
  margin: 12px 0;
}

.king-card {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(198, 145, 43, 0.28);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(255,246,213,0.82));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 16px 36px rgba(198, 145, 43, 0.18);
}

.king-card .pig-photo {
  width: 138px;
  box-shadow: 0 12px 26px rgba(198, 145, 43, 0.2);
}

.king-card strong {
  display: block;
  color: #8f5c13;
  font-size: 22px;
  font-weight: 950;
}

.king-card p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.contest-stage {
  position: relative;
  min-height: 230px;
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid rgba(48, 40, 43, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.68), rgba(255,250,238,0.18)),
    linear-gradient(90deg, #e9f3d8, #fff2df 48%, #e6f0d2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.86), inset 0 -20px 34px rgba(117, 84, 54, 0.08);
}

.arena-lines,
.arena-light {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.arena-lines {
  background:
    repeating-linear-gradient(0deg, transparent 0 38px, rgba(116, 94, 70, 0.12) 39px 40px),
    linear-gradient(90deg, transparent 48%, rgba(184, 77, 99, 0.18) 49%, rgba(184, 77, 99, 0.18) 51%, transparent 52%);
}

.arena-light {
  background: radial-gradient(circle at 50% 42%, rgba(255,255,255,0.64), transparent 38%);
}

.arena-pig {
  position: absolute;
  top: 50%;
  display: grid;
  width: 96px;
  height: 76px;
  place-items: center;
  transform: translateY(-50%);
  filter: drop-shadow(0 10px 8px rgba(70, 48, 36, 0.16));
}

.arena-pig .pig-photo {
  width: 92px;
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.76);
}

.arena-pig.player {
  left: var(--player-left, 8%);
}

.arena-pig.rival {
  right: var(--rival-right, 8%);
}

.arena-pig.rival .pig-photo {
  transform: scaleX(-1);
}

.contest-stage.rush .arena-pig {
  animation: contest-run 0.42s ease-in-out infinite alternate;
}

.contest-stage.clash .arena-pig {
  animation: contest-bump 0.22s ease-in-out infinite alternate;
}

.arena-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4);
  background: radial-gradient(circle, rgba(255,236,148,0.78), rgba(219,111,131,0.18) 46%, transparent 64%);
}

.contest-stage.clash .arena-burst,
.contest-stage.result .arena-burst {
  opacity: 1;
  animation: contest-flash 0.7s ease-out infinite alternate;
}

.arena-result {
  position: absolute;
  left: 50%;
  bottom: 16px;
  min-width: 108px;
  transform: translateX(-50%);
  padding: 9px 14px;
  border: 1px solid rgba(48, 40, 43, 0.1);
  border-radius: 999px;
  background: rgba(255,253,248,0.92);
  color: var(--ink);
  font-weight: 900;
  text-align: center;
  box-shadow: 0 12px 30px rgba(70, 48, 36, 0.16);
}

.contest-stage.win .arena-result {
  color: #8b5f13;
}

.contest-stage.lose .arena-result {
  color: #9b3548;
}

@keyframes contest-run {
  from { transform: translateY(-50%) rotate(-2deg); }
  to { transform: translateY(-54%) rotate(2deg); }
}

@keyframes contest-bump {
  from { transform: translateY(-50%) scale(1); }
  to { transform: translateY(-52%) scale(1.06); }
}

@keyframes contest-flash {
  from { transform: translate(-50%, -50%) scale(0.72); }
  to { transform: translate(-50%, -50%) scale(1.08); }
}

@media (min-width: 720px) {
  .game-shell {
    padding-inline: 22px;
  }

  h1 {
    font-size: 32px;
  }

  .pafu-card {
    grid-template-columns: 130px minmax(0, 1fr);
  }

  .dog-faces {
    width: 126px;
    min-height: 72px;
  }

  .pafu-face {
    width: 60px;
    height: 66px;
  }

  .mayuan-face {
    width: 60px;
    height: 66px;
  }

  .dashboard {
    grid-template-columns: 1.15fr 0.85fr;
  }

  .controls {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .pig-list {
    grid-template-columns: repeat(3, 1fr);
  }

  .action-button strong {
    font-size: 15px;
  }

  .breed-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 720px) and (orientation: portrait) {
  canvas {
    height: min(58svh, 600px);
    min-height: 500px;
  }

  .pafu-card {
    grid-template-columns: 112px minmax(0, 1fr);
    padding: 10px;
  }

  .dog-faces {
    width: 108px;
    min-height: 62px;
  }

  .pafu-face {
    width: 51px;
    height: 57px;
  }

  .mayuan-face {
    width: 51px;
    height: 57px;
  }

  .controls {
    gap: 8px;
  }

  .action-button {
    min-height: 66px;
  }

  .pig-list {
    grid-template-columns: 1fr;
    max-height: 270px;
    overflow: auto;
  }

  .log {
    max-height: 270px;
  }
}

@media (min-width: 900px) and (orientation: landscape) {
  body {
    overflow: hidden;
  }

  .game-shell {
    display: grid;
    width: min(100vw, 1280px);
    height: 100dvh;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) 342px;
    grid-template-rows: auto 126px auto minmax(0, 1fr);
    gap: 10px;
    padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom));
  }

  .topbar {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  h1 {
    font-size: 27px;
  }

  .wallet,
  .app-button,
  .music-button {
    height: 40px;
  }

  .app-button,
  .music-button {
    min-width: 54px;
    padding-inline: 10px;
  }

  .scene-card {
    display: flex;
    min-height: 0;
    grid-column: 1;
    grid-row: 2 / 5;
    flex-direction: column;
  }

  .scene-head {
    flex: 0 0 auto;
    padding: 8px 10px;
    font-size: 12px;
  }

  canvas {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
  }

  .pafu-card {
    grid-column: 2;
    grid-row: 2;
    grid-template-columns: 118px minmax(0, 1fr);
    gap: 9px;
    align-self: stretch;
    margin-top: 0;
    padding: 10px;
    overflow: visible;
  }

  .dog-faces {
    width: 114px;
    min-height: 64px;
    transform: translateY(-6px);
  }

  .pafu-face {
    width: 54px;
    height: 60px;
  }

  .mayuan-face {
    width: 54px;
    height: 60px;
  }

  .card-title-row {
    margin-bottom: 3px;
  }

  #tipText {
    min-height: 0;
    max-height: 38px;
    overflow: hidden;
    font-size: 12px;
  }

  .pafu-actions {
    gap: 6px;
    margin-top: 6px;
  }

  .soft-button {
    min-height: 32px;
  }

  meter {
    height: 12px;
    margin-top: 6px;
  }

  .controls {
    position: static;
    grid-column: 2;
    grid-row: 3;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-self: start;
    gap: 7px;
    margin-top: 0;
    padding: 8px;
    backdrop-filter: none;
  }

  .action-button {
    min-height: 50px;
  }

  .action-button strong {
    font-size: 14px;
  }

  .dashboard {
    display: grid;
    min-height: 0;
    grid-column: 2;
    grid-row: 4;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1.2fr) minmax(92px, 0.8fr);
    gap: 10px;
    margin-top: 0;
    overflow: hidden;
  }

  .dashboard article {
    display: flex;
    min-height: 0;
    flex-direction: column;
    padding: 10px;
    overflow: hidden;
  }

  .pig-list {
    grid-template-columns: 1fr;
    gap: 7px;
    min-height: 0;
    margin-top: 8px;
    overflow: auto;
    overscroll-behavior: contain;
  }

  .pig-chip {
    min-height: 74px;
    padding: 8px;
  }

  .pig-chip strong {
    font-size: 13px;
  }

  .pig-chip small,
  .log {
    font-size: 11px;
  }

  .log {
    min-height: 0;
    max-height: none;
    overflow: auto;
    overscroll-behavior: contain;
  }

  .game-shell[data-nav-view="dogsView"] .controls,
  .game-shell[data-nav-view="dogsView"] .dashboard,
  .game-shell[data-nav-view="workView"] .pafu-card,
  .game-shell[data-nav-view="workView"] .dashboard,
  .game-shell[data-nav-view="catalogView"] .pafu-card,
  .game-shell[data-nav-view="catalogView"] .controls {
    display: none;
  }

  .game-shell[data-nav-view="dogsView"] .pafu-card {
    grid-row: 2 / 5;
    grid-template-columns: 178px minmax(0, 1fr);
    align-content: start;
    align-self: stretch;
    gap: 12px;
  }

  .game-shell[data-nav-view="dogsView"] .dog-faces {
    width: 172px;
    min-height: 92px;
  }

  .game-shell[data-nav-view="dogsView"] .pafu-face {
    width: 82px;
    height: 90px;
  }

  .game-shell[data-nav-view="dogsView"] .mayuan-face {
    width: 82px;
    height: 90px;
  }

  .game-shell[data-nav-view="workView"] .controls {
    display: grid;
    grid-row: 2 / 5;
    align-self: stretch;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    overflow: auto;
  }

  .game-shell[data-nav-view="workView"] .action-button {
    min-height: 68px;
  }

  .game-shell[data-nav-view="catalogView"] .dashboard {
    grid-row: 2 / 5;
    grid-template-rows: 1fr;
    overflow: auto;
  }

  .game-shell[data-nav-view="catalogView"] .dashboard article {
    display: none;
  }

  .game-shell[data-nav-view="catalogView"] #catalogView {
    display: flex;
  }

  .modal-backdrop {
    align-items: center;
  }

  .breed-panel {
    max-height: min(88vh, 720px);
  }
}

@media (min-width: 1100px) and (orientation: landscape) {
  .game-shell {
    grid-template-columns: minmax(0, 1fr) 372px;
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .breed-option {
    grid-template-columns: 72px minmax(0, 1fr);
    padding: 8px;
  }

  .pig-photo {
    width: 72px;
  }

  .pig-profile {
    grid-template-columns: 1fr;
  }

  .pig-profile .pig-photo {
    width: 100%;
    max-width: 180px;
  }

  .name-row {
    grid-template-columns: 1fr;
  }
}
