:root {
  color-scheme: dark;
  --green: #80c65f;
  --red: #e26d5f;
  --ink: #f9ead2;
  --muted: #c9ac83;
  --field: rgba(71, 42, 24, 0.86);
  --shadow: 0 22px 50px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family:
    ui-rounded,
    "Apple SD Gothic Neo",
    "Malgun Gothic",
    system-ui,
    sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(140, 98, 48, 0.45), transparent 32rem),
    radial-gradient(circle at 82% 18%, rgba(154, 53, 44, 0.28), transparent 30rem),
    linear-gradient(135deg, #160f0c, #2b1910 44%, #120b08);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

body:not(.in-room) .player-card {
  visibility: hidden;
  pointer-events: none;
}

.app {
  width: min(1040px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0;
}

.table {
  position: relative;
  overflow: hidden;
  min-height: 640px;
  border: 1px solid rgba(255, 231, 190, 0.18);
  border-radius: 32px;
  box-shadow: var(--shadow), inset 0 0 80px rgba(0, 0, 0, 0.25);
  background:
    linear-gradient(90deg, rgba(20, 12, 8, 0.34), transparent 17%, transparent 83%, rgba(20, 12, 8, 0.34)),
    repeating-linear-gradient(88deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 85px),
    linear-gradient(160deg, #80532f, #58341f 50%, #3a2217);
}

.table::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 226, 156, 0.14), transparent 18rem),
    radial-gradient(circle at 0% 90%, rgba(111, 187, 85, 0.18), transparent 16rem),
    radial-gradient(circle at 100% 90%, rgba(218, 84, 72, 0.15), transparent 16rem);
}

.topbar,
.lobby,
.game-shell {
  position: relative;
  z-index: 1;
}

.topbar {
  height: 142px;
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  align-items: start;
  gap: 16px;
  padding: 18px 22px 0;
}

.player-card {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 -14px 28px rgba(0, 0, 0, 0.15);
}

.player-card-left {
  justify-self: start;
  width: 270px;
  border-radius: 18px 44px 44px 18px;
  background: linear-gradient(115deg, rgba(61, 125, 41, 0.95), rgba(92, 143, 43, 0.52));
}

.player-card-right {
  justify-self: end;
  width: 270px;
  border-radius: 44px 18px 18px 44px;
  background: linear-gradient(245deg, rgba(144, 51, 41, 0.95), rgba(184, 77, 52, 0.48));
}

.player-card.is-turn {
  outline: 3px solid rgba(255, 240, 170, 0.76);
  box-shadow:
    0 0 28px rgba(255, 224, 111, 0.24),
    inset 0 -14px 28px rgba(0, 0, 0, 0.12);
}

.turn-chip {
  display: none;
  position: absolute;
  margin-top: -72px;
  padding: 4px 12px;
  border-radius: 999px;
  color: #1d160b;
  background: #ffe987;
  font-weight: 950;
  font-size: 13px;
}

.player-card.is-turn .turn-chip {
  display: block;
}

.player-card small {
  color: rgba(255, 240, 210, 0.78);
  font-weight: 900;
}

.streak-win {
  color: #91ef6f;
}

.streak-loss {
  color: #ff8271;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  box-shadow: inset 8px 8px 14px rgba(255, 255, 255, 0.16);
}

.avatar-green {
  background: radial-gradient(circle at 34% 32%, #efffce 0 10%, transparent 12%), linear-gradient(135deg, #91d56a, #396b28);
}

.avatar-red {
  background: radial-gradient(circle at 34% 32%, #ffe5dc 0 10%, transparent 12%), linear-gradient(135deg, #ee8373, #843126);
}

.brand {
  justify-self: center;
  display: grid;
  justify-items: center;
  gap: 6px;
}

.brand h1 {
  margin: 0;
  text-align: center;
  color: #ffe9b7;
  text-shadow: 0 5px 0 rgba(64, 36, 21, 0.75);
  font-size: 46px;
  line-height: 0.95;
}

.brand h1 span {
  display: block;
  color: #fff9e6;
  font-size: 36px;
}

.dice-mark {
  font-size: 30px;
}

.room-panel button,
.lobby button,
.tray-action,
.result-banner button {
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  color: #2a180e;
  background: linear-gradient(180deg, #ffe2a1, #c99042);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.38),
    0 6px 12px rgba(0, 0, 0, 0.22);
  font-weight: 900;
}

.lobby {
  position: relative;
  width: min(560px, calc(100% - 40px));
  margin: 78px auto 0;
  padding: 28px;
  border-radius: 24px;
  background: rgba(24, 15, 10, 0.62);
  box-shadow: inset 0 0 0 1px rgba(255, 235, 204, 0.12);
  text-align: center;
}

.online-users,
.lobby-rating {
  position: fixed;
  z-index: 3;
  color: #ffe6b2;
  background: rgba(24, 15, 10, 0.6);
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.22),
    inset 0 0 0 1px rgba(255, 235, 204, 0.13);
  backdrop-filter: blur(8px);
}

body.in-room .online-users,
body.in-room .lobby-rating {
  display: none;
}

.online-users {
  right: max(24px, calc((100vw - 1040px) / 2 + 24px));
  top: 34px;
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 950;
}

.lobby-rating {
  right: max(24px, calc((100vw - 1040px) / 2 + 24px));
  bottom: 34px;
  min-width: 150px;
  padding: 14px 16px;
  border-radius: 18px;
  text-align: right;
}

.lobby-rating strong,
.lobby-rating span {
  display: block;
}

.lobby-rating strong {
  color: #ffe193;
  font-size: 24px;
  font-weight: 950;
}

.lobby-rating span {
  color: rgba(255, 239, 211, 0.76);
  font-size: 14px;
  font-weight: 900;
}

.lobby h2 {
  margin: 0 0 10px;
  font-size: 28px;
}

.lobby p {
  color: rgba(255, 238, 207, 0.72);
}

.lobby-actions {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.lobby .primary-match {
  min-height: 52px;
  border-radius: 16px;
  color: #1f1609;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 255, 255, 0.5), transparent 28%),
    linear-gradient(180deg, #fff3b0, #efb64f);
  box-shadow:
    0 0 24px rgba(255, 211, 111, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 7px 14px rgba(0, 0, 0, 0.25);
  font-size: 17px;
}

.nickname-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  text-align: left;
  color: #ffe8bd;
  font-weight: 900;
}

.lobby form {
  display: flex;
  gap: 10px;
}

.lobby input {
  flex: 1;
  border: 1px solid rgba(255, 230, 185, 0.24);
  border-radius: 12px;
  padding: 12px 14px;
  color: #fff2d7;
  background: rgba(15, 9, 6, 0.52);
  font-weight: 900;
  letter-spacing: 0.18em;
}

.nickname-row input {
  letter-spacing: 0;
}

.status {
  min-height: 22px;
  color: #ffe2a1;
}

.status:empty {
  display: none;
}

.game-shell {
  padding-bottom: 130px;
}

.start-banner {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 205px;
  transform: translateX(-50%);
  min-width: 330px;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 16px 22px 18px;
  border: 1px solid rgba(255, 232, 178, 0.34);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 227, 150, 0.28), transparent 72%),
    rgba(25, 15, 10, 0.86);
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  animation: bannerPop 420ms cubic-bezier(0.12, 0.82, 0.25, 1.18);
}

.start-banner[hidden] {
  display: none;
}

.rolloff-dice {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
}

.rolloff-dice > div {
  display: grid;
  justify-items: center;
  gap: 7px;
}

.rolloff-dice small {
  max-width: 120px;
  color: rgba(255, 239, 211, 0.76);
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.versus {
  color: #ffd384;
  font-size: 15px;
  font-weight: 950;
}

.start-banner strong {
  color: #ffe4a4;
  font-size: 26px;
  font-weight: 950;
}

.room-panel {
  width: min(720px, calc(100% - 40px));
  margin: 28px auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 16px;
  border-radius: 18px;
  background: rgba(22, 13, 8, 0.56);
}

.room-panel span {
  color: var(--muted);
  font-size: 13px;
}

#room-code {
  margin-left: 8px;
  color: #ffe987;
  font-size: 24px;
  letter-spacing: 0.12em;
}

#connection-status {
  margin: 0;
  min-width: 190px;
  color: rgba(255, 238, 207, 0.72);
  text-align: center;
}

.leave-room-button {
  margin-left: 4px;
  color: #fff3ec !important;
  background: linear-gradient(180deg, #d66a59, #872d26) !important;
}

.board-wrap {
  height: 390px;
  display: grid;
  grid-template-columns: 132px minmax(570px, 1fr) 132px;
  align-items: center;
  gap: 18px;
  padding: 4px 38px 0;
}

.player-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.dice-tray {
  position: relative;
  width: 114px;
  height: 292px;
  border-radius: 20px;
  padding: 16px 10px 38px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.22), transparent 22%, transparent 78%, rgba(0, 0, 0, 0.2)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.15)),
    #34542a;
  box-shadow:
    inset 0 0 0 3px rgba(35, 20, 12, 0.64),
    inset 0 0 26px rgba(0, 0, 0, 0.52),
    0 8px 18px rgba(0, 0, 0, 0.22);
}

.tray-right {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.22), transparent 22%, transparent 78%, rgba(0, 0, 0, 0.2)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0.16)),
    #6f2d25;
}

.tray-label {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  padding: 5px 8px;
  border-radius: 8px;
  color: #ead7a8;
  background: rgba(24, 15, 10, 0.72);
  text-align: center;
  font-size: 12px;
}

.tray-dice {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.tray-controls {
  display: flex;
  width: 114px;
  flex-direction: column;
  gap: 8px;
}

.tray-action {
  min-height: 38px;
  padding: 8px 7px;
  font-size: 13px;
}

.tray-action.danger {
  color: #fff3ec;
  background: linear-gradient(180deg, #d66a59, #872d26);
}

button:disabled,
.tray-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  filter: saturate(0.55);
}

.battle-board {
  position: relative;
  width: 570px;
  display: grid;
  gap: 14px;
  justify-self: center;
}

.field-row {
  display: grid;
  grid-template-columns: 232px 82px 232px;
  align-items: center;
  gap: 11px;
}

.field {
  min-height: 74px;
  border: 3px solid rgba(0, 0, 0, 0.55);
  border-radius: 14px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 22px;
  cursor: default;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.04), transparent 30%, rgba(0, 0, 0, 0.12)),
    repeating-linear-gradient(174deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 26px),
    var(--field);
  box-shadow:
    inset 0 0 0 1px rgba(255, 235, 188, 0.08),
    inset 0 10px 20px rgba(255, 255, 255, 0.025),
    inset 0 -12px 18px rgba(0, 0, 0, 0.18);
}

.field-left {
  justify-content: flex-end;
}

.field-right {
  justify-content: flex-start;
}

.field.legal {
  cursor: pointer;
  border-color: rgba(255, 239, 202, 0.74);
  box-shadow:
    0 0 20px rgba(255, 236, 182, 0.14),
    inset 0 0 0 1px rgba(255, 249, 225, 0.25);
}

.field.flick-hit {
  animation: fieldImpact 560ms ease-out;
}

.field.shield-hit {
  animation: shieldFieldImpact 620ms ease-out;
}

.score-bridge {
  display: grid;
  grid-template-columns: 1fr 26px 1fr;
  align-items: center;
  min-height: 52px;
  border-radius: 999px;
  background: rgba(26, 16, 10, 0.56);
  box-shadow: inset 0 0 0 1px rgba(255, 240, 185, 0.12);
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.score-left,
.score-right {
  font-size: 20px;
}

.score-left {
  color: #9bd377;
}

.score-right {
  color: #f18a79;
}

.arrow {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #ffd384;
  background: rgba(229, 105, 45, 0.72);
}

.arrow.left {
  color: #dfffc7;
  background: rgba(68, 150, 50, 0.76);
}

.arrow.right {
  color: #ffe2d8;
  background: rgba(201, 69, 52, 0.8);
}

.die {
  --pip: #cc4635;
  position: relative;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  padding: 0;
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.95), transparent 17%),
    linear-gradient(145deg, #fffdf3, #d9d0b9 72%, #b7a78d);
  box-shadow:
    inset -4px -5px 6px rgba(95, 66, 42, 0.25),
    inset 4px 5px 7px rgba(255, 255, 255, 0.8),
    0 4px 0 rgba(98, 56, 40, 0.68),
    0 8px 14px rgba(0, 0, 0, 0.32);
}

.die.player-0 {
  --pip: #5e8e35;
}

.die.player-1 {
  --pip: #d84836;
}

.die.clickable {
  cursor: pointer;
}

.die.shield {
  box-shadow:
    0 0 0 2px rgba(163, 255, 187, 0.8),
    0 0 22px rgba(91, 255, 158, 0.45),
    inset -4px -5px 6px rgba(95, 66, 42, 0.25),
    inset 4px 5px 7px rgba(255, 255, 255, 0.8),
    0 4px 0 rgba(55, 91, 56, 0.8),
    0 8px 14px rgba(0, 0, 0, 0.32);
  animation: shieldPulse 1.5s ease-in-out infinite;
}

.die.player-1.shield {
  animation-name: redShieldPulse;
  box-shadow:
    0 0 0 2px rgba(255, 158, 143, 0.82),
    0 0 22px rgba(255, 92, 83, 0.46),
    inset -4px -5px 6px rgba(95, 66, 42, 0.25),
    inset 4px 5px 7px rgba(255, 255, 255, 0.8),
    0 4px 0 rgba(121, 52, 45, 0.82),
    0 8px 14px rgba(0, 0, 0, 0.32);
}

.die::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 8px;
  border: 2px solid color-mix(in srgb, var(--pip) 62%, white);
  opacity: 0.72;
}

.die.shield::after {
  content: "🛡";
  position: absolute;
  right: -8px;
  bottom: -8px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #baffc8;
  color: #244c24;
  font-size: 12px;
  box-shadow: 0 0 12px rgba(135, 255, 157, 0.86);
}

.die.player-1.shield::after {
  background: #ffb6aa;
  color: #6f1e18;
  box-shadow: 0 0 12px rgba(255, 120, 104, 0.86);
}

.die.rolling {
  animation: tumbleIn 660ms cubic-bezier(0.1, 0.8, 0.25, 1.1);
}

.start-banner .die.rolling {
  animation-duration: 1980ms;
}

.tray-left .die.rolling {
  animation-name: tumbleInLeftTray;
}

.tray-right .die.rolling {
  animation-name: tumbleInRightTray;
}

.die.pop {
  animation: placePop 310ms ease-out;
}

.die.flicking {
  z-index: 3;
  pointer-events: none;
  animation: flickOut 540ms cubic-bezier(0.22, 0.75, 0.3, 1) forwards;
}

.field-right .die.flicking {
  animation-name: flickOutRight;
}

.die.victim-flick {
  z-index: 3;
  pointer-events: none;
  animation: victimFlickOut 620ms cubic-bezier(0.2, 0.76, 0.26, 1) forwards;
}

.field-right .die.victim-flick {
  animation-name: victimFlickOutRight;
}

.die.striking {
  z-index: 4;
  pointer-events: none;
  filter: brightness(1.08);
}

.die.striking.strike-right {
  animation: strikeToRight 620ms cubic-bezier(0.18, 0.78, 0.24, 1) forwards;
}

.die.striking.strike-left {
  animation: strikeToLeft 620ms cubic-bezier(0.18, 0.78, 0.24, 1) forwards;
}

.strike-flyer-shell {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 8;
  width: 46px;
  height: 46px;
  pointer-events: none;
  transform-origin: center;
  animation: strikeFly 820ms cubic-bezier(0.12, 0.76, 0.18, 1) forwards;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.36));
}

.strike-flyer-shell .die {
  animation: strikeFlySpin 820ms cubic-bezier(0.14, 0.78, 0.22, 1) forwards;
}

.die.shield-block {
  animation: shieldBlock 620ms ease-in-out;
}

.die.player-1.shield-block {
  animation-name: redShieldBlock;
}

.die.discard {
  animation: discardDie 360ms ease-in forwards;
}

.pips {
  position: absolute;
  inset: 11px;
}

.pip {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pip);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.pip.c {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.pip.tl {
  left: 0;
  top: 0;
}

.pip.tr {
  right: 0;
  top: 0;
}

.pip.ml {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.pip.mr {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.pip.bl {
  left: 0;
  bottom: 0;
}

.pip.br {
  right: 0;
  bottom: 0;
}

.combo-group {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px;
  margin: -3px;
  border-radius: 13px;
  box-shadow:
    inset 0 0 0 3px rgba(244, 89, 50, 0.78),
    0 0 18px rgba(255, 100, 64, 0.32);
}

.combo-link {
  width: 8px;
  height: 8px;
  border: 2px solid rgba(255, 105, 63, 0.9);
  border-radius: 3px;
}

.result-banner {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: calc(100% + 14px);
  transform: translateX(-50%);
  min-width: 260px;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 15px 22px 16px;
  border: 1px solid rgba(255, 232, 178, 0.32);
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 227, 150, 0.22), transparent 70%),
    rgba(25, 15, 10, 0.74);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.result-banner[hidden] {
  display: none;
}

.result-banner strong {
  color: #ffe4a4;
  font-size: 24px;
  font-weight: 950;
}

.audio-panel {
  position: absolute;
  z-index: 4;
  left: 18px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 232, 178, 0.2);
  border-radius: 999px;
  background: rgba(22, 13, 8, 0.58);
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(8px);
}

body:not(.in-room) .audio-panel {
  display: none;
}

.audio-panel button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #2b190d;
  background: linear-gradient(#ffe19a, #e8ac4d);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 3px 0 rgba(103, 58, 28, 0.62);
}

.audio-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f6d9a7;
  font-size: 13px;
  font-weight: 900;
}

.audio-panel input {
  width: 92px;
  accent-color: #ffd071;
}

.event-log {
  width: min(570px, calc(100% - 40px));
  max-height: 88px;
  overflow: auto;
  margin: 14px auto 0;
  padding: 10px 18px 10px 36px;
  border-radius: 16px;
  background: rgba(20, 12, 8, 0.48);
  color: rgba(255, 239, 211, 0.78);
  font-size: 13px;
}

@keyframes bannerPop {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-12px) scale(0.92);
  }
  68% {
    opacity: 1;
    transform: translateX(-50%) translateY(3px) scale(1.04);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes tumbleIn {
  0% {
    opacity: 0;
    transform: translateY(-74px) translateX(-30px) rotate(-132deg) scale(0.72);
  }
  42% {
    opacity: 1;
    transform: translateY(14px) translateX(18px) rotate(48deg) scale(1.08);
  }
  68% {
    transform: translateY(-9px) translateX(-4px) rotate(96deg) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) translateX(0) rotate(0) scale(1);
  }
}

@keyframes tumbleInRightTray {
  0% {
    opacity: 0;
    transform: translate(70px, -28px) rotate(92deg) scale(0.78);
  }
  16% {
    opacity: 1;
    transform: translate(38px, -18px) rotate(146deg) scale(0.92);
  }
  32% {
    transform: translate(10px, 15px) rotate(218deg) scale(1.08);
  }
  48% {
    transform: translate(-7px, 4px) rotate(284deg) scale(1.02);
  }
  64% {
    transform: translate(5px, -7px) rotate(334deg) scale(0.96);
  }
  82% {
    transform: translate(-2px, 3px) rotate(378deg) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(360deg) scale(1);
  }
}

@keyframes tumbleInLeftTray {
  0% {
    opacity: 0;
    transform: translate(-70px, -28px) rotate(-92deg) scale(0.78);
  }
  16% {
    opacity: 1;
    transform: translate(-38px, -18px) rotate(-146deg) scale(0.92);
  }
  32% {
    transform: translate(-10px, 15px) rotate(-218deg) scale(1.08);
  }
  48% {
    transform: translate(7px, 4px) rotate(-284deg) scale(1.02);
  }
  64% {
    transform: translate(-5px, -7px) rotate(-334deg) scale(0.96);
  }
  82% {
    transform: translate(2px, 3px) rotate(-378deg) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(-360deg) scale(1);
  }
}

@keyframes placePop {
  0% {
    transform: scale(0.7) translateY(-14px);
    opacity: 0.4;
  }
  62% {
    transform: scale(1.13) translateY(0);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

@keyframes flickOut {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
    filter: brightness(1);
  }
  35% {
    opacity: 1;
    transform: translate(-28px, -42px) rotate(-130deg) scale(1.12);
    filter: brightness(1.25);
  }
  100% {
    opacity: 0;
    transform: translate(-70px, 34px) rotate(-310deg) scale(0.72);
    filter: brightness(0.9);
  }
}

@keyframes flickOutRight {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  35% {
    opacity: 1;
    transform: translate(30px, -42px) rotate(132deg) scale(1.12);
  }
  100% {
    opacity: 0;
    transform: translate(74px, 34px) rotate(320deg) scale(0.72);
  }
}

@keyframes victimFlickOut {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
    filter: brightness(1);
  }
  34% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
    filter: brightness(1);
  }
  48% {
    opacity: 1;
    transform: translate(-18px, -9px) rotate(-54deg) scale(1.1);
    filter: brightness(1.28);
  }
  66% {
    opacity: 0.85;
    transform: translate(-45px, -28px) rotate(-154deg) scale(0.96);
  }
  100% {
    opacity: 0;
    transform: translate(-86px, -54px) rotate(-330deg) scale(0.64);
    filter: brightness(0.85);
  }
}

@keyframes victimFlickOutRight {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
    filter: brightness(1);
  }
  34% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
    filter: brightness(1);
  }
  48% {
    opacity: 1;
    transform: translate(18px, -9px) rotate(54deg) scale(1.1);
    filter: brightness(1.28);
  }
  66% {
    opacity: 0.85;
    transform: translate(45px, -28px) rotate(154deg) scale(0.96);
  }
  100% {
    opacity: 0;
    transform: translate(86px, -54px) rotate(330deg) scale(0.64);
    filter: brightness(0.85);
  }
}

@keyframes strikeFly {
  0% {
    opacity: 0;
    transform: translate(calc(var(--from-x) - 23px), calc(var(--from-y) - 23px)) scale(0.78);
    filter: brightness(1) drop-shadow(0 8px 10px rgba(0, 0, 0, 0.28));
  }
  8% {
    opacity: 1;
    transform: translate(calc(var(--from-x) - 23px), calc(var(--from-y) - 23px)) scale(0.92);
  }
  42% {
    opacity: 1;
    transform: translate(calc(var(--mid-x) - 23px), calc(var(--mid-y) - 23px)) scale(1.08);
    filter: brightness(1.18) drop-shadow(0 18px 16px rgba(0, 0, 0, 0.24));
  }
  70% {
    opacity: 1;
    transform: translate(calc(var(--to-x) - 23px), calc(var(--to-y) - 23px)) scale(1.16);
    filter: brightness(1.34) drop-shadow(0 0 18px rgba(255, 166, 92, 0.56));
  }
  86% {
    opacity: 0.9;
    transform: translate(calc(var(--to-x) - 21px), calc(var(--to-y) - 29px)) scale(0.88);
  }
  100% {
    opacity: 0;
    transform: translate(calc(var(--to-x) - 16px), calc(var(--to-y) - 42px)) scale(0.62);
    filter: brightness(0.92) drop-shadow(0 0 0 rgba(0, 0, 0, 0));
  }
}

@keyframes strikeFlySpin {
  0% {
    transform: rotate(-60deg);
  }
  42% {
    transform: rotate(260deg);
  }
  70% {
    transform: rotate(520deg);
  }
  100% {
    transform: rotate(690deg);
  }
}

@keyframes strikeToRight {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  18% {
    opacity: 1;
    transform: translate(26px, -2px) rotate(30deg) scale(1.03);
  }
  38% {
    opacity: 1;
    transform: translate(58px, -2px) rotate(72deg) scale(1.08);
    filter: brightness(1.35);
  }
  52% {
    opacity: 1;
    transform: translate(78px, -4px) rotate(108deg) scale(1.02);
    filter: brightness(1.45);
  }
  68% {
    opacity: 0.86;
    transform: translate(96px, -12px) rotate(152deg) scale(0.9);
  }
  100% {
    opacity: 0;
    transform: translate(122px, -30px) rotate(238deg) scale(0.68);
    filter: brightness(0.92);
  }
}

@keyframes strikeToLeft {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  18% {
    opacity: 1;
    transform: translate(-26px, -2px) rotate(-30deg) scale(1.03);
  }
  38% {
    opacity: 1;
    transform: translate(-58px, -2px) rotate(-72deg) scale(1.08);
    filter: brightness(1.35);
  }
  52% {
    opacity: 1;
    transform: translate(-78px, -4px) rotate(-108deg) scale(1.02);
    filter: brightness(1.45);
  }
  68% {
    opacity: 0.86;
    transform: translate(-96px, -12px) rotate(-152deg) scale(0.9);
  }
  100% {
    opacity: 0;
    transform: translate(-122px, -30px) rotate(-238deg) scale(0.68);
    filter: brightness(0.92);
  }
}

@keyframes shieldPulse {
  0%,
  100% {
    filter: drop-shadow(0 0 0 rgba(124, 255, 166, 0));
  }
  50% {
    filter: drop-shadow(0 0 10px rgba(124, 255, 166, 0.58));
  }
}

@keyframes redShieldPulse {
  0%,
  100% {
    filter: drop-shadow(0 0 0 rgba(255, 121, 106, 0));
  }
  50% {
    filter: drop-shadow(0 0 10px rgba(255, 121, 106, 0.6));
  }
}

@keyframes shieldBlock {
  0%,
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
  30% {
    transform: scale(1.16);
    filter: brightness(1.45) drop-shadow(0 0 16px rgba(146, 255, 188, 0.85));
  }
  60% {
    transform: scale(0.96);
  }
}

@keyframes redShieldBlock {
  0%,
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
  30% {
    transform: scale(1.16);
    filter: brightness(1.42) drop-shadow(0 0 16px rgba(255, 125, 108, 0.86));
  }
  60% {
    transform: scale(0.96);
  }
}

@keyframes discardDie {
  to {
    opacity: 0;
    transform: translateY(44px) rotate(55deg) scale(0.6);
  }
}

@keyframes fieldImpact {
  0%,
  100% {
    transform: translateX(0);
    border-color: rgba(0, 0, 0, 0.55);
  }
  28% {
    transform: translateX(-4px);
    border-color: rgba(255, 112, 70, 0.92);
    box-shadow:
      0 0 22px rgba(255, 109, 72, 0.28),
      inset 0 0 0 1px rgba(255, 180, 138, 0.3);
  }
  54% {
    transform: translateX(4px);
  }
}

@keyframes shieldFieldImpact {
  0%,
  100% {
    box-shadow:
      inset 0 0 0 1px rgba(255, 235, 188, 0.08),
      inset 0 10px 20px rgba(255, 255, 255, 0.025),
      inset 0 -12px 18px rgba(0, 0, 0, 0.18);
  }
  36% {
    box-shadow:
      0 0 24px rgba(119, 255, 161, 0.38),
      inset 0 0 0 2px rgba(143, 255, 179, 0.68);
  }
}

@media (max-width: 900px) {
  .app {
    width: 100%;
    padding: 0;
  }

  .table {
    border-radius: 0;
  }

  .topbar {
    grid-template-columns: 1fr;
    height: auto;
  }

  .player-card {
    width: 100%;
  }

  .board-wrap {
    grid-template-columns: 1fr;
    height: auto;
  }

  .battle-board {
    order: -1;
    transform: scale(0.85);
  }
}
