:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  color: #f4f6e9;
  background: #b2e0e1;
  --ink: #24331c;
  --mint: #d9ee91;
  --muted: #aebfaf;
  --glass: rgba(20, 35, 26, 0.8);
  --glass-border: rgba(226, 247, 222, 0.18);
  --leaf: #49682b;
  --panel-outline: #e3e3c0;
  --edge: clamp(14px, 3vw, 38px);
  --safe-top: max(var(--edge), env(safe-area-inset-top, 0px));
  --safe-left: max(var(--edge), env(safe-area-inset-left, 0px));
  --safe-right: max(var(--edge), env(safe-area-inset-right, 0px));
  --hud-bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 8px));
  --slot-height: clamp(38px, 10vw, 56px);
  --hud-gap: 8px;
  --touch-size: clamp(44px, 12vw, 54px);
  --touch-gap: 6px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  appearance: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 4px;
}

.game-shell, #game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#game, #game canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.game-shell:has(#game.is-hit)::after {
  position: absolute;
  z-index: 1;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 38%, #ad302266 88%, #ad3022aa);
  content: "";
  pointer-events: none;
}

.topbar {
  --glass: rgba(255, 253, 229, 0.86);
  --glass-border: rgba(255, 255, 240, 0.75);
  position: absolute;
  z-index: 6;
  top: var(--safe-top);
  left: var(--safe-left);
  right: var(--safe-right);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  color: var(--ink);
  pointer-events: none;
}

.brand {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  padding: 7px 15px 7px 7px;
  min-height: 52px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(12, 23, 16, 0.14);
  backdrop-filter: blur(12px);
}

.brand-mark, .intro-mark {
  display: grid;
  flex: none;
  place-items: center;
  background: var(--mint);
  color: var(--ink);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
}

.brand-mark:empty::before, .intro-mark:empty::before {
  width: 52%;
  aspect-ratio: 0.9;
  clip-path: polygon(50% 0, 100% 22%, 100% 75%, 50% 100%, 0 75%, 0 22%);
  background: conic-gradient(from 60deg at 50% 47%, #2c462b 0 120deg, #426045 120deg 240deg, #6d8651 240deg);
  content: "";
}

.brand-copy strong {
  font-size: 15px;
  letter-spacing: 0.09em;
  line-height: 1.3;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--glass);
  box-shadow: 0 6px 24px rgba(12, 23, 16, 0.14);
  backdrop-filter: blur(12px);
  min-width: 42px;
  padding: 0 11px;
  transition: border-color 150ms, background 150ms;
}

.icon-button:hover {
  background: #f1f5d4;
  border-color: #b2bd8e;
}

.mouse-lock-button {
  flex: none;
  padding-inline: 12px;
  color: var(--leaf);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.online-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 9px;
  border: 1px solid var(--glass-border);
  border-radius: 9px;
  background: var(--glass);
  color: var(--leaf);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.online-indicator::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.topbar button:focus-visible, .overlay button:focus-visible {
  outline-color: var(--leaf);
}

#hud {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
}

.world-info {
  position: absolute;
  top: calc(var(--safe-top) + 64px);
  left: var(--safe-left);
  display: grid;
  gap: 3px;
  width: max-content;
  padding: 9px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 9px;
  background: var(--glass);
  backdrop-filter: blur(12px);
}

.coordinates {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.health-hud {
  display: grid;
  gap: 5px;
  min-width: clamp(115px, 21vw, 154px);
  margin-top: 5px;
  color: #ffe6da;
  font-size: 11px;
}

.health-label {
  display: flex;
  justify-content: space-between;
  gap: 9px;
}

.health-text {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.health-track {
  height: 7px;
  overflow: hidden;
  border: 1px solid #ffdec333;
  border-radius: 10px;
  background: #130e0f99;
}

.health-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e8755c, #ffc18c);
  transition: width 160ms ease-out;
}

.crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 23px;
  height: 23px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 1px 1px #11291b);
}

.crosshair::before, .crosshair::after {
  position: absolute;
  inset: 50% auto auto 50%;
  border-radius: 2px;
  transform: translate(-50%, -50%);
  background: #f9ffef;
  content: "";
}

.crosshair::before {
  width: 17px;
  height: 2px;
}

.crosshair::after {
  width: 2px;
  height: 17px;
}

#hud.has-target .crosshair::before, #hud.has-target .crosshair::after {
  background: #ffb084;
}

.respawn-status {
  position: absolute;
  top: 45%;
  left: 50%;
  z-index: 1;
  width: max-content;
  max-width: calc(100% - var(--safe-left) - var(--safe-right));
  padding: 12px clamp(14px, 4vw, 24px);
  transform: translate(-50%, -50%);
  border: 1px solid #ffd4b070;
  border-radius: 12px;
  background: #3d2421ec;
  box-shadow: 0 8px 32px #1f272333;
  color: #fff1dd;
  font-size: clamp(14px, 3.5vw, 18px);
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

#hud:has(.respawn-status:not([hidden])) .crosshair {
  visibility: hidden;
}

.bottom-hud {
  position: absolute;
  right: var(--safe-right);
  bottom: var(--hud-bottom);
  left: var(--safe-left);
  display: grid;
  justify-items: center;
  gap: var(--hud-gap);
}

.selection-name {
  display: flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 7px;
  background: var(--glass);
  color: #e9f0e5;
  font-size: 12px;
  letter-spacing: 0.05em;
}

.hotbar {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  width: min(100%, 560px);
  gap: clamp(3px, 0.75vw, 6px);
  padding: 6px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: var(--glass);
  box-shadow: 0 12px 35px #0c1d1740;
  backdrop-filter: blur(12px);
  pointer-events: auto;
}

.slot {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  height: var(--slot-height);
  padding: 0;
  border: 1px solid rgba(222, 242, 211, 0.12);
  border-radius: 8px;
  background: rgba(235, 249, 229, 0.06);
  transition: border-color 120ms, background-color 120ms;
  touch-action: manipulation;
}

.slot:hover {
  border-color: #a6c0a0;
}

.slot.active, .slot.selected, .slot.is-selected, .slot[aria-pressed="true"], .slot[aria-selected="true"] {
  border-color: var(--mint);
  background: rgba(217, 251, 134, 0.2);
  box-shadow: inset 0 0 0 1px rgba(217, 251, 134, 0.23);
}

.slot-key {
  position: absolute;
  top: 4px;
  left: 6px;
  color: #ccdac7;
  font-size: 10px;
  line-height: 1;
}

.block-icon {
  display: block;
  width: clamp(17px, 4.5vw, 30px);
  max-width: 70%;
  height: clamp(20px, 5.2vw, 34px);
  margin-top: 4px;
  overflow: hidden;
  clip-path: polygon(50% 0, 100% 23%, 100% 74%, 50% 100%, 0 74%, 0 23%);
  background-color: var(--block-color, #89a65f);
  background-image:
    linear-gradient(90deg, transparent 50%, #15221130 50%),
    repeating-linear-gradient(0deg, #ffffff0c 0 3px, #17230d1a 3px 5px);
}

.block-icon::before {
  display: block;
  width: 100%;
  height: 49%;
  clip-path: polygon(50% 0, 100% 47%, 50% 100%, 0 47%);
  background: linear-gradient(132deg, #ffffff68, #ffffff30);
  content: "";
}

.desktop-hint {
  color: #f2f6e9;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-align: center;
  text-shadow: 0 1px 4px #142619, 0 1px 8px #142619;
}

.overlay {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: flex;
  padding: calc(var(--safe-top) + 56px) var(--safe-right) var(--hud-bottom) var(--safe-left);
  overflow: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(ellipse at 72% 5%, #fff0b72e, transparent 60%),
    linear-gradient(0deg, #254d3d45, transparent 68%);
}

.intro-card, .help-card, .lobby-card {
  flex: none;
  width: min(100%, 416px);
  margin: auto;
  padding: clamp(23px, 4vw, 37px);
  border: 1px solid #ffffeccf;
  border-radius: 23px;
  background: linear-gradient(150deg, #fffcebea, #f5f6dff2 76%);
  color: var(--ink);
  box-shadow: 0 24px 70px #284b3a33, inset 0 1px 0 #ffffff99;
  backdrop-filter: blur(13px);
}

.intro-card {
  display: grid;
  justify-items: center;
  text-align: center;
}

.intro-mark {
  width: 60px;
  height: 60px;
  margin-bottom: 20px;
  border: 1px solid #e7eea9;
  border-radius: 14px;
  box-shadow: 0 4px 0 #a5bd69, 0 9px 24px #515e362e;
  font-size: 30px;
  line-height: 1;
}

.intro-title {
  margin: 0;
  font-size: clamp(35px, 7vw, 58px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.075em;
  text-indent: 0.075em;
}

.intro-title em {
  color: var(--leaf);
  font-style: normal;
}

.intro-copy {
  margin: 13px 0 26px;
  color: #4c5b3f;
  font-size: 14px;
  line-height: 1.65;
}

.primary-button, .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 11px 17px;
  border: 1px solid #bdce76;
  border-radius: 10px;
  background: linear-gradient(110deg, #e0ed9c, #f0ee9e);
  color: var(--ink);
  box-shadow: 0 4px 0 #a7bc69;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: background 140ms, box-shadow 140ms, transform 140ms;
}

.primary-button:enabled:hover {
  background: #f3f3ae;
}

.primary-button:enabled:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #a7bc69;
}

.secondary-button {
  border-color: #d4dcb3;
  background: #fffce3;
  box-shadow: none;
  color: var(--leaf);
  letter-spacing: normal;
}

.secondary-button:enabled:hover {
  border-color: #a6b676;
  background: #eef2d1;
}

.primary-button:disabled, .secondary-button:disabled {
  border-color: #d9dcbe;
  background: #e9ead6;
  box-shadow: none;
  color: #666c55;
  cursor: default;
}

.entry-actions, .lobby-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

.entry-actions > button, .lobby-actions > button {
  flex: 1 1 108px;
  width: auto;
  min-width: 0;
}

.intro-instructions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 13px;
  margin: 19px 0 0;
  color: #5b644a;
  font-size: 11px;
  line-height: 1.55;
}

kbd {
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  margin-right: 3px;
  padding: 0 5px;
  border: 1px solid var(--panel-outline);
  border-radius: 4px;
  background: #ffffebbe;
  color: #414e32;
  font: inherit;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

#lobby.overlay, #help.overlay {
  z-index: 8;
  padding-top: var(--safe-top);
  background: #233b3266;
}

.help-card, .lobby-card {
  --glass: #fffde8;
  --glass-border: var(--panel-outline);
  --muted: #5b644a;
  position: relative;
}

.lobby-card {
  display: grid;
  gap: 15px;
  width: min(100%, 570px);
}

.lobby-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.lobby-header h2 {
  margin: 0 0 5px;
  font-size: 27px;
}

.lobby-header p, .lobby-status {
  margin: 0;
  color: #526145;
  font-size: 13px;
  line-height: 1.5;
}

.lobby-status {
  padding: 8px 11px;
  border: 1px solid var(--panel-outline);
  border-radius: 8px;
  background: #fffde9;
}

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

.role-card {
  display: grid;
  grid-template: auto auto / 34px minmax(0, 1fr);
  align-items: center;
  gap: 2px 8px;
  min-height: 64px;
  padding: 8px;
  border: 1px solid var(--panel-outline);
  border-radius: 10px;
  background: #fffcef;
  text-align: left;
}

.role-card:enabled:hover {
  border-color: #9caf70;
}

.role-card[aria-pressed="true"]:enabled {
  border-color: #668442;
  background: #eaf0c8;
  box-shadow: inset 0 0 0 1px #668442;
}

.role-card:disabled {
  background: #edecdf;
  cursor: default;
}

.role-avatar {
  grid-row: span 2;
  width: 34px;
  aspect-ratio: 1;
  border: 1px solid #4552404a;
  border-radius: 5px;
  background:
    linear-gradient(var(--role-accent, #df9d61) 0 30%, transparent 30%),
    linear-gradient(#283a2a 0 0) 29% 53% / 3px 4px no-repeat,
    linear-gradient(#283a2a 0 0) 66% 53% / 3px 4px no-repeat,
    linear-gradient(90deg, transparent 83%, #2d413f23 83%),
    linear-gradient(#f7d9ab 0 67%, var(--role-color, #82a661) 67%);
  box-shadow: 0 2px 0 #45524032;
}

.role-card:disabled .role-avatar {
  filter: saturate(0.45);
}

.role-name {
  align-self: end;
  font-size: 13px;
  font-weight: 700;
}

.role-status {
  align-self: start;
  color: #566049;
  font-size: 11px;
}

.invite-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.invite-row input {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid var(--panel-outline);
  border-radius: 8px;
  background: #fffcef;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.invite-row button {
  flex: none;
  width: auto;
  min-height: 44px;
  padding: 7px 10px;
  font-size: 13px;
}

.help-card h2 {
  margin: 0 44px 17px 0;
  font-size: 25px;
}

.help-card .icon-button {
  position: absolute;
  top: 18px;
  right: 18px;
}

.help-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #526145;
  font-size: 13px;
  line-height: 1.55;
}

.help-list > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--panel-outline);
}

.help-list > div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.help-list dd {
  margin: 0;
  color: var(--ink);
}

.save-status {
  margin: 18px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

#mobile-controls {
  position: absolute;
  --move-height: calc(var(--touch-size) * 2 + var(--touch-gap));
  --touch-bottom: calc(var(--hud-bottom) + var(--slot-height) + 54px);
  z-index: 3;
  inset: 0;
  pointer-events: none;
}

.move-pad, .touch-actions, .joystick, .touch-mode-switch {
  position: absolute;
  bottom: var(--touch-bottom);
}

.move-pad, .touch-actions {
  display: grid;
  gap: var(--touch-gap);
}

.move-pad {
  left: var(--safe-left);
  grid-template-columns: repeat(3, var(--touch-size));
}

.touch-actions {
  right: var(--safe-right);
  grid-template-columns: repeat(2, var(--touch-size));
}

.move-pad button, .touch-actions button, .touch-mode-switch, .joystick {
  display: grid;
  place-items: center;
  min-height: var(--touch-size);
  padding: 0 5px;
  border: 1px solid #dff5dc55;
  border-radius: 9px;
  background: #15291cd4;
  box-shadow: 0 4px 14px #0c20173d;
  font-size: 12px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.move-pad button:active, .touch-actions button:active, .touch-mode-switch:active {
  border-color: var(--mint);
  background: #46623b;
}

.joystick {
  left: var(--safe-left);
  width: var(--move-height);
  height: var(--move-height);
  padding: 0;
  border-radius: 50%;
  background: radial-gradient(circle, #dff5dc20 0 35%, #dff5dc44 36% 37%, #15291ca8 38%);
}

.joystick-thumb {
  width: 36%;
  aspect-ratio: 1;
  transform: translate(var(--stick-x, 0px), var(--stick-y, 0px));
  border: 1px solid #ecfac7a3;
  border-radius: 50%;
  background: #daeaa0d9;
  box-shadow: 0 2px 8px #192c17a6;
  pointer-events: none;
}

.touch-mode-switch {
  bottom: calc(var(--touch-bottom) + var(--move-height) + 8px);
  left: var(--safe-left);
  min-width: 60px;
  min-height: 44px;
  padding-inline: 9px;
  color: #f3fad9;
  touch-action: manipulation;
}

.move-pad button[data-move="forward"] {
  grid-area: 1 / 2;
}

.move-pad button[data-move="left"] {
  grid-area: 2 / 1;
}

.move-pad button[data-move="back"] {
  grid-area: 2 / 2;
}

.move-pad button[data-move="right"] {
  grid-area: 2 / 3;
}

.touch-actions button[data-action="jump"] {
  grid-area: 1 / 2;
}

.touch-actions button[data-action="attack"] {
  grid-area: 1 / 1;
  border-color: #ffbf8e99;
  background: #67311df0;
  color: #fff0d9;
}

.touch-actions button[data-action="attack"]:active {
  border-color: #ffb084;
  background: #8a4425;
}

.touch-actions button[data-action="mine"] {
  grid-area: 2 / 1;
}

.touch-actions button[data-action="place"] {
  grid-area: 2 / 2;
}

#toast {
  position: absolute;
  z-index: 9;
  bottom: calc(var(--hud-bottom) + var(--slot-height) + 82px);
  left: 50%;
  width: max-content;
  max-width: calc(100% - 30px);
  padding: 9px 15px;
  transform: translateX(-50%);
  border: 1px solid var(--glass-border);
  border-radius: 9px;
  background: #192b20ec;
  color: #f2f8e9;
  font-size: 12px;
  text-align: center;
  pointer-events: none;
}

.game-shell:has(#mobile-controls:not([hidden])) {
  --hud-gap: 6px;
}

.game-shell:has(#mobile-controls:not([hidden])) :is(.desktop-hint, .slot-key) {
  display: none;
}

.game-shell:has(#mobile-controls:not([hidden])) #toast {
  top: calc(var(--safe-top) + var(--toast-offset, 99px));
  bottom: auto;
}

.game-shell:has(#mobile-controls:not([hidden]) .touch-actions [data-action="attack"]:not([hidden])) {
  --toast-offset: 132px;
}

@media (max-width: 440px) {
  .brand {
    gap: 7px;
    min-height: 44px;
    padding: 5px 9px 5px 5px;
  }

  .brand-copy strong {
    font-size: 13px;
  }

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

  .world-info {
    top: calc(var(--safe-top) + 52px);
  }

  .icon-button {
    min-width: 42px;
    padding-inline: 7px;
  }

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

@media (max-width: 360px) {
  .topbar, .top-actions {
    gap: 5px;
  }

  .mouse-lock-button {
    padding-inline: 6px;
    font-size: 12px;
  }

  .online-indicator {
    padding-inline: 7px;
    font-size: 11px;
  }

  .entry-actions > button {
    padding-inline: 8px;
  }
}

@media (max-height: 540px) and (orientation: landscape) {
  :root {
    --hud-bottom: max(10px, calc(env(safe-area-inset-bottom, 0px) + 5px));
    --slot-height: 40px;
  }

  .overlay {
    padding-top: calc(var(--safe-top) + 47px);
  }

  .intro-card, .help-card, .lobby-card {
    padding: 16px 22px;
  }

  .intro-mark {
    width: 41px;
    height: 41px;
    margin-bottom: 11px;
  }

  .intro-title {
    font-size: 34px;
  }

  .intro-copy {
    margin: 8px 0 12px;
  }

  .intro-instructions {
    margin-top: 12px;
  }
}

@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  :root {
    --edge: clamp(10px, 2vw, 18px);
    --safe-left: max(var(--edge), calc(env(safe-area-inset-left, 0px) + 6px));
    --safe-right: max(var(--edge), calc(env(safe-area-inset-right, 0px) + 6px));
    --touch-size: clamp(44px, 6.2vw, 52px);
    --touch-gap: clamp(5px, 0.9vw, 8px);
    --slot-height: clamp(36px, 10vh, 44px);
  }

  .topbar {
    align-items: center;
  }

  .brand {
    min-height: 44px;
    gap: 8px;
    padding: 5px 10px 5px 5px;
  }

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

  .brand-copy strong {
    font-size: 13px;
  }

  .topbar .icon-button {
    min-width: 44px;
    min-height: 44px;
  }

  .online-indicator {
    min-height: 32px;
    font-size: 11px;
  }

  .world-info {
    top: calc(var(--safe-top) + 51px);
    padding: 6px 8px;
    gap: 1px;
  }

  .health-hud {
    min-width: 94px;
    gap: 3px;
    margin-top: 3px;
    font-size: 10px;
  }

  .health-track {
    height: 6px;
  }

  .intro-card {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    justify-items: stretch;
    gap: 6px 15px;
    text-align: start;
  }

  .intro-mark {
    grid-row: 1 / 3;
    margin: 0;
  }

  .intro-title {
    font-size: clamp(26px, 6vw, 34px);
  }

  .intro-copy {
    margin: 0;
  }

  .intro-card .entry-actions, .intro-instructions {
    grid-column: 1 / -1;
  }

  .intro-card .entry-actions {
    margin-top: 6px;
  }

  .intro-instructions {
    margin-top: 5px;
  }

  .lobby-card {
    gap: 8px;
    padding: 12px clamp(12px, 3vw, 22px);
  }

  .lobby-header h2 {
    margin-bottom: 2px;
    font-size: 22px;
  }

  .lobby-status {
    padding: 5px 8px;
  }

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

  .role-card {
    grid-template-columns: 28px minmax(0, 1fr);
    min-height: 47px;
    gap: 2px 6px;
    padding: 5px 6px;
  }

  .role-avatar {
    width: 28px;
  }

  .lobby-actions > button {
    min-height: 44px;
    padding: 6px 9px;
    font-size: 13px;
  }
}

@media (orientation: landscape) and (min-width: 480px) and (max-height: 540px) and (pointer: coarse) {
  .lobby-card {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  }

  .lobby-header, .lobby-status, .role-grid, .lobby-actions:has(+ .invite-row[hidden]) {
    grid-column: 1 / -1;
  }

  .game-shell:has(#mobile-controls:not([hidden])) {
    --move-width: calc(var(--touch-size) * 3 + var(--touch-gap) * 2);
    --actions-width: calc(var(--touch-size) * 2 + var(--touch-gap));
  }

  .game-shell:has(#mobile-controls:not([hidden]) .joystick:not([hidden])) {
    --move-width: calc(var(--touch-size) * 2 + var(--touch-gap));
  }

  #mobile-controls {
    --touch-bottom: calc(var(--hud-bottom) + 5px);
  }

  .touch-mode-switch {
    left: calc(var(--safe-left) + (var(--move-width) - 60px) / 2);
  }

  .game-shell:has(#mobile-controls:not([hidden])) .bottom-hud {
    right: calc(var(--safe-right) + var(--actions-width) + 8px);
    left: calc(var(--safe-left) + var(--move-width) + 8px);
  }

  .game-shell:has(#mobile-controls:not([hidden])) .hotbar {
    max-width: 500px;
    gap: clamp(2px, 0.55vw, 5px);
    padding: 4px;
  }

  .game-shell:has(#mobile-controls:not([hidden])) .block-icon {
    height: auto;
    aspect-ratio: 0.88;
    margin-top: 0;
  }

  .game-shell:has(#mobile-controls:not([hidden])) #toast {
    top: calc(var(--safe-top) + 51px);
    right: var(--safe-right);
    left: calc(var(--safe-left) + 138px);
    max-width: min(400px, calc(100% - var(--safe-left) - var(--safe-right) - 138px));
    margin-inline: auto;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
  }
}
