:root {
  color-scheme: dark;
  --ink: #f5f7fb;
  --muted: #9aa7b8;
  --night: #101826;
  --panel: #182235;
  --line: rgba(255, 255, 255, 0.12);
  --cyan: #42d9e8;
  --pink: #ff5f8f;
  --yellow: #ffd447;
  --green: #65d68b;
  --paper: #f7f1df;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--night);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #101826;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

body * {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

img,
canvas,
button,
a {
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

button,
a {
  font: inherit;
}

button:focus-visible,
canvas:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(66, 217, 232, 0.65);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.home-lobby {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  overflow: hidden;
  border: 12px solid #151821;
  background:
    radial-gradient(#d8bd30 1.35px, transparent 1.35px) 0 0 / 10px 10px,
    #f7e85a;
  color: #171a24;
}

.home-lobby::before {
  content: "";
  position: absolute;
  inset: 76px 0 auto;
  height: 5px;
  background: #151821;
}

.home-head {
  position: relative;
  z-index: 4;
  display: flex;
  width: min(1440px, calc(100% - 64px));
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto;
}

.home-brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.home-brand > span:last-child {
  display: flex;
  flex-direction: column;
}

.home-brand strong {
  font-family: "Arial Rounded MT Bold", "PingFang SC", sans-serif;
  font-size: 1.15rem;
  font-weight: 1000;
}

.home-brand small {
  margin-top: 2px;
  color: #e33f54;
  font-size: 0.57rem;
  font-weight: 950;
}

.home-brand-mascot {
  position: relative;
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border: 3px solid #151821;
  background: #ee5360;
  box-shadow: 5px 5px 0 #151821;
  color: #fff;
  transform: rotate(-5deg);
}

.home-brand-mascot::before,
.home-brand-mascot::after {
  content: "";
  position: absolute;
  top: -9px;
  width: 13px;
  height: 13px;
  border: 3px solid #151821;
  background: #55d9d1;
  transform: rotate(45deg);
}

.home-brand-mascot::before { left: 3px; }
.home-brand-mascot::after { right: 3px; background: #fff8e8; }
.home-brand-mascot b { position: relative; z-index: 1; font-size: 1.3rem; font-weight: 1000; }
.home-brand-mascot i { position: absolute; right: 7px; bottom: 4px; width: 9px; height: 5px; border-bottom: 2px solid #151821; border-radius: 50%; }

.home-records {
  display: flex;
  align-items: center;
  gap: 7px;
}

.home-records > span {
  display: flex;
  min-height: 35px;
  align-items: center;
  gap: 7px;
  border: 2px solid #151821;
  padding: 0 11px;
  background: #fff9de;
  box-shadow: 3px 3px 0 #151821;
  font-size: 0.63rem;
  font-weight: 850;
  white-space: nowrap;
}

.home-records strong { font-size: 0.84rem; }

.home-audio {
  display: grid;
  width: 39px;
  height: 38px;
  place-items: center;
  border: 3px solid #151821;
  padding: 0;
  background: #55d9d1;
  box-shadow: 3px 3px 0 #151821;
  color: #151821;
  cursor: pointer;
  font-size: 1.05rem;
}

.home-audio.muted { background: #a7aba8; }

.home-stage {
  position: relative;
  z-index: 2;
  display: grid;
  width: min(1440px, calc(100% - 64px));
  min-height: calc(100dvh - 112px);
  grid-template-columns: minmax(280px, 0.72fr) minmax(600px, 1.45fr);
  align-items: center;
  gap: clamp(28px, 4vw, 64px);
  margin: 0 auto;
  padding: 34px 0 28px;
}

.home-title-block {
  position: relative;
  z-index: 2;
  min-height: 320px;
  border: 5px solid #151821;
  padding: clamp(26px, 4vw, 48px);
  background: #fffaf0;
  box-shadow: 11px 11px 0 #ee5360;
  transform: rotate(-1deg);
}

.home-title-block p {
  margin: 0 0 13px;
  color: #e13d51;
  font-size: 0.68rem;
  font-weight: 1000;
}

.home-title-block h1 {
  margin: 0;
  font-family: "Arial Rounded MT Bold", "PingFang SC", sans-serif;
  font-size: clamp(3.4rem, 5.3vw, 5.4rem);
  font-weight: 1000;
  line-height: 0.98;
  letter-spacing: 0;
}

.home-title-block > strong {
  display: inline-block;
  margin-top: 22px;
  border: 3px solid #151821;
  padding: 7px 12px;
  background: #f7e85a;
  box-shadow: 3px 3px 0 #151821;
  font-size: 0.9rem;
  transform: rotate(1.5deg);
}

.home-burst {
  position: absolute;
  top: -43px;
  right: 17px;
  border: 4px solid #151821;
  padding: 8px 16px;
  background: #55d9d1;
  box-shadow: 4px 4px 0 #151821;
  font-family: "Arial Rounded MT Bold", sans-serif;
  font-size: 1.2rem;
  font-weight: 1000;
  transform: rotate(5deg);
}

.cute-face {
  position: absolute;
  right: 24px;
  bottom: 22px;
  width: 54px;
  height: 45px;
  border: 3px solid #151821;
  border-radius: 50%;
  background: #ff9fc3;
  transform: rotate(-7deg);
}

.cute-face i { position: absolute; top: 13px; width: 5px; height: 8px; border-radius: 50%; background: #151821; }
.cute-face i:first-child { left: 14px; }
.cute-face i:nth-child(2) { right: 14px; }
.cute-face b { position: absolute; bottom: 8px; left: 50%; width: 15px; height: 8px; border-bottom: 3px solid #151821; border-radius: 50%; transform: translateX(-50%); }

.home-games {
  display: grid;
  height: min(71vh, 720px);
  min-height: 540px;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 15px;
}

.home-game-card {
  --card-image: none;
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 5px solid #151821;
  padding: 0;
  background: #171a24;
  box-shadow: 7px 7px 0 #151821;
  color: #fff;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
}

.home-game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--card-image);
  background-position: center;
  background-size: cover;
  transition: transform 220ms ease, filter 220ms ease;
}

.home-game-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 25%, rgba(14, 17, 25, 0.94));
}

.home-game-card:hover::before { transform: scale(1.035); filter: saturate(1.14) brightness(1.05); }
.home-game-card:active { translate: 3px 3px; box-shadow: 4px 4px 0 #151821; }
.home-game-card:nth-child(2), .home-game-card:nth-child(3) { transform: rotate(0.7deg); }
.home-game-card:nth-child(2):active, .home-game-card:nth-child(3):active { transform: rotate(0.7deg) translate(3px, 3px); }
.home-runner { --card-image: url("./assets/runner-adventure-far.svg"); }
.home-tile { --card-image: url("./assets/kitchen-table.webp"); }
.home-dragon { --card-image: url("./assets/ocean-depths.webp"); }
.home-defend { --card-image: url("./assets/chentang-arena-v2.webp"); }

.home-game-copy {
  position: absolute;
  z-index: 2;
  right: 62px;
  bottom: 16px;
  left: 18px;
}

.home-game-copy small {
  display: inline-block;
  margin-bottom: 8px;
  border: 2px solid #151821;
  padding: 3px 7px;
  background: #f7e85a;
  color: #151821;
  font-size: 0.57rem;
  font-weight: 1000;
}

.home-game-copy strong {
  display: block;
  overflow-wrap: anywhere;
  font-family: "Arial Rounded MT Bold", "PingFang SC", sans-serif;
  font-size: clamp(1.15rem, 1.75vw, 1.75rem);
  font-weight: 1000;
  line-height: 1.08;
}

.home-game-copy > span { display: block; margin-top: 7px; font-size: 0.62rem; font-weight: 850; }

.home-play {
  position: absolute;
  z-index: 3;
  right: 17px;
  bottom: 17px;
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border: 3px solid #151821;
  background: #ee5360;
  box-shadow: 3px 3px 0 #151821;
  color: #fff;
  font-size: 0.9rem;
  font-style: normal;
}

.cute-sticker {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  border: 3px solid #151821;
  box-shadow: 3px 3px 0 #151821;
  font-family: "Arial Rounded MT Bold", sans-serif;
  font-weight: 1000;
  pointer-events: none;
}

.sticker-star { top: 8%; left: 2%; width: 50px; height: 50px; border-radius: 50%; background: #55d9d1; color: #151821; font-size: 1.55rem; transform: rotate(-12deg); }
.sticker-heart { right: -2px; bottom: 7%; width: 47px; height: 42px; background: #ff9fc3; color: #e23b50; font-size: 1.25rem; transform: rotate(8deg); }
.sticker-bolt { top: 4%; right: 31%; width: 40px; height: 48px; background: #fffaf0; color: #e23b50; font-size: 1.65rem; transform: rotate(11deg); }
.sticker-flower { bottom: 2%; left: 30%; width: 43px; height: 43px; border-radius: 50%; background: #9b8cf4; color: #fff; font-size: 1.3rem; transform: rotate(-8deg); }

body.home-mode > .site-head,
body.home-mode > .arcade-shell,
body.home-mode > .site-foot {
  display: none;
}

body:not(.home-mode) > .home-lobby {
  display: none;
}

body:not(.home-mode) {
  --game-accent: #ffd84d;
  --game-accent-2: #ff766c;
  --game-page: #78d3f2;
  --game-panel: rgba(255, 252, 224, 0.92);
  --game-border: rgba(103, 74, 114, 0.34);
  --game-shadow: #c78932;
  --game-page-image: url("./assets/runner-adventure-far.svg");
  background-color: var(--game-page);
  background-image:
    linear-gradient(180deg, rgba(68, 181, 225, 0.3), var(--game-page) 680px),
    var(--game-page-image);
  background-position: center top;
  background-repeat: no-repeat;
  background-size: 100% auto;
}

body[data-active-game="tileGame"] {
  --game-accent: #ff6975;
  --game-accent-2: #69bd8a;
  --game-page: #2b252c;
  --game-panel: rgba(52, 38, 39, 0.9);
  --game-border: rgba(255, 213, 153, 0.34);
  --game-shadow: #a8434b;
  --game-page-image: url("./assets/kitchen-table.webp");
}

body[data-active-game="dragonGame"] {
  --game-accent: #7ce8c4;
  --game-accent-2: #ffd66e;
  --game-page: #061923;
  --game-panel: rgba(8, 37, 49, 0.9);
  --game-border: rgba(124, 232, 196, 0.32);
  --game-shadow: #287b66;
  --game-page-image: url("./assets/ocean-depths.webp");
}

body[data-active-game="defendGame"] {
  --game-accent: #ffd36b;
  --game-accent-2: #e65449;
  --game-page: #19121b;
  --game-panel: rgba(43, 25, 34, 0.92);
  --game-border: rgba(255, 211, 107, 0.34);
  --game-shadow: #8c662c;
  --game-page-image: url("./assets/chentang-harbor.webp");
}

.site-head,
.arcade-shell,
.site-foot {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
}

.site-head {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--game-border);
  background: linear-gradient(90deg, rgba(6, 12, 22, 0.82), rgba(6, 12, 22, 0.46));
  backdrop-filter: blur(12px) saturate(1.15);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  background: var(--game-accent);
  color: #172033;
  font-size: 1.25rem;
  font-weight: 950;
  transform: rotate(-4deg);
}

.brand > span:last-child {
  display: flex;
  flex-direction: column;
}

.brand strong {
  font-size: 1.06rem;
}

.brand small,
.game-tab small {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0;
}

.record-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px 26px;
  color: var(--muted);
  font-size: 0.78rem;
}

.head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
}

.audio-toggle {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid var(--game-border);
  background: var(--game-panel);
  color: var(--game-accent);
  cursor: pointer;
  font-size: 1.15rem;
}

.audio-toggle:hover {
  border-color: var(--game-accent);
  background: rgba(27, 39, 56, 0.94);
}

.audio-toggle.muted {
  color: #69778b;
}

.record-strip strong {
  margin-left: 6px;
  color: var(--ink);
  font-size: 0.94rem;
}

.arcade-shell {
  padding: 18px 0 42px;
}

.game-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.game-tab {
  --tab-accent: #ffd84d;
  --tab-image: url("./assets/runner-adventure-far.svg");
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 92px;
  align-items: center;
  gap: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 14px 20px;
  background:
    linear-gradient(90deg, rgba(8, 14, 24, 0.95), rgba(8, 14, 24, 0.58)),
    var(--tab-image) center / cover no-repeat;
  color: #ffffff;
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, filter 160ms ease, translate 160ms ease;
}

.game-tab:nth-child(2) { --tab-accent: #ff6975; --tab-image: url("./assets/kitchen-table.webp"); }
.game-tab:nth-child(3) { --tab-accent: #7ce8c4; --tab-image: url("./assets/ocean-depths.webp"); }
.game-tab:nth-child(4) { --tab-accent: #ffd36b; --tab-image: url("./assets/chentang-harbor.webp"); }

.game-tab::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 4px;
  background: var(--tab-accent);
  opacity: 0.2;
}

.game-tab > * { position: relative; z-index: 1; }

.game-tab:hover { border-color: var(--tab-accent); filter: saturate(1.12) brightness(1.06); }
.game-tab:active { translate: 0 2px; }

.game-tab > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.game-tab strong {
  font-size: 1rem;
}

.tab-number {
  color: #617089;
  font-size: 0.72rem;
  font-weight: 900;
}

.game-tab.active {
  border-color: var(--tab-accent);
  background:
    linear-gradient(90deg, rgba(7, 13, 22, 0.9), rgba(7, 13, 22, 0.34)),
    var(--tab-image) center / cover no-repeat;
  box-shadow: inset 0 0 0 2px var(--tab-accent), 0 8px 24px rgba(0, 0, 0, 0.26);
  color: #ffffff;
}

.game-tab.active small {
  color: rgba(255, 255, 255, 0.72);
}

.game-tab.active .tab-number {
  color: var(--tab-accent);
}

.game-tab.active::after { opacity: 1; }

.game-screen {
  display: grid;
  grid-template-columns: minmax(330px, 0.42fr) minmax(0, 1fr);
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--game-border);
  border-radius: 6px;
  background: #0c1421;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
}

.game-screen[hidden] {
  display: none;
}

.game-info {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
  padding: 42px 36px;
  border-right: 1px solid var(--game-border);
  background: var(--game-panel);
  isolation: isolate;
}

.game-info > * { position: relative; z-index: 1; }

.runner-info {
  background:
    linear-gradient(145deg, rgba(255, 253, 224, 0.97) 15%, rgba(255, 240, 177, 0.84)),
    url("./assets/runner-adventure-meadow.svg") center / cover no-repeat;
  color: #3f3652;
}

.runner-info::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  opacity: 0.38;
  background:
    radial-gradient(#ff8f86 1.5px, transparent 1.5px) 0 0 / 22px 22px,
    linear-gradient(180deg, transparent 68%, rgba(85, 190, 100, 0.28));
  pointer-events: none;
}

.runner-info .game-kicker { color: #ee624f; }
.runner-info .game-desc { color: #6b6075; }
.runner-info .hud-block { border-color: rgba(103, 74, 114, 0.23); background: rgba(103, 74, 114, 0.23); }
.runner-info .hud-block span { background: rgba(255, 255, 241, 0.84); color: #7a6c80; }
.runner-info .hud-block strong { color: #3f3652; }
.runner-info .key-guide { color: #6b6075; }
.runner-info kbd { border-color: rgba(103, 74, 114, 0.32); background: #fffdf0; color: #3f3652; }

.tile-info {
  background:
    linear-gradient(145deg, rgba(255, 250, 230, 0.96), rgba(246, 220, 180, 0.86)),
    url("./assets/kitchen-table.webp") center / cover no-repeat;
  color: #35252d;
}

.tile-info::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  opacity: 0.34;
  background: radial-gradient(#df6a74 1.4px, transparent 1.4px) 0 0 / 18px 18px;
  pointer-events: none;
}

.dragon-info {
  background:
    linear-gradient(145deg, rgba(4, 28, 40, 0.96), rgba(7, 56, 66, 0.72)),
    url("./assets/ocean-depths.webp") center / cover no-repeat;
}

.dragon-info::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  opacity: 0.5;
  background:
    radial-gradient(circle at 78% 18%, transparent 0 12px, rgba(150, 242, 220, 0.25) 13px 14px, transparent 15px),
    radial-gradient(circle at 86% 31%, transparent 0 5px, rgba(150, 242, 220, 0.2) 6px 7px, transparent 8px),
    radial-gradient(circle at 69% 43%, transparent 0 8px, rgba(150, 242, 220, 0.18) 9px 10px, transparent 11px);
  pointer-events: none;
}

.defend-info {
  background:
    linear-gradient(145deg, rgba(34, 17, 29, 0.96), rgba(77, 31, 36, 0.75)),
    url("./assets/chentang-harbor.webp") center / cover no-repeat;
}

.defend-info::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 16px;
  border: 1px solid rgba(255, 211, 107, 0.28);
  box-shadow: inset 0 0 0 5px rgba(122, 39, 39, 0.18);
  pointer-events: none;
}

.game-info h1,
.game-info p {
  margin-top: 0;
}

.game-info h1 {
  margin-bottom: 16px;
  font-size: 3rem;
  line-height: 1;
  letter-spacing: 0;
  text-wrap: balance;
  text-shadow: 0 4px 22px rgba(0, 0, 0, 0.32);
}

.game-kicker {
  margin-bottom: 12px;
  color: var(--game-accent);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.game-desc {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.8;
}

.hud-block {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 34px 0 26px;
  background: var(--game-border);
  border: 1px solid var(--game-border);
}

.hud-block span {
  display: flex;
  min-width: 0;
  min-height: 68px;
  flex-direction: column;
  justify-content: center;
  padding: 10px;
  background: rgba(8, 17, 30, 0.78);
  color: #8492a6;
  font-size: 0.68rem;
  text-align: center;
}

.hud-block strong {
  min-height: 1.35em;
  margin-top: 4px;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.96rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-command,
.icon-command {
  min-height: 48px;
  border: 0;
  cursor: pointer;
  font-weight: 900;
}

.primary-command {
  min-width: 142px;
  padding: 0 22px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: var(--game-accent);
  box-shadow: 0 5px 0 var(--game-shadow), 0 12px 26px rgba(0, 0, 0, 0.24);
  color: #172033;
}

.primary-command:hover {
  filter: brightness(1.08) saturate(1.08);
}

.primary-command:active { translate: 0 3px; box-shadow: 0 2px 0 var(--game-shadow); }

.key-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
  color: #7f8da1;
  font-size: 0.72rem;
}

kbd {
  display: inline-grid;
  min-width: 28px;
  min-height: 24px;
  margin-right: 5px;
  place-items: center;
  border: 1px solid var(--game-border);
  border-bottom-width: 3px;
  padding: 0 6px;
  background: rgba(8, 18, 30, 0.78);
  color: #d9e0eb;
  font: inherit;
}

.canvas-wrap {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--game-page);
}

.fullscreen-toggle {
  position: absolute;
  z-index: 12;
  top: 12px;
  right: 12px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(12, 20, 33, 0.82);
  color: #ffffff;
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  touch-action: manipulation;
}

.fullscreen-toggle:active,
.fullscreen-toggle:hover {
  border-color: var(--yellow);
  background: var(--yellow);
  color: #172033;
}

.in-game-result-actions {
  position: absolute;
  z-index: 13;
  top: calc(50% + 58px);
  left: 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  translate: -50% 0;
}

.in-game-result-actions[hidden] {
  display: none;
}

.in-game-replay,
.in-game-switch {
  min-width: 136px;
  min-height: 46px;
  border: 0;
  padding: 0 20px;
  cursor: pointer;
  font-weight: 950;
  touch-action: manipulation;
}

.in-game-replay {
  background: var(--yellow);
  box-shadow: 0 6px 0 #b78216, 0 12px 28px rgba(0, 0, 0, 0.35);
  color: #172033;
}

.in-game-switch {
  border: 1px solid rgba(224, 249, 246, 0.52);
  background: rgba(5, 22, 34, 0.9);
  box-shadow: 0 6px 0 #06131d, 0 12px 28px rgba(0, 0, 0, 0.35);
  color: #ffffff;
}

.in-game-replay:active,
.in-game-switch:active {
  translate: 0 4px;
  box-shadow: 0 2px 0 #b78216, 0 7px 18px rgba(0, 0, 0, 0.3);
}

.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  background: #111827;
  touch-action: none;
}

.runner-wrap > #runnerCanvas {
  position: relative;
  z-index: 1;
}

.runner-wrap > .runner-hero-layer {
  position: absolute;
  z-index: 3;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: 100%;
  background: transparent;
  object-fit: contain;
  pointer-events: none;
}

.mobile-actions {
  position: absolute;
  z-index: 10;
  right: 16px;
  bottom: 16px;
  left: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.mobile-actions span {
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.mobile-actions button {
  width: 50px;
  height: 48px;
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(12, 20, 33, 0.82);
  color: #ffffff;
  cursor: pointer;
  font-weight: 900;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.mobile-actions button:active,
.mobile-actions button.active {
  border-color: var(--yellow);
  background: var(--yellow);
  color: #172033;
}

.runner-actions span {
  font-size: 1.35rem;
}

.runner-actions {
  justify-content: space-between;
}

.tile-screen {
  background: #34271e;
}

.tile-info {
  color: #35252d;
}

.tile-info .game-kicker { color: #cf3f57; }
.tile-info .game-desc { color: #725d60; }
.tile-info .hud-block { border-color: rgba(112, 69, 54, 0.2); background: rgba(112, 69, 54, 0.2); }
.tile-info .hud-block span { background: rgba(255, 252, 238, 0.8); color: #8a6e68; }
.tile-info .hud-block strong { color: #35252d; }
.tile-info .key-guide { color: #725d60; }
.tile-info kbd { border-color: rgba(83, 55, 46, 0.34); background: #fffaf0; color: #3b2930; }
.tile-info .primary-command { background: #ff6975; color: #ffffff; }

.tool-row {
  display: flex;
  gap: 9px;
}

.icon-command {
  width: 48px;
  min-width: 48px;
  padding: 0;
  background: #101826;
  color: #ffffff;
  font-size: 1.25rem;
}

.tile-info .icon-command {
  border: 1px solid rgba(90, 58, 47, 0.24);
  background: #fffaf0;
  color: #473039;
  box-shadow: 0 4px 0 rgba(112, 69, 54, 0.32);
}

.tile-playfield {
  position: relative;
  display: grid;
  min-width: 0;
  grid-template-rows: minmax(380px, 1fr) auto;
  overflow: hidden;
  background: #b87543 url("./assets/kitchen-table.webp") center / cover no-repeat;
}

.tile-playfield > .fullscreen-toggle {
  z-index: 14;
}

.tile-playfield::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 1;
  background:
    radial-gradient(ellipse at 50% 58%, rgba(255, 245, 202, 0.14), transparent 52%),
    linear-gradient(180deg, rgba(48, 29, 20, 0.03), rgba(48, 29, 20, 0.16));
}

.pantry-scene {
  position: absolute;
  inset: 0 0 126px;
  overflow: hidden;
  pointer-events: none;
  display: none;
}

.shelf {
  position: absolute;
  right: 4%;
  width: 23%;
  height: 10px;
  background: #6d4930;
  box-shadow: 0 7px 0 rgba(58, 35, 22, 0.22);
}

.shelf-one { top: 22%; }
.shelf-two { top: 70%; left: 4%; }

.jar {
  position: absolute;
  width: 42px;
  height: 62px;
  border: 4px solid rgba(92, 59, 37, 0.55);
  border-radius: 7px 7px 16px 16px;
  background: rgba(255, 246, 210, 0.42);
}

.jar::before {
  content: "";
  position: absolute;
  top: -9px;
  left: -5px;
  width: 44px;
  height: 9px;
  background: #755039;
}

.jar-one { top: 11%; right: 9%; }
.jar-two { top: 58%; left: 12%; transform: scale(0.82); }

.tile-board {
  position: relative;
  z-index: 1;
  width: min(94%, 760px);
  max-height: 450px;
  aspect-ratio: 16 / 9;
  align-self: center;
  justify-self: center;
}

.food-tile {
  position: absolute;
  display: flex;
  width: 10.8%;
  aspect-ratio: 0.86;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(113, 71, 38, 0.42);
  border-radius: 7px;
  padding: 0;
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 255, 255, 0.9) 0 4%, transparent 27%),
    linear-gradient(145deg, #fffdf4 0%, #f4e3bf 64%, #dcb37d 100%);
  box-shadow:
    0 5px 0 #8c5732,
    0 10px 18px rgba(50, 26, 13, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  color: #253047;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 120ms ease, filter 120ms ease;
}

.food-tile::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px solid rgba(129, 82, 42, 0.19);
  border-radius: 5px;
}

.food-tile::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 193, 94, 0.2), rgba(188, 108, 53, 0.05) 60%, transparent 62%);
  box-shadow: inset 0 0 0 1px rgba(121, 77, 41, 0.1);
}

@media (hover: hover) and (pointer: fine) {
  .food-tile:hover:not(.covered) {
    filter: brightness(1.05) saturate(1.08);
    box-shadow:
      0 5px 0 #8c5732,
      0 10px 24px rgba(50, 26, 13, 0.42),
      inset 0 0 0 2px rgba(255, 255, 255, 0.76);
  }
}

.food-tile:active:not(.covered) {
  transform: translateY(-2px) scale(0.97);
  filter: brightness(1.08) saturate(1.08);
}

.food-tile.covered {
  opacity: 1;
  filter: brightness(0.82) saturate(0.94) contrast(0.94);
  box-shadow:
    0 3px 0 #765037,
    0 7px 13px rgba(50, 26, 13, 0.27),
    inset 0 0 0 3px rgba(73, 55, 44, 0.18);
  cursor: not-allowed;
}

.food-tile.covered::before {
  border-color: rgba(77, 57, 44, 0.34);
}

.food-tile .food-art,
.tray-tile .food-art {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.food-emoji {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: 2.55rem;
  line-height: 1;
  filter: drop-shadow(0 4px 2px rgba(70, 44, 28, 0.25)) saturate(1.08);
}

.food-name {
  display: none;
}

.tray-area {
  position: relative;
  z-index: 3;
  min-height: 126px;
  border-top: 8px solid #5f3928;
  padding: 12px 22px 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), transparent 28%),
    #efe1c5;
  box-shadow: 0 -12px 30px rgba(67, 36, 20, 0.24);
  color: #314058;
}

.tray-area p {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 9px;
  font-size: 0.72rem;
  font-weight: 900;
}

.tray-area p span {
  color: #8b6a4e;
  font-weight: 700;
}

.tile-tray {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(7, minmax(38px, 66px));
  min-height: 66px;
  gap: 6px;
  justify-content: center;
  border: 1px solid rgba(79, 48, 30, 0.46);
  padding: 7px;
  background:
    repeating-linear-gradient(90deg, transparent 0 54px, rgba(96, 58, 31, 0.06) 55px 56px),
    linear-gradient(180deg, #d2b17c, #e7cfaa);
  box-shadow: inset 0 3px 8px rgba(72, 39, 22, 0.22), 0 1px 0 rgba(255, 255, 255, 0.65);
}

.tray-slot,
.tray-tile {
  aspect-ratio: 0.9;
  border-radius: 5px;
}

.tray-slot {
  border: 1px solid rgba(83, 56, 35, 0.2);
  background: rgba(255, 250, 226, 0.24);
  box-shadow: inset 0 2px 4px rgba(67, 39, 20, 0.14);
}

.tray-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(113, 71, 38, 0.3);
  background: linear-gradient(145deg, #fffdf4, #edd5aa);
  box-shadow: 0 3px 0 #9d6840, 0 5px 8px rgba(69, 39, 21, 0.17);
}

.tray-tile .food-emoji {
  font-size: 1.7rem;
}

.tray-tile .food-name {
  display: none;
}

.game-overlay {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(20, 28, 42, 0.9);
  color: #ffffff;
  text-align: center;
}

.game-overlay[hidden] {
  display: none;
}

.game-overlay strong {
  font-size: 2.7rem;
}

.weird-chant {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
  filter: drop-shadow(0 7px 0 rgba(0, 0, 0, 0.24));
}

.weird-chant b {
  display: inline-block;
  color: var(--yellow);
  font-family: "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "PingFang SC", sans-serif;
  font-size: 4.7rem;
  font-weight: 950;
  -webkit-text-stroke: 2px #172033;
  opacity: 0;
  animation: chant-duang 700ms cubic-bezier(0.2, 1.45, 0.35, 1) forwards;
}

.weird-chant b:nth-child(2) { animation-delay: 65ms; }
.weird-chant b:nth-child(3) { animation-delay: 130ms; }
.weird-chant b:nth-child(4) { animation-delay: 195ms; }
.weird-chant b:nth-child(5) { animation-delay: 260ms; }
.weird-chant b:nth-child(6) { animation-delay: 325ms; }
.weird-chant b:nth-child(7) { animation-delay: 390ms; }
.weird-chant b:nth-child(8) { animation-delay: 455ms; }
.weird-chant b:nth-child(9) { animation-delay: 520ms; }

@keyframes chant-duang {
  0% { opacity: 0; scale: 0.05; translate: 0 -42px; }
  48% { opacity: 1; scale: 1.34 0.78; translate: 0 7px; }
  68% { scale: 0.88 1.16; translate: 0 -5px; }
  84% { scale: 1.08 0.94; translate: 0 2px; }
  100% { opacity: 1; scale: 1; translate: 0 0; }
}

.weird-chant.long b {
  font-size: 3rem;
}

.weird-chant b:nth-child(1) { transform: translateY(8px) rotate(-12deg); color: #ff729c; }
.weird-chant b:nth-child(2) { transform: translateY(-9px) rotate(8deg); color: #ffd447; }
.weird-chant b:nth-child(3) { transform: translateY(5px) rotate(-5deg) scale(1.12); color: #65d68b; }
.weird-chant b:nth-child(4) { transform: translateY(-7px) rotate(11deg); color: #42d9e8; }
.weird-chant b:nth-child(5) { transform: translateY(9px) rotate(-8deg) scale(1.08); color: #ff9f43; }
.weird-chant b:nth-child(6) { transform: translateY(-3px) rotate(13deg); color: #c89cff; }
.weird-chant b:nth-child(7) { transform: translateY(7px) rotate(-10deg) scale(1.08); color: #ff729c; }
.weird-chant b:nth-child(8) { transform: translateY(-8px) rotate(7deg); color: #ffd447; }
.weird-chant b:nth-child(9) { transform: translateY(5px) rotate(-7deg) scale(1.12); color: #65d68b; }

.game-overlay span {
  margin: 10px 0 24px;
  color: #bdc8d7;
}

.result-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.secondary-command {
  display: none;
  min-height: 46px;
  border: 1px solid rgba(224, 249, 246, 0.5);
  padding: 0 22px;
  background: rgba(5, 22, 34, 0.9);
  color: #ffffff;
  font-weight: 900;
  touch-action: manipulation;
}

.dragon-info {
  color: #e9fff8;
}

.dragon-info .game-kicker {
  color: #89e8bd;
}

.evolution-progress {
  width: 100%;
  margin-top: 28px;
}

.evolution-progress > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #8ea4b6;
  font-size: 0.68rem;
}

.evolution-progress > div:first-child strong {
  color: #d9f8eb;
  font-size: 0.8rem;
}

.evolution-meter {
  height: 8px;
  margin: 9px 0 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: #0d2230;
}

.evolution-meter i {
  display: block;
  width: 0;
  height: 100%;
  background: #65d68b;
  box-shadow: 0 0 14px rgba(101, 214, 139, 0.62);
  transition: width 200ms ease;
}

.evolution-progress small {
  color: #718a9c;
  font-size: 0.64rem;
}

.evolution-progress small strong {
  color: #a9d9c1;
}

.dragon-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.swim-joystick {
  position: relative;
  width: 96px;
  height: 96px;
  flex: 0 0 96px;
  border: 1px solid rgba(211, 249, 244, 0.36);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(96, 226, 210, 0.13) 0 48%, transparent 50%),
    rgba(5, 26, 38, 0.58);
  box-shadow: inset 0 0 24px rgba(109, 238, 220, 0.1), 0 8px 24px rgba(0, 10, 20, 0.28);
  pointer-events: auto;
  touch-action: none;
}

.joystick-ring {
  position: absolute;
  inset: 13px;
  border: 1px solid rgba(190, 246, 237, 0.18);
  border-radius: 50%;
}

.joystick-ring::before,
.joystick-ring::after {
  content: "";
  position: absolute;
  background: rgba(208, 252, 245, 0.13);
}

.joystick-ring::before {
  top: 50%;
  right: 6px;
  left: 6px;
  height: 1px;
}

.joystick-ring::after {
  top: 6px;
  bottom: 6px;
  left: 50%;
  width: 1px;
}

.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(232, 255, 252, 0.72);
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(124, 232, 219, 0.95), rgba(28, 116, 130, 0.96));
  box-shadow: inset 0 2px 8px rgba(255, 255, 255, 0.3), 0 5px 14px rgba(0, 12, 24, 0.4);
  transform: translate(-50%, -50%);
  transition: box-shadow 100ms ease;
  pointer-events: none;
}

.joystick-knob i {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(235, 255, 252, 0.78);
  border-radius: 50%;
}

.swim-joystick.active .joystick-knob {
  box-shadow: inset 0 2px 8px rgba(255, 255, 255, 0.4), 0 0 22px rgba(89, 240, 218, 0.55);
}

.defend-info {
  color: #fff8e4;
}

.defend-info .game-kicker {
  color: #ffca57;
}

.defend-wrap {
  background: #241625;
}

.defend-wrap canvas {
  cursor: crosshair;
}

.defend-top-controls {
  position: absolute;
  z-index: 15;
  top: 14px;
  right: 66px;
  display: flex;
  gap: 7px;
}

.defend-top-controls button {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border: 1px solid rgba(255, 226, 157, 0.44);
  padding: 0;
  background: rgba(32, 16, 30, 0.82);
  box-shadow: inset 0 0 14px rgba(255, 165, 77, 0.08), 0 6px 17px rgba(8, 4, 12, 0.26);
  color: #ffe19a;
  cursor: pointer;
  font-weight: 950;
  touch-action: manipulation;
}

.defend-top-controls button:active:not(:disabled) {
  border-color: #ffe27e;
  background: #9e3d38;
  color: #fffbd4;
}

.defend-top-controls button:disabled {
  opacity: 0.44;
}

.defend-actions {
  align-items: flex-end;
  justify-content: space-between;
}

.defend-joystick {
  position: relative;
  width: 102px;
  height: 102px;
  flex: 0 0 102px;
  border: 1px solid rgba(255, 237, 193, 0.42);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 194, 75, 0.14) 0 48%, transparent 50%),
    rgba(24, 21, 37, 0.62);
  box-shadow: inset 0 0 26px rgba(255, 173, 57, 0.12), 0 8px 26px rgba(0, 9, 18, 0.3);
  pointer-events: auto;
  touch-action: none;
}

.defend-joystick .joystick-knob {
  background: linear-gradient(145deg, rgba(255, 206, 92, 0.96), rgba(186, 58, 48, 0.96));
  border-color: rgba(255, 247, 214, 0.8);
}

.defend-joystick.active .joystick-knob {
  box-shadow: inset 0 2px 8px rgba(255, 255, 255, 0.42), 0 0 24px rgba(255, 158, 57, 0.62);
}

.defend-skills {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  pointer-events: auto;
}

.mobile-actions .defend-skill {
  position: relative;
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(255, 247, 219, 0.58);
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px rgba(13, 22, 34, 0.38), 0 6px 18px rgba(0, 8, 18, 0.34);
  color: #fff7da;
  font-size: 1.7rem;
}

.mobile-actions .defend-skill:nth-child(2) {
  width: 76px;
  height: 76px;
  font-size: 2rem;
}

.defend-skill.ring-skill {
  background: radial-gradient(circle, #f9d768 0 18%, #b94b3e 20% 44%, #3e1832 47% 100%);
}

.defend-skill.dash-skill {
  background: radial-gradient(circle, #fff0a8 0 12%, #e04a34 34%, #5b1727 72%);
}

.defend-skill.flame-skill {
  background: radial-gradient(circle, #fff1a1 0 13%, #f47726 32%, #7f1f2c 72%);
}

.mobile-actions .defend-skill:disabled {
  filter: grayscale(0.45) brightness(0.62);
  opacity: 0.84;
}

.mobile-actions .defend-skill:active:not(:disabled) {
  scale: 0.91;
  background-color: #ffcd50;
}

.defend-skill small {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 17px;
  padding-top: 1px;
  background: rgba(8, 14, 24, 0.78);
  color: #fff;
  font-size: 0.62rem;
  line-height: 16px;
}

.defend-upgrade {
  --tier-color: #62b8ff;
  position: absolute;
  z-index: 24;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 2.3vw, 24px);
  background:
    linear-gradient(rgba(5, 8, 18, .56), rgba(5, 8, 18, .94)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 12px),
    rgba(7, 12, 22, 0.94);
  backdrop-filter: blur(8px) saturate(0.72);
}

.defend-upgrade[hidden] {
  display: none;
}

.defend-upgrade::before,
.defend-upgrade::after {
  position: absolute;
  top: 8%;
  bottom: 8%;
  width: 1px;
  background: linear-gradient(transparent, rgba(255, 219, 135, .34), transparent);
  content: "";
}

.defend-upgrade::before { left: 6%; }
.defend-upgrade::after { right: 6%; }

.defend-upgrade-title {
  position: relative;
  z-index: 1;
  display: block !important;
  width: min(760px, 92%);
  margin-bottom: 13px;
  text-align: center;
}

.defend-upgrade-title::before,
.defend-upgrade-title::after {
  position: absolute;
  top: 50%;
  width: 22%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 216, 121, .62));
  content: "";
}

.defend-upgrade-title::before { left: 0; }
.defend-upgrade-title::after { right: 0; transform: scaleX(-1); }

.defend-upgrade-title small,
.defend-upgrade-title strong,
.defend-upgrade-title span {
  display: block;
}

.defend-upgrade-title small {
  margin-bottom: 2px;
  color: #f2c46e;
  font-size: .58rem;
  font-weight: 900;
}

.defend-upgrade-title strong {
  color: #fff2bd;
  font-family: Georgia, "STKaiti", serif;
  font-size: clamp(1.35rem, 3vw, 2rem);
  text-shadow: 0 3px 18px rgba(255, 166, 61, .36);
}

.defend-upgrade-title span {
  margin-top: 2px;
  color: #bac4d0;
  font-size: .68rem;
  font-weight: 750;
}

.defend-upgrade > #defendUpgradeChoices {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(790px, 94%);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 1.5vw, 14px);
}

.defend-upgrade-card {
  --tier-color: #62b8ff;
  --tier-deep: #1c5f97;
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 292px;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--tier-color), white 22%);
  border-bottom: 5px solid var(--tier-deep);
  border-radius: 7px;
  padding: 12px 13px 13px;
  background:
    radial-gradient(circle at 50% 23%, color-mix(in srgb, var(--tier-color), transparent 68%), transparent 28%),
    linear-gradient(162deg, rgba(32, 40, 53, .98), rgba(12, 17, 28, .99) 60%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .035), 0 14px 35px rgba(0, 2, 9, .48), 0 0 18px color-mix(in srgb, var(--tier-color), transparent 82%);
  color: #fff;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  transition: translate 150ms ease, box-shadow 150ms ease;
}

.defend-upgrade-card.green { --tier-color: #67d18b; --tier-deep: #277a49; }
.defend-upgrade-card.blue { --tier-color: #5cb8ff; --tier-deep: #205e9a; }
.defend-upgrade-card.purple { --tier-color: #c27cf5; --tier-deep: #6b35a0; }
.defend-upgrade-card.gold { --tier-color: #ffd05d; --tier-deep: #a7651c; }

.defend-upgrade-card.gold {
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 218, 103, .34), transparent 30%),
    linear-gradient(162deg, #3a2c22, #151821 63%);
  animation: defend-gold-card 1.8s ease-in-out infinite;
}

.defend-upgrade-card:active {
  translate: 0 3px;
  border-bottom-width: 3px;
}

.defend-upgrade-card small,
.defend-upgrade-card i,
.defend-upgrade-card em,
.defend-upgrade-card b,
.defend-upgrade-card strong,
.defend-upgrade-card span {
  display: block;
}

.defend-card-rarity {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  color: var(--tier-color);
  font-size: 0.64rem;
  font-weight: 900;
}

.defend-card-rarity span,
.defend-card-rarity b {
  margin: 0;
  color: inherit;
  font-size: inherit;
}

.defend-upgrade-card i {
  display: grid;
  width: 66px;
  height: 66px;
  place-items: center;
  margin: 8px auto 5px;
  border: 3px double color-mix(in srgb, var(--tier-color), white 22%);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, .9) 0 6%, transparent 8%),
    conic-gradient(from 35deg, color-mix(in srgb, var(--tier-color), white 24%), var(--tier-deep), #eef5ff, var(--tier-color));
  box-shadow: 0 0 19px color-mix(in srgb, var(--tier-color), transparent 48%);
  color: #fffce9;
  font-family: Georgia, serif;
  font-size: 1.72rem;
  font-style: normal;
  text-shadow: 0 2px 7px var(--tier-deep);
}

.defend-upgrade-card em {
  color: var(--tier-color);
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 900;
  text-align: center;
}

.defend-upgrade-card .defend-card-name {
  margin: 1px 0 7px;
  color: #fff8e5;
  font-family: Georgia, "STKaiti", serif;
  font-size: 1rem;
  text-align: center;
}

.defend-upgrade-card .defend-card-desc {
  min-height: 42px;
  color: #bfc8d1;
  font-size: .65rem;
  font-weight: 650;
  line-height: 1.55;
}

.defend-upgrade-card .defend-card-effect {
  margin-top: 7px;
  border-left: 3px solid var(--tier-color);
  padding: 6px 7px;
  background: color-mix(in srgb, var(--tier-color), transparent 89%);
  color: #fff7d4;
  font-size: .69rem;
}

.defend-upgrade-card .defend-card-stat {
  margin-top: 5px;
  color: #8e9aa8;
  font-size: .56rem;
  font-weight: 750;
}

.defend-upgrade-card .defend-card-pick {
  margin-top: auto;
  padding-top: 9px;
  color: var(--tier-color);
  font-size: .62rem;
  font-weight: 950;
  text-align: center;
}

.defend-reroll {
  position: relative;
  z-index: 2;
  min-width: 146px;
  min-height: 38px;
  margin-top: 12px;
  border: 1px solid rgba(220, 228, 239, .3);
  border-radius: 5px;
  background: rgba(25, 32, 43, .92);
  color: #dce6ef;
  cursor: pointer;
  font-weight: 900;
  touch-action: manipulation;
}

.defend-reroll span { color: #ffcc68; font-size: 1rem; }

.defend-reroll:disabled {
  opacity: 0.38;
}

@keyframes defend-gold-card {
  50% { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .06), 0 14px 38px rgba(0, 2, 9, .52), 0 0 28px rgba(255, 196, 68, .3); }
}

.expanded-game-menu {
  display: none;
}

.expanded-menu-toggle,
.expanded-menu-panel button {
  border: 1px solid rgba(219, 248, 245, 0.3);
  background: rgba(5, 22, 34, 0.88);
  color: #ffffff;
  cursor: pointer;
  touch-action: manipulation;
}

.expanded-menu-toggle {
  display: flex;
  min-width: 108px;
  height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  box-shadow: 0 8px 24px rgba(0, 8, 18, 0.32);
}

.expanded-menu-toggle > span {
  color: var(--cyan);
  font-size: 1.2rem;
}

.expanded-menu-toggle strong {
  font-size: 0.78rem;
}

.expanded-menu-toggle.has-result {
  border-color: rgba(255, 212, 71, 0.75);
  animation: menu-attention 1.1s ease-in-out 2;
}

@keyframes menu-attention {
  50% { box-shadow: 0 0 0 5px rgba(255, 212, 71, 0.16), 0 8px 24px rgba(0, 8, 18, 0.32); }
}

.expanded-menu-panel {
  display: grid;
  width: 184px;
  gap: 5px;
  margin-top: 7px;
  padding: 6px;
  border: 1px solid rgba(215, 248, 244, 0.2);
  background: rgba(3, 18, 29, 0.94);
  box-shadow: 0 16px 34px rgba(0, 8, 18, 0.45);
}

.expanded-menu-panel[hidden] {
  display: none;
}

.expanded-menu-panel button {
  display: grid;
  min-height: 44px;
  grid-template-columns: 30px 1fr;
  align-items: center;
  padding: 0 12px;
  text-align: left;
}

.expanded-menu-panel button span {
  color: #6f8593;
  font-size: 0.64rem;
  font-weight: 900;
}

.expanded-menu-panel button.active,
.expanded-menu-panel button:active {
  border-color: rgba(89, 235, 216, 0.65);
  background: rgba(31, 115, 121, 0.75);
}

.rotate-prompt {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #0c1421;
  color: #ffffff;
  text-align: center;
}

.rotate-prompt[hidden] {
  display: none;
}

.rotate-prompt > span {
  color: var(--yellow);
  font-size: 4rem;
  font-weight: 900;
}

.rotate-prompt strong {
  font-size: 1.45rem;
}

.rotate-prompt button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0 18px;
  background: #182235;
  color: #ffffff;
  font-weight: 800;
}

body.expanded-game {
  overflow: hidden;
}

body.expanded-game .site-head,
body.expanded-game .game-nav,
body.expanded-game .game-info,
body.expanded-game .site-foot {
  display: none;
}

body.expanded-game .expanded-game-menu {
  position: fixed;
  z-index: 40;
  top: max(10px, env(safe-area-inset-top));
  left: max(clamp(18px, 3vw, 34px), env(safe-area-inset-left));
  display: block;
}

body.expanded-game .secondary-command {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.expanded-game .arcade-shell {
  width: 100%;
  height: 100dvh;
  padding: 0;
}

body.expanded-game .game-screen.active {
  display: block;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  border: 0;
}

body.expanded-game .game-screen.active > [data-play-area] {
  width: 100%;
  height: 100%;
  min-height: 0;
}

body.expanded-game .canvas-wrap canvas {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
}

body.expanded-dragon-portrait .dragon-wrap {
  background: #052b3b;
}

body.expanded-dragon-portrait .dragon-wrap > #dragonCanvas {
  width: min(100vw, 56.25vh);
  height: min(100vh, 177.78vw);
  max-width: 100%;
  max-height: 100%;
  inset: 50% auto auto 50%;
  translate: -50% -50%;
  object-fit: contain;
}

body.expanded-game .canvas-wrap {
  display: grid;
  place-items: center;
}

body.expanded-game .canvas-wrap canvas {
  position: absolute;
  inset: 0;
}

body.expanded-game .tile-playfield {
  grid-template-rows: minmax(0, 1fr) auto;
}

body.expanded-game .tile-board {
  width: min(82%, 118vh, 920px);
  height: auto;
  max-height: none;
  aspect-ratio: 16 / 9;
  transform: translateY(3px);
}

body.expanded-game .tray-area {
  min-height: 90px;
  padding: 6px 16px 8px;
}

body.expanded-game .tray-area p {
  margin-bottom: 4px;
}

body.expanded-game .tile-tray {
  grid-template-columns: repeat(7, minmax(36px, 52px));
  min-height: 58px;
  gap: 4px;
  padding: 5px;
}

body.expanded-game .fullscreen-toggle {
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
}

body.expanded-game .mobile-actions {
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  left: max(12px, env(safe-area-inset-left));
}

body.expanded-game .runner-actions {
  right: max(clamp(56px, 8vw, 96px), env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  left: max(clamp(56px, 8vw, 96px), env(safe-area-inset-left));
  justify-content: space-between;
}

body.expanded-game .runner-actions button {
  width: 74px;
  height: 74px;
  font-size: 1.75rem;
}

body.expanded-game .dragon-actions {
  right: max(clamp(46px, 6vw, 78px), env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  left: max(clamp(46px, 6vw, 78px), env(safe-area-inset-left));
}

body.expanded-game .defend-actions {
  right: max(clamp(44px, 6vw, 76px), env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  left: max(clamp(44px, 6vw, 76px), env(safe-area-inset-left));
}

body.expanded-game .defend-joystick {
  width: clamp(108px, 28vh, 130px);
  height: clamp(108px, 28vh, 130px);
  flex-basis: clamp(108px, 28vh, 130px);
}

body.expanded-game .defend-skill {
  width: clamp(68px, 17vh, 82px);
  height: clamp(68px, 17vh, 82px);
}

body.expanded-game .defend-skill:nth-child(2) {
  width: clamp(78px, 20vh, 94px);
  height: clamp(78px, 20vh, 94px);
}

body.expanded-game .swim-joystick {
  width: clamp(104px, 27vh, 124px);
  height: clamp(104px, 27vh, 124px);
  flex-basis: clamp(104px, 27vh, 124px);
}

body.expanded-game .joystick-knob {
  width: clamp(50px, 13vh, 60px);
  height: clamp(50px, 13vh, 60px);
}

@media (orientation: portrait) and (max-width: 980px) {
  body.expanded-game:not(.expanded-dragon-portrait) .rotate-prompt {
    display: flex;
  }
}

@media (orientation: landscape) and (max-height: 980px) {
  body.expanded-dragon-portrait .rotate-prompt {
    display: flex;
  }
}

.site-foot {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  color: #627086;
  font-size: 0.72rem;
}

@media (max-width: 980px) {
  .home-lobby { border-width: 8px; }
  .home-lobby::before { inset-block-start: 68px; }
  .home-head { width: calc(100% - 32px); min-height: 66px; }
  .home-records > span { display: none; }
  .home-stage {
    width: calc(100% - 34px);
    min-height: calc(100dvh - 82px);
    grid-template-columns: minmax(210px, 0.62fr) minmax(0, 1.38fr);
    gap: 22px;
    padding: 24px 0;
  }
  .home-title-block { min-height: 270px; padding: 28px 24px; }
  .home-title-block h1 { font-size: 3.4rem; }
  .home-games { height: min(68vh, 600px); min-height: 450px; gap: 11px; }
  .home-game-card { border-width: 4px; box-shadow: 5px 5px 0 #151821; }
  .home-game-copy { right: 49px; bottom: 12px; left: 12px; }
  .home-game-copy strong { font-size: 1.12rem; }
  .home-game-copy > span { display: none; }
  .home-play { right: 11px; bottom: 12px; width: 37px; height: 37px; }

  .game-screen {
    grid-template-columns: 1fr;
  }

  .game-info {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 16px 26px;
    border-right: 0;
    border-bottom: 1px solid var(--game-border);
    padding: 28px;
  }

  .game-info > div:first-child {
    grid-row: span 2;
  }

  .game-info h1 {
    font-size: 2.3rem;
  }

  .hud-block {
    min-width: 330px;
    margin: 0;
  }

  .key-guide,
  .evolution-progress {
    display: none;
  }

  .tool-row {
    justify-self: end;
  }

  .canvas-wrap {
    min-height: 0;
  }

  .tile-playfield {
    min-height: 590px;
  }
}

@media (max-width: 720px) {
  .home-lobby { min-height: 100dvh; border-width: 6px; overflow: auto; }
  .home-lobby::before { inset-block-start: 67px; height: 4px; }
  .home-head { width: calc(100% - 24px); min-height: 65px; }
  .home-brand { gap: 9px; }
  .home-brand-mascot { width: 42px; height: 42px; box-shadow: 3px 3px 0 #151821; }
  .home-brand strong { font-size: 0.96rem; }
  .home-stage {
    display: block;
    width: calc(100% - 26px);
    min-height: 0;
    padding: 52px 0 34px;
  }
  .home-title-block {
    width: calc(100% - 8px);
    min-height: 232px;
    margin: 0 0 25px;
    padding: 24px 24px 22px;
    border-width: 4px;
    box-shadow: 7px 7px 0 #ee5360;
  }
  .home-title-block h1 { font-size: 2.8rem; line-height: 1; }
  .home-title-block > strong { margin-top: 17px; font-size: 0.74rem; }
  .home-burst { top: -35px; right: 12px; border-width: 3px; padding: 6px 11px; font-size: 0.98rem; }
  .cute-face { right: 16px; bottom: 15px; transform: scale(.82) rotate(-7deg); }
  .home-games { height: auto; min-height: 0; grid-template-rows: repeat(4, 190px); grid-template-columns: 1fr; gap: 14px; }
  .home-game-card:nth-child(2), .home-game-card:nth-child(3) { transform: none; }
  .home-game-card:nth-child(2):active, .home-game-card:nth-child(3):active { transform: translate(3px, 3px); }
  .home-game-copy strong { max-width: 100%; font-size: 1.35rem; }
  .home-game-copy > span { display: block; }
  .sticker-star { top: 24px; left: -4px; transform: scale(.75) rotate(-12deg); }
  .sticker-bolt { display: none; }
  .sticker-heart { right: -7px; bottom: 12px; }
  .sticker-flower { display: none; }

  .site-head,
  .arcade-shell,
  .site-foot {
    width: min(100% - 20px, 1440px);
  }

  .site-head {
    min-height: 74px;
  }

  .record-strip {
    display: none;
  }

  .head-actions {
    gap: 0;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .game-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 6px;
  }

  .game-tab {
    min-height: 76px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    padding: 10px 12px;
  }

  .game-tab:nth-child(odd) {
    border-right: 1px solid rgba(255, 255, 255, 0.14);
  }

  .game-tab small {
    display: none;
  }

  .game-info {
    display: flex;
    align-items: flex-start;
    padding: 25px 20px 27px;
  }

  .game-screen { border-radius: 4px; }

  .game-kicker { margin-bottom: 8px; }

  .game-info h1 {
    margin-bottom: 12px;
    font-size: 2rem;
    max-width: 100%;
    overflow-wrap: anywhere;
    line-height: 1.08;
  }

  .weird-chant b {
    font-size: 3.2rem;
  }

  .weird-chant.long b {
    font-size: 2rem;
  }

  .hud-block {
    width: 100%;
    min-width: 0;
    margin: 18px 0 17px;
  }

  .hud-block span {
    min-height: 55px;
  }

  .primary-command { min-height: 50px; }

  .tool-row {
    align-self: stretch;
  }

  .tool-row .primary-command {
    flex: 1;
  }

  .canvas-wrap canvas {
    min-height: 0;
  }

  .mobile-actions {
    right: 10px;
    bottom: 10px;
    left: 10px;
  }

  .runner-actions {
    justify-content: space-between;
  }

  .defend-skills {
    gap: 7px;
  }

  .defend-joystick {
    width: 92px;
    height: 92px;
    flex-basis: 92px;
  }

  .mobile-actions .defend-skill {
    width: 56px;
    height: 56px;
  }

  .mobile-actions .defend-skill:nth-child(2) {
    width: 66px;
    height: 66px;
  }

  .tile-playfield {
    min-height: 520px;
    grid-template-rows: minmax(345px, 1fr) auto;
  }

  .tile-board {
    width: 100%;
  }

  .food-emoji {
    font-size: 1.65rem;
  }

  .food-name {
    display: none;
  }

  .tray-area {
    min-height: 112px;
    padding: 10px 8px 12px;
  }

  .tile-tray {
    gap: 3px;
    padding: 5px;
  }

  .tray-tile .food-emoji {
    font-size: 1.35rem;
  }

}

@media (max-width: 390px) {
  .game-info h1 {
    font-size: 1.65rem;
  }

  .game-desc {
    font-size: 0.82rem;
  }

  .mobile-actions button { width: 54px; height: 54px; }
  .swim-joystick { width: 88px; height: 88px; flex-basis: 88px; }
}

@media (orientation: landscape) and (max-height: 430px) {
  .defend-upgrade {
    padding: 7px 34px 8px;
  }

  .defend-upgrade-title {
    margin-bottom: 5px;
  }

  .defend-upgrade-title small {
    display: none;
  }

  .defend-upgrade-title strong {
    font-size: 1.2rem;
    line-height: 1.1;
  }

  .defend-upgrade-title span {
    font-size: .55rem;
  }

  .defend-upgrade > #defendUpgradeChoices {
    width: min(760px, 92%);
    gap: 7px;
  }

  .defend-upgrade-card {
    min-height: 0;
    height: 252px;
    padding: 7px 9px 8px;
  }

  .defend-upgrade-card i {
    width: 46px;
    height: 46px;
    margin: 3px auto 2px;
    font-size: 1.3rem;
  }

  .defend-upgrade-card .defend-card-name {
    margin-bottom: 3px;
    font-size: .84rem;
  }

  .defend-upgrade-card .defend-card-desc {
    min-height: 32px;
    font-size: .54rem;
    line-height: 1.4;
  }

  .defend-upgrade-card .defend-card-effect {
    margin-top: 4px;
    padding: 4px 5px;
    font-size: .57rem;
  }

  .defend-upgrade-card .defend-card-stat {
    font-size: .5rem;
  }

  .defend-upgrade-card .defend-card-pick {
    padding-top: 4px;
    font-size: .53rem;
  }

  .defend-reroll {
    min-height: 31px;
    margin-top: 5px;
    font-size: .64rem;
  }

  body.expanded-game .in-game-result-actions {
    top: calc(50% + 54px);
  }

  body.expanded-game .in-game-replay,
  body.expanded-game .in-game-switch {
    min-width: 124px;
    min-height: 48px;
    padding: 0 16px;
  }

  body.expanded-game .runner-actions button {
    width: 76px;
    height: 76px;
  }
}
