* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --bg-top: #fff4d9;
  --bg-bottom: #f3dcc5;
  --panel: rgba(255, 250, 242, 0.84);
  --panel-strong: rgba(255, 248, 234, 0.94);
  --border: rgba(67, 43, 17, 0.14);
  --shadow: 0 24px 70px rgba(91, 53, 16, 0.16);
  --text-main: #2b1c0f;
  --text-muted: #6d5443;
  --accent: #b85225;
  --accent-strong: #8d3516;
  --accent-soft: rgba(184, 82, 37, 0.12);
  --success: #2d7a55;
  --danger: #c43737;
  --card-radius: 28px;
  --play-card-radius: 10px;
  font-family: 'Bahnschrift', 'Trebuchet MS', sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-main);
  background:
    radial-gradient(
      circle at top left,
      rgba(255, 255, 255, 0.75),
      transparent 32%
    ),
    linear-gradient(145deg, var(--bg-top), var(--bg-bottom));
}

.background-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(102, 70, 39, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(102, 70, 39, 0.06) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at center, black 45%, transparent 92%);
  opacity: 0.5;
}

.app-shell {
  position: relative;
  width: min(480px, calc(100vw - 16px));
  margin: 0 auto;
  padding: 16px 0 calc(28px + env(safe-area-inset-bottom, 0px));
}

.card-stage > * {
  animation: rise 420ms ease-out;
}

.card-stage {
  min-height: 420px;
}

.screen-card {
  position: relative;
  overflow: hidden;
  padding: 20px 16px;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.screen-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), #d28a34, #f3b74e);
}

.screen-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.compact-header {
  margin-bottom: 16px;
}

.screen-title {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.05;
}

.screen-subtitle {
  margin: 8px 0 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(60, 37, 12, 0.08);
  font-size: 0.92rem;
  white-space: nowrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(45, 122, 85, 0.12);
  animation: pulse 1.8s infinite;
}

.dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(196, 55, 55, 0.18);
}

.meta-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 24px;
}

.meta-grid-wide {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.meta-item,
.player-panel,
.counter-board {
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--panel-strong);
  border: 1px solid rgba(68, 42, 15, 0.08);
}

.player-identity-panel {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.78),
    rgba(246, 232, 209, 0.88)
  );
}

.player-identity-header,
.player-identity-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.identity-subtitle {
  margin-top: 6px;
}

.identity-pill {
  flex-shrink: 0;
}

.meta-label {
  margin: 0 0 8px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.meta-value {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  word-break: break-all;
}

.actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.actions > * {
  flex: 1 1 0;
}

button {
  appearance: none;
  border: none;
  border-radius: 16px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

.select-control {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(63, 37, 13, 0.08);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-main);
  font: inherit;
  font-weight: 700;
}

.text-control {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(63, 37, 13, 0.12);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text-main);
  font: inherit;
  font-weight: 700;
}

.text-control::placeholder {
  color: rgba(109, 84, 67, 0.72);
}

.text-control:focus {
  outline: 2px solid rgba(184, 82, 37, 0.24);
  outline-offset: 2px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.field-block {
  display: grid;
  gap: 10px;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.button-primary {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 14px 28px rgba(141, 53, 22, 0.24);
}

.button-secondary {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(63, 37, 13, 0.08);
}

.button-danger {
  color: white;
  background: linear-gradient(135deg, #ad402f, #7d201f);
  box-shadow: 0 14px 28px rgba(125, 32, 31, 0.2);
}

.lobby-create-panel,
.section-block {
  margin-bottom: 24px;
  padding: 18px;
  border-radius: 24px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.76),
    rgba(247, 230, 205, 0.76)
  );
  border: 1px solid rgba(66, 41, 18, 0.08);
}

.create-match-panel {
  display: grid;
  gap: 18px;
  padding: 24px 20px 22px;
}

.create-match-header {
  display: grid;
  justify-items: start;
  gap: 0;
  text-align: left;
}

.create-match-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  align-items: stretch;
}

.control-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 248, 238, 0.82);
  border: 1px solid rgba(68, 42, 15, 0.08);
}

.stepper-control {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  gap: 12px;
  align-items: stretch;
}

.stepper-button {
  min-height: 64px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(63, 37, 13, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  font-size: 1.4rem;
  line-height: 1;
}

.stepper-value-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.9),
    rgba(250, 237, 216, 0.92)
  );
  border: 1px solid rgba(68, 42, 15, 0.08);
}

.stepper-value {
  font-size: 2rem;
  line-height: 1;
}

.stepper-hint {
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.mode-switcher {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

.mode-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  padding: 14px;
  border-radius: 18px;
  text-align: center;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(63, 37, 13, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.mode-switch.is-active {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-color: transparent;
  box-shadow: 0 16px 28px rgba(141, 53, 22, 0.18);
}

.mode-switch-title {
  width: 100%;
  text-align: center;
  position: absolute;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
  pointer-events: none;
}

.mode-switch-copy {
  font-size: 0.8rem;
  line-height: 1.35;
  opacity: 0.84;
}

.create-match-actions {
  justify-content: center;
}

.create-match-actions > * {
  flex: 0 1 240px;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.lobby-list-header {
  align-items: flex-start;
}

.lobby-list-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.lobby-list-header .meta-label {
  margin-bottom: 0;
}

.quick-join-button {
  min-width: 144px;
  width: auto;
}

.empty-state-panel {
  padding: 20px 16px;
  border-radius: 20px;
  background: rgba(255, 249, 239, 0.74);
  border: 1px dashed rgba(87, 56, 19, 0.14);
  text-align: center;
}

.lobby-list,
.player-list {
  display: grid;
  gap: 12px;
}

.lobby-row,
.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 249, 239, 0.9);
  border: 1px solid rgba(68, 42, 15, 0.08);
}

.lobby-row-main {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.lobby-row-title,
.match-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mini-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 236, 217, 0.88);
  border: 1px solid rgba(149, 85, 27, 0.14);
  color: #774421;
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.mini-pill.is-online {
  background: rgba(222, 247, 234, 0.9);
  color: #1f6a43;
  border-color: rgba(37, 110, 73, 0.14);
}

.match-rule-pill {
  background: rgba(255, 241, 216, 0.94);
}

.match-title-stack {
  min-width: 0;
}

.inline-caption {
  margin-top: 18px !important;
  text-align: center;
}

.toast-viewport {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 50;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 24px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid rgba(143, 44, 44, 0.18);
  background: rgba(255, 244, 242, 0.94);
  color: #712b2b;
  box-shadow: 0 24px 48px rgba(84, 31, 20, 0.22);
  backdrop-filter: blur(14px);
  pointer-events: auto;
  animation: toastIn 220ms ease-out;
}

.toast-message {
  margin: 0;
  line-height: 1.5;
  font-weight: 700;
}

.toast-dismiss {
  width: auto;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(113, 43, 43, 0.08);
  color: inherit;
  box-shadow: none;
}

.toast-dismiss:hover {
  background: rgba(113, 43, 43, 0.14);
}

.queue-visual {
  margin: 24px 0;
  padding: 24px 18px;
  text-align: center;
  border-radius: 24px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.74),
    rgba(247, 230, 205, 0.8)
  );
  border: 1px solid rgba(66, 41, 18, 0.08);
}

.lobby-visual {
  margin-top: 0;
}

.spinner {
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 7px solid rgba(184, 82, 37, 0.16);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.game-screen-card {
  overflow: hidden;
}

.match-arena {
  position: relative;
  min-height: 320px;
  margin-bottom: 14px;
  padding: 128px 0 12px;
}

.opponents-orbit {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.opponents-orbit.is-target-selection-active {
  pointer-events: auto;
}

.opponent-seat {
  position: absolute;
  z-index: 4;
  display: flex;
  padding: 0;
  border: 0;
  background: transparent;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 112px;
  pointer-events: none;
  font: inherit;
  color: inherit;
  text-align: inherit;
  transition:
    opacity 0.22s ease,
    filter 0.22s ease;
}

.opponents-orbit.is-target-selection-active .opponent-seat {
  pointer-events: auto;
}

.opponent-seat:disabled {
  cursor: default;
}

.opponent-seat::after {
  display: none;
}

.opponent-seat.is-removed {
  opacity: 0.42;
  filter: saturate(0.45);
}

.opponent-seat.is-acting {
  transform: translate(-50%, -50%);
}

.opponent-seat.is-targetable {
  cursor: pointer;
}

.opponent-seat.is-targetable .opponent-avatar-shell,
.opponent-seat.is-targetable .opponent-meta {
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    background 0.22s ease,
    border-color 0.22s ease;
}

.opponent-seat.is-targetable:hover .opponent-avatar-shell,
.opponent-seat.is-targetable:focus-visible .opponent-avatar-shell {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #fff5e8, #f7c88e);
  box-shadow:
    0 0 0 1px rgba(184, 82, 37, 0.18),
    0 16px 32px rgba(184, 82, 37, 0.22);
}

.opponent-seat.is-targetable:hover .opponent-meta,
.opponent-seat.is-targetable:focus-visible .opponent-meta {
  background: rgba(255, 245, 230, 0.96);
  border-color: rgba(184, 82, 37, 0.22);
}

.opponent-seat.is-selected-target .opponent-avatar-shell {
  background: linear-gradient(135deg, #fff8ea, #ffcf8a);
  box-shadow:
    0 0 0 2px rgba(255, 227, 183, 0.92),
    0 0 0 6px rgba(184, 82, 37, 0.18),
    0 16px 32px rgba(184, 82, 37, 0.22),
    0 0 24px rgba(255, 171, 71, 0.2);
}

.opponent-seat.is-selected-target .opponent-avatar-shell::before,
.opponent-seat.is-selected-target .opponent-avatar-shell::after {
  opacity: 1;
}

.opponent-seat.is-selected-target .opponent-meta {
  background: rgba(255, 244, 223, 0.98);
  border-color: rgba(184, 82, 37, 0.26);
  color: #6d371c;
  box-shadow: 0 10px 20px rgba(184, 82, 37, 0.14);
}

.opponent-seat.is-target-disabled:not(.is-removed) {
  opacity: 0.72;
}

.opponent-seat.is-target-disabled:not(.is-removed) .opponent-avatar-shell {
  filter: saturate(0.78);
}

.opponent-token {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 108px;
}

.opponent-avatar-shell {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 3px;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    rgba(255, 243, 230, 0.98),
    rgba(232, 198, 156, 0.96)
  );
  box-shadow: 0 12px 24px rgba(78, 48, 18, 0.16);
  isolation: isolate;
  transition:
    box-shadow 0.28s ease,
    background 0.28s ease;
}

.opponent-avatar-shell::before,
.opponent-avatar-shell::after {
  content: '';
  position: absolute;
  inset: -7px;
  z-index: -1;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.24s ease;
}

.opponent-avatar-shell::before {
  background: radial-gradient(
    circle,
    rgba(255, 201, 105, 0.5) 0%,
    rgba(255, 156, 72, 0.22) 46%,
    rgba(255, 156, 72, 0) 72%
  );
  filter: blur(2px);
}

.opponent-avatar-shell::after {
  inset: -5px;
  border: 2px solid rgba(255, 232, 176, 0.85);
  box-shadow:
    0 0 0 2px rgba(184, 82, 37, 0.2),
    0 0 22px rgba(255, 165, 74, 0.38);
}

.opponent-avatar {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(135deg, #8f3518, #cd7c33);
  color: rgba(255, 248, 238, 0.96);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-indent: 0.08em;
  text-transform: uppercase;
}

.opponent-avatar.has-role-icon {
  text-indent: 0;
}

.opponent-avatar-role-icon {
  width: 31px;
  height: 31px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(43, 28, 15, 0.34));
}

.opponent-seat.is-acting .opponent-avatar-shell {
  background: linear-gradient(135deg, #fff5e5, #ffd599);
  box-shadow:
    0 0 0 2px rgba(255, 235, 190, 0.82),
    0 0 0 6px rgba(255, 193, 100, 0.18),
    0 16px 30px rgba(184, 82, 37, 0.22);
}

.opponent-seat.is-acting .opponent-avatar-shell::before {
  opacity: 1;
}

.opponent-seat.is-acting .opponent-avatar-shell::after {
  opacity: 1;
  animation: avatar-pulse 1.6s ease-in-out infinite;
}

@keyframes avatar-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.18);
    opacity: 1;
  }
}

.opponent-fan {
  position: absolute;
  inset: 0;
}

.opponent-fan-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 38px;
  transform-origin: center;
}

.opponent-fan-card .game-card {
  width: 100%;
  min-height: 100%;
  height: 100%;
  flex-basis: 100%;
  border-radius: 9px;
  box-shadow: 0 6px 12px rgba(77, 44, 16, 0.12);
}

.opponent-fan-card .card-back-pattern {
  inset: 3px;
  border-radius: 6px;
}

.opponent-fan-card .card-back-label {
  display: none;
}

.opponent-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255, 249, 240, 0.9);
  border: 1px solid rgba(73, 44, 16, 0.08);
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(78, 48, 18, 0.08);
}

.opponent-seat.is-offline .opponent-meta {
  background: rgba(255, 244, 241, 0.94);
}

.opponent-meta .dot {
  width: 8px;
  height: 8px;
  box-shadow: 0 0 0 4px rgba(45, 122, 85, 0.1);
}

.opponent-meta .dot.offline {
  box-shadow: 0 0 0 4px rgba(196, 55, 55, 0.16);
}

.opponent-id {
  max-width: 54px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.opponent-status {
  display: inline-flex;
  align-items: center;
  min-width: 34px;
  justify-content: center;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(196, 55, 55, 0.12);
  color: #8b2e2e;
  font-size: 0.68rem;
  font-weight: 800;
}

.player-lane {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: 22px;
  background: var(--panel-strong);
  border: 1px solid rgba(68, 42, 15, 0.08);
  transition:
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    transform 0.22s ease;
}

.acting-lane {
  border-color: rgba(184, 82, 37, 0.42);
  box-shadow:
    0 0 0 1px rgba(184, 82, 37, 0.2),
    0 22px 42px rgba(184, 82, 37, 0.18),
    0 0 38px rgba(241, 162, 72, 0.14);
  background: linear-gradient(
    180deg,
    rgba(255, 249, 238, 0.99),
    rgba(252, 236, 212, 0.97)
  );
}

.acting-lane::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  border: 2px solid rgba(255, 210, 128, 0.92);
  pointer-events: none;
  animation: activeFrame 1.5s ease-in-out infinite;
}

.acting-lane.turn-flash {
  box-shadow:
    0 0 0 2px rgba(255, 232, 176, 0.38),
    0 28px 56px rgba(184, 82, 37, 0.24),
    0 0 56px rgba(255, 177, 81, 0.18);
}

.acting-lane.turn-flash::after {
  animation:
    activeFrameBurst 480ms ease-out 1,
    activeFrame 1.5s ease-in-out 480ms infinite;
}

.self-lane {
  margin-top: 14px;
}

.lane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lane-title {
  margin: 4px 0 0;
  font-size: 1rem;
  font-weight: 800;
}

.lane-header-compact {
  align-items: center;
}

.self-lane-title {
  margin: 0;
}

.lane-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.lane-meta-compact {
  flex-direction: row;
  align-items: center;
  gap: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.hand-row {
  position: relative;
  width: 100%;
  height: var(--hand-height, 112px);
  padding-bottom: 2px;
}

.hand-card-slot {
  position: absolute;
  top: 0;
  left: 0;
}

.hand-card-slot .game-card {
  width: 100%;
  height: 100%;
  min-height: 100%;
  flex-basis: 100%;
  border-radius: var(--play-card-radius);
}

.hand-card-slot button:hover {
  transform: translateY(-5px);
}

.hand-row .card-half {
  padding: 12px 12px 10px;
  font-size: 0.62rem;
  line-height: 1.18;
}

.hand-row .card-corner {
  width: 10px;
  height: 10px;
}

.hand-row .card-corner-sign {
  top: 5px;
  left: 5px;
}

.hand-row .card-corner-rank {
  right: 5px;
  bottom: 5px;
}

.hand-row .card-back-pattern {
  inset: 6px;
  border-radius: 9px;
}

.hand-row .card-back-label {
  font-size: 0.56rem;
  letter-spacing: 0.08em;
}

.hand-row.is-compact .game-card {
  border-radius: 8px;
}

.game-card.compact .card-half {
  flex: 0 0 50%;
  flex-direction: row;
  justify-content: space-between;
  min-height: 0;
  gap: 2px;
  padding: 6px 3px;
  overflow: hidden;
}

.game-card.compact .card-value-text {
  display: none;
}

.game-card.compact .card-corner {
  position: static;
  width: min(20px, calc((100% - 2px) / 2));
  height: min(20px, calc((100% - 2px) / 2));
  max-width: calc((100% - 2px) / 2);
  max-height: calc((100% - 2px) / 2);
  flex: 0 1 min(20px, calc((100% - 2px) / 2));
  opacity: 0.9;
}

.game-card.compact .card-icon {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

.game-card.compact.face-down .card-back-label {
  display: none;
}

.opponent-hand {
  justify-content: flex-start;
}

.table-zone {
  position: relative;
  z-index: 2;
  width: min(100%, 256px);
  margin: 0 auto;
  padding: 14px 16px 18px;
  border-radius: 24px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.6), transparent 52%),
    linear-gradient(180deg, rgba(120, 71, 32, 0.12), rgba(92, 55, 23, 0.2));
  border: 1px solid rgba(68, 42, 15, 0.1);
  overflow: visible;
}

.table-zone::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 29px;
  pointer-events: none;
  opacity: 0;
  background: conic-gradient(
    from calc(var(--table-glow-angle, 0deg) - 35deg),
    transparent 0deg,
    rgba(255, 180, 50, 0.55) 14deg,
    rgba(255, 160, 30, 0.9) 35deg,
    rgba(255, 180, 50, 0.55) 56deg,
    transparent 70deg,
    transparent 360deg
  );
  filter: blur(4px);
  z-index: -1;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  padding: 5px;
  transition: opacity 0.28s ease;
}

.table-zone.table-zone-active::after {
  opacity: 1;
}

.table-label {
  margin-bottom: 10px;
  text-align: center;
}

.table-stack {
  position: relative;
  width: 132px;
  height: 176px;
  margin: 0 auto;
}

.table-action-slot {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.table-action-button {
  position: absolute;
  top: calc(100% - 39px);
  left: 50%;
  width: 114px;
  padding: 8px 10px;
  border-radius: 14px;
  font-size: 0.68rem;
  line-height: 1.15;
  text-align: center;
  pointer-events: auto;
  transform: translateX(-50%);
  box-shadow: 0 10px 24px rgba(90, 53, 18, 0.18);
}

.table-action-button:hover {
  transform: translateX(-50%) translateY(-1px);
}

.table-action-button.is-muted {
  opacity: 0.58;
  box-shadow: 0 8px 18px rgba(90, 53, 18, 0.1);
}

.table-action-button.is-urgent {
  background: linear-gradient(135deg, #c76631, #983d1c);
  color: white;
  box-shadow:
    0 14px 30px rgba(152, 61, 28, 0.28),
    0 0 0 1px rgba(255, 226, 199, 0.28),
    0 0 22px rgba(255, 145, 77, 0.22);
  filter: saturate(1.02);
  animation: takeHitPulse 1.05s ease-in-out infinite;
}

.table-action-button.is-urgent:hover {
  transform: translateX(-50%) translateY(-2px);
}

.table-hint {
  min-height: 2.8em;
  margin: 12px 0 0;
  text-align: center;
  color: rgba(43, 28, 15, 0.48);
  font-size: 0.74rem;
  line-height: 1.35;
}

.table-hint.is-target-prompt,
.table-hint.is-target-prompt-urgent {
  min-height: auto;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(184, 82, 37, 0.2);
  background: linear-gradient(
    180deg,
    rgba(255, 243, 222, 0.96),
    rgba(253, 233, 203, 0.94)
  );
  color: #7b3a1d;
  box-shadow: 0 10px 24px rgba(184, 82, 37, 0.12);
}

.table-hint.is-target-prompt-urgent {
  border-color: rgba(183, 66, 28, 0.42);
  background: linear-gradient(
    180deg,
    rgba(255, 232, 214, 0.98),
    rgba(255, 214, 189, 0.96)
  );
  color: #822f15;
  box-shadow:
    0 12px 28px rgba(183, 66, 28, 0.18),
    0 0 0 1px rgba(255, 226, 198, 0.4);
  animation: targetPromptPulse 1.35s ease-in-out infinite;
}

@keyframes targetPromptPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 12px 28px rgba(183, 66, 28, 0.18),
      0 0 0 1px rgba(255, 226, 198, 0.4);
  }
  50% {
    transform: scale(1.015);
    box-shadow:
      0 16px 36px rgba(183, 66, 28, 0.22),
      0 0 0 1px rgba(255, 226, 198, 0.56);
  }
}

.table-card {
  position: absolute;
  top: 0;
  left: 50%;
  width: 92px;
  opacity: 1;
  transform-origin: center center;
  will-change: transform, opacity;
}

.table-card .game-card {
  width: 92px;
  min-height: 132px;
  flex-basis: 92px;
  border-radius: var(--play-card-radius);
}

.table-card.attack-card {
  --table-card-base-transform: translateX(calc(-50% - 14px)) rotate(-5deg);
  transform: var(--table-card-base-transform);
}

.table-card.defense-card {
  --table-card-base-transform: translate(calc(-50% + 16px), 16px) rotate(6deg);
  transform: var(--table-card-base-transform);
}

.table-card.defense-card {
  z-index: 1;
}

.table-card-phase-entering {
  animation: tableCardEnter 420ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.table-card-phase-returning {
  animation: tableCardReturn 380ms cubic-bezier(0.55, 0, 0.88, 0.53) forwards;
}

.table-card-phase-discarding {
  animation: tableCardDiscard 320ms ease-in forwards;
}

@keyframes tableCardEnter {
  from {
    opacity: 0;
    transform: var(--table-card-base-transform)
      translate(
        var(--table-card-travel-x, 0px),
        var(--table-card-travel-y, 0px)
      )
      rotate(var(--table-card-travel-rotate, 0deg)) scale(0.94);
  }
  to {
    opacity: 1;
    transform: var(--table-card-base-transform) translate(0, 0) rotate(0deg)
      scale(1);
  }
}

@keyframes tableCardReturn {
  from {
    opacity: 1;
    transform: var(--table-card-base-transform) translate(0, 0) rotate(0deg)
      scale(1);
  }
  to {
    opacity: 0;
    transform: var(--table-card-base-transform)
      translate(
        var(--table-card-travel-x, 0px),
        var(--table-card-travel-y, 0px)
      )
      rotate(var(--table-card-travel-rotate, 0deg)) scale(0.92);
  }
}

@keyframes tableCardDiscard {
  from {
    opacity: 1;
    transform: var(--table-card-base-transform) scale(1);
  }
  to {
    opacity: 0;
    transform: var(--table-card-base-transform) scale(0.72);
  }
}

.empty-slot {
  display: grid;
  place-items: center;
  width: 100%;
  flex: 1;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.table-empty {
  height: 100%;
  text-align: center;
}

.game-card {
  position: relative;
  display: flex;
  flex: 0 0 92px;
  flex-direction: column;
  justify-content: stretch;
  width: 92px;
  min-height: 132px;
  padding: 0;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(61, 35, 14, 0.12);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.95),
    rgba(251, 241, 230, 0.95)
  );
  box-shadow: 0 14px 28px rgba(90, 53, 18, 0.14);
  cursor: default;
}

.game-card.clickable {
  cursor: pointer;
}

.game-card.card-tone-muted {
  opacity: 0.56;
  filter: grayscale(0.94) saturate(0.2) brightness(1.03);
  box-shadow: 0 8px 16px rgba(90, 53, 18, 0.08);
}

.game-card.card-tone-muted .card-half {
  animation: none;
  box-shadow: none;
}

.game-card.selected,
.game-card.clickable:not(:disabled):focus-visible {
  outline: 2px solid rgba(184, 82, 37, 0.42);
  outline-offset: 2px;
}

.game-card.face-down {
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, rgba(151, 53, 33, 0.92), rgba(94, 25, 27, 0.95)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent);
}

.game-card.placeholder {
  background: rgba(255, 255, 255, 0.3);
  border-style: dashed;
  box-shadow: none;
}

.card-half {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 16px 18px 14px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.3;
  transition:
    opacity 0.22s ease,
    filter 0.22s ease,
    box-shadow 0.22s ease,
    transform 0.22s ease;
}

.card-value-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.card-corner {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 14px;
  opacity: 0.72;
}

.card-icon {
  display: block;
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  filter: var(--card-icon-filter, none);
}

.card-corner-sign {
  top: 7px;
  left: 7px;
}

.card-corner-rank {
  right: 7px;
  bottom: 7px;
}

.hand-row.is-compact .card-half {
  font-size: 0.54rem;
}

.attack-zone {
  --card-icon-filter: brightness(0) saturate(100%) invert(14%) sepia(95%)
    saturate(3788%) hue-rotate(356deg) brightness(99%) contrast(96%);
  background: linear-gradient(
    180deg,
    rgba(232, 49, 34, 0.26),
    rgba(191, 24, 24, 0.42)
  );
  color: #7d0f0b;
}

.game-card.stat-focus-attack .attack-zone {
  box-shadow:
    inset 0 0 0 1px rgba(255, 236, 229, 0.8),
    inset 0 12px 12px rgba(255, 255, 255, 0.08),
    inset 0 -12px 16px rgba(122, 0, 0, 0.1),
    inset 14px 0 18px rgba(255, 69, 69, 0.12),
    inset -14px 0 18px rgba(255, 69, 69, 0.12),
    0 0 18px rgba(221, 32, 32, 0.16),
    0 0 32px rgba(255, 82, 82, 0.08);
  filter: saturate(1.12) brightness(1.03);
  animation: focusedHalfGlowWarm 1.8s ease-in-out infinite;
}

.game-card.stat-focus-attack .defense-zone {
  opacity: 0.64;
  filter: saturate(0.62) brightness(0.97);
}

.defense-zone {
  --card-icon-filter: brightness(0) saturate(100%) invert(22%) sepia(92%)
    saturate(3023%) hue-rotate(210deg) brightness(97%) contrast(97%);
  background: linear-gradient(
    180deg,
    rgba(22, 111, 255, 0.22),
    rgba(0, 71, 214, 0.4)
  );
  color: #0a3f97;
}

.game-card.stat-focus-defense .defense-zone {
  box-shadow:
    inset 0 0 0 1px rgba(232, 244, 255, 0.82),
    inset 0 12px 12px rgba(255, 255, 255, 0.08),
    inset 0 -12px 16px rgba(0, 42, 130, 0.12),
    inset 14px 0 18px rgba(59, 140, 255, 0.12),
    inset -14px 0 18px rgba(59, 140, 255, 0.12),
    0 0 18px rgba(21, 98, 255, 0.16),
    0 0 32px rgba(63, 157, 255, 0.08);
  filter: saturate(1.14) brightness(1.04);
  animation: focusedHalfGlowCool 1.8s ease-in-out infinite;
}

.game-card.stat-focus-defense .attack-zone {
  opacity: 0.64;
  filter: saturate(0.62) brightness(0.97);
}

.card-back-pattern {
  position: absolute;
  inset: 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.1) 8px,
    transparent 8px,
    transparent 16px
  );
}

.card-back-label {
  position: relative;
  z-index: 1;
  color: rgba(255, 245, 236, 0.95);
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.game-actions {
  margin-top: 16px;
}

@keyframes takeHitPulse {
  0%,
  100% {
    transform: translateX(-50%);
    box-shadow:
      0 14px 30px rgba(152, 61, 28, 0.28),
      0 0 0 0 rgba(221, 122, 63, 0.42),
      0 0 18px rgba(255, 145, 77, 0.2);
    filter: saturate(1.02) brightness(1);
  }
  50% {
    transform: translateX(-50%);
    box-shadow:
      0 20px 42px rgba(152, 61, 28, 0.38),
      0 0 0 12px rgba(221, 122, 63, 0),
      0 0 34px rgba(255, 145, 77, 0.42);
    filter: saturate(1.14) brightness(1.06);
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(43, 28, 15, 0.36);
  backdrop-filter: blur(8px);
}

.result-modal {
  width: min(100%, 360px);
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 28px 22px 24px;
  border-radius: 26px;
  background: rgba(255, 249, 239, 0.98);
  border: 1px solid rgba(67, 43, 17, 0.14);
  box-shadow: 0 24px 56px rgba(43, 28, 15, 0.24);
}

.result-modal-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.result-modal-label,
.result-modal-message,
.result-modal-caption {
  margin: 0;
}

.result-modal-message {
  width: 100%;
  text-align: center;
}

.result-modal-caption {
  max-width: 26ch;
}

.result-modal-actions {
  margin-top: 2px;
}

.player-panel.highlight {
  border-color: rgba(184, 82, 37, 0.28);
  box-shadow: inset 0 0 0 1px rgba(184, 82, 37, 0.14);
  background: linear-gradient(
    180deg,
    rgba(255, 248, 236, 0.94),
    rgba(251, 239, 223, 0.94)
  );
}

.player-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.player-name {
  font-weight: 800;
  font-size: 1.02rem;
  word-break: break-all;
}

.player-seat {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.counter-board {
  margin-bottom: 22px;
  text-align: center;
}

.counter-value {
  margin: 6px 0 2px;
  font-size: clamp(2.8rem, 7vw, 4.8rem);
  font-weight: 900;
  letter-spacing: -0.06em;
  line-height: 1;
}

.caption {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes lanePulse {
  0%,
  100% {
    opacity: 0.65;
    box-shadow: 0 0 0 0 rgba(184, 82, 37, 0.12);
  }
  50% {
    opacity: 1;
    box-shadow: 0 0 0 8px rgba(184, 82, 37, 0.04);
  }
}

@keyframes focusedHalfGlowWarm {
  0%,
  100% {
    box-shadow:
      inset 0 0 0 1px rgba(255, 236, 229, 0.74),
      inset 0 10px 10px rgba(255, 255, 255, 0.06),
      inset 0 -10px 14px rgba(122, 0, 0, 0.08),
      inset 12px 0 16px rgba(255, 69, 69, 0.1),
      inset -12px 0 16px rgba(255, 69, 69, 0.1),
      0 0 14px rgba(221, 32, 32, 0.12),
      0 0 24px rgba(255, 82, 82, 0.06);
  }
  50% {
    box-shadow:
      inset 0 0 0 1px rgba(255, 244, 240, 0.88),
      inset 0 12px 12px rgba(255, 255, 255, 0.08),
      inset 0 -12px 16px rgba(122, 0, 0, 0.11),
      inset 15px 0 20px rgba(255, 86, 86, 0.14),
      inset -15px 0 20px rgba(255, 86, 86, 0.14),
      0 0 18px rgba(221, 32, 32, 0.16),
      0 0 32px rgba(255, 82, 82, 0.09);
  }
}

@keyframes focusedHalfGlowCool {
  0%,
  100% {
    box-shadow:
      inset 0 0 0 1px rgba(232, 244, 255, 0.76),
      inset 0 10px 10px rgba(255, 255, 255, 0.06),
      inset 0 -10px 14px rgba(0, 42, 130, 0.08),
      inset 12px 0 16px rgba(59, 140, 255, 0.1),
      inset -12px 0 16px rgba(59, 140, 255, 0.1),
      0 0 14px rgba(21, 98, 255, 0.12),
      0 0 24px rgba(63, 157, 255, 0.06);
  }
  50% {
    box-shadow:
      inset 0 0 0 1px rgba(245, 250, 255, 0.88),
      inset 0 12px 12px rgba(255, 255, 255, 0.08),
      inset 0 -12px 16px rgba(0, 42, 130, 0.1),
      inset 15px 0 20px rgba(82, 158, 255, 0.14),
      inset -15px 0 20px rgba(82, 158, 255, 0.14),
      0 0 18px rgba(21, 98, 255, 0.16),
      0 0 32px rgba(63, 157, 255, 0.09);
  }
}

@keyframes activeFrame {
  0%,
  100% {
    opacity: 0.75;
    box-shadow:
      0 0 0 0 rgba(255, 196, 96, 0.08),
      inset 0 0 0 0 rgba(255, 216, 150, 0.12);
  }
  50% {
    opacity: 1;
    box-shadow:
      0 0 0 10px rgba(255, 196, 96, 0.06),
      inset 0 0 22px rgba(255, 216, 150, 0.12);
  }
}

@keyframes activeFrameBurst {
  0% {
    opacity: 1;
    transform: scale(0.98);
    box-shadow: 0 0 0 0 rgba(255, 196, 96, 0.3);
  }
  100% {
    opacity: 0.88;
    transform: scale(1.02);
    box-shadow: 0 0 0 18px rgba(255, 196, 96, 0);
  }
}

@keyframes avatarHalo {
  0%,
  100% {
    opacity: 0.7;
    transform: scale(0.98);
  }
  50% {
    opacity: 1;
    transform: scale(1.14);
  }
}

@keyframes avatarRing {
  0%,
  100% {
    opacity: 0.8;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes avatarBurst {
  0% {
    opacity: 1;
    transform: scale(0.86);
  }
  100% {
    opacity: 0.82;
    transform: scale(1.22);
  }
}

@keyframes avatarBurstRing {
  0% {
    opacity: 1;
    transform: scale(0.78);
    box-shadow:
      0 0 0 4px rgba(255, 236, 188, 0.5),
      0 0 26px rgba(255, 165, 74, 0.45);
  }
  100% {
    opacity: 0.9;
    transform: scale(1.14);
    box-shadow:
      0 0 0 0 rgba(255, 236, 188, 0),
      0 0 18px rgba(255, 165, 74, 0.22);
  }
}

@keyframes laneBurst {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(184, 82, 37, 0.3);
  }
  100% {
    opacity: 0.75;
    box-shadow: 0 0 0 14px rgba(184, 82, 37, 0);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.18);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 980px) {
  .app-shell {
    padding-top: 14px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 12px, 100%);
  }

  .screen-card {
    padding: 18px 14px;
  }

  .meta-grid,
  .player-grid {
    grid-template-columns: 1fr;
  }

  .screen-header {
    flex-direction: column;
    align-items: stretch;
  }

  .player-identity-header,
  .player-identity-body,
  .lobby-list-header {
    flex-direction: column;
    align-items: stretch;
  }

  .lobby-list-actions {
    justify-content: flex-start;
  }

  .create-match-controls,
  .mode-switcher {
    grid-template-columns: 1fr;
  }

  .badge {
    align-self: flex-start;
  }

  .lane-header {
    align-items: flex-start;
  }

  .lane-meta {
    align-items: flex-start;
  }

  .button-primary,
  .button-secondary,
  .button-danger,
  button {
    width: 100%;
  }

  .quick-join-button {
    width: 100%;
  }

  .actions,
  .inline-actions {
    flex-direction: column;
  }

  .actions > * {
    flex: initial;
  }

  .toast-viewport {
    top: 12px;
    width: min(100vw - 16px, 100%);
  }

  .toast {
    grid-template-columns: 1fr;
  }

  .match-arena {
    min-height: 286px;
    padding-top: 116px;
  }

  .opponent-seat {
    width: 96px;
  }

  .opponent-avatar-shell {
    width: 44px;
    height: 44px;
  }

  .opponent-avatar {
    font-size: 0.58rem;
  }

  .opponent-fan {
    inset: 0;
  }

  .opponent-fan-card {
    width: 22px;
    height: 32px;
  }

  .opponent-meta {
    gap: 5px;
    padding: 4px 8px;
    font-size: 0.68rem;
  }

  .table-stack {
    width: 118px;
    height: 164px;
  }

  .table-card {
    width: 84px;
    height: 122px;
  }

  .table-card .game-card {
    width: 84px;
    min-height: 122px;
    flex-basis: 84px;
  }

  .table-card.attack-card {
    --table-card-base-transform: translateX(calc(-50% - 11px)) rotate(-5deg);
    transform: var(--table-card-base-transform);
  }

  .table-card.defense-card {
    --table-card-base-transform: translate(calc(-50% + 12px), 14px) rotate(6deg);
    transform: var(--table-card-base-transform);
  }
}

@media (min-width: 641px) {
  .app-shell {
    width: min(560px, calc(100vw - 24px));
  }

  .screen-card {
    padding: 24px 20px;
  }

  .game-card {
    flex-basis: 96px;
    width: 96px;
    min-height: 136px;
  }
}
