:root {
  --red: #ee3437;
  --yellow: #f7c934;
  --green: #26ad57;
  --blue: #2f7eea;
  --ink: #08172b;
  --muted: #6e7f94;
  --panel: rgba(12, 28, 62, 0.9);
  --panel-soft: rgba(18, 44, 88, 0.76);
  --line: rgba(155, 229, 255, 0.54);
  --glow: rgba(91, 222, 255, 0.36);
  --radius: 10px;
  --header-h: 74px;
  --top-row: clamp(166px, 15dvh, 190px);
  --hand-row: clamp(218px, 22dvh, 264px);
  --card-w: clamp(76px, 6.1vw, 98px);
  --card-h: calc(var(--card-w) * 1.42);
  --pile-w: clamp(104px, 8.4vw, 128px);
  --pile-h: calc(var(--pile-w) * 1.42);
}

* {
  box-sizing: border-box;
}

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

body {
  color: #f7fbff;
  background:
    radial-gradient(circle at 50% 24%, rgba(86, 217, 255, 0.42), transparent 24rem),
    radial-gradient(circle at 12% 24%, rgba(79, 82, 184, 0.45), transparent 20rem),
    radial-gradient(circle at 88% 28%, rgba(36, 139, 232, 0.34), transparent 22rem),
    linear-gradient(135deg, #071126 0%, #17164a 42%, #123b6e 72%, #06101f 100%);
  font-family: Arial, Helvetica, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: -24%;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.16) 0 3px, transparent 4px),
    radial-gradient(circle at 80% 16%, rgba(255, 255, 255, 0.13) 0 3px, transparent 4px),
    repeating-conic-gradient(from -18deg at 50% 50%, rgba(142, 220, 255, 0.1) 0deg 7deg, transparent 7deg 20deg),
    radial-gradient(circle at 50% 47%, rgba(83, 225, 255, 0.28), transparent 32rem);
  opacity: 0.95;
}

button {
  font: inherit;
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--header-h) minmax(0, 1fr);
  gap: 8px;
  padding: 8px 16px 10px;
}

.top-bar {
  display: flex;
  min-height: 0;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 12px;
  color: #fff;
  background: linear-gradient(180deg, rgba(20, 39, 84, 0.86), rgba(7, 16, 39, 0.92));
  border: 2px solid rgba(191, 242, 255, 0.86);
  border-radius: 10px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.16),
    0 0 30px var(--glow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: #fff;
  background: conic-gradient(from 45deg, var(--red), var(--yellow), var(--green), var(--blue), var(--red));
  border: 3px solid rgba(255, 255, 255, 0.96);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.16), 0 0 24px rgba(255, 214, 56, 0.48);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.35rem, 2.1vw, 1.8rem);
  line-height: 1;
}

.brand p {
  margin-top: 4px;
  color: #d7e6f7;
  font-size: 0.94rem;
}

.top-controls,
.human-actions,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-block {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-label {
  color: #dcecff;
  font-weight: 900;
  white-space: nowrap;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  overflow: hidden;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
}

.level-button,
.plain-button,
.action-button,
.start-button {
  min-height: 40px;
  border: 0;
  cursor: pointer;
  font-weight: 900;
}

.level-button {
  padding: 0 14px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-right: 1px solid rgba(255, 255, 255, 0.22);
}

.level-button:last-child {
  border-right: 0;
}

.level-button.is-active,
.plain-button {
  color: #fff;
  background: linear-gradient(180deg, #273d5c, #101d30);
}

.plain-button,
.action-button {
  padding: 0 16px;
  border-radius: 8px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.26);
  white-space: nowrap;
}

.action-button {
  color: #fff;
  background: linear-gradient(180deg, #ff4c44, #d31028);
  border: 1px solid rgba(255, 255, 255, 0.36);
  box-shadow: 0 10px 20px rgba(192, 16, 34, 0.35);
}

.action-button.secondary {
  color: #142033;
  background: linear-gradient(180deg, #fff, #dfeaf7);
  border-color: #c7d7e8;
}

.action-button:disabled,
.draw-pile:disabled {
  cursor: not-allowed;
}

.action-button:disabled {
  color: #708095;
  background: linear-gradient(180deg, #f3f8fd, #d9e5f2);
  box-shadow: none;
}

.game-board {
  position: relative;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: var(--top-row) minmax(0, 1fr) var(--hand-row);
  gap: 10px;
  overflow: hidden;
  padding: 14px 18px;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(114, 229, 255, 0.66), rgba(35, 132, 220, 0.5) 34%, rgba(36, 45, 124, 0.72) 62%, rgba(8, 12, 33, 0.92) 100%),
    linear-gradient(135deg, #1b2e7d, #123a70 45%, #071126);
  border: 2px solid rgba(126, 226, 255, 0.7);
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 0 34px rgba(67, 210, 255, 0.28),
    inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.game-board::before,
.game-board::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.game-board::before {
  inset: -28%;
  background:
    radial-gradient(circle at 50% 48%, rgba(234, 255, 255, 0.3), transparent 18rem),
    repeating-conic-gradient(from 4deg at 50% 49%, rgba(143, 222, 255, 0.18) 0deg 8deg, transparent 8deg 20deg);
  opacity: 0.92;
}

.game-board::after {
  left: 4%;
  right: 4%;
  top: 16%;
  bottom: 18%;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(ellipse at 50% 50%, rgba(100, 222, 235, 0.78), rgba(42, 133, 190, 0.78) 48%, rgba(17, 48, 114, 0.9));
  background-size: 32px 32px, 32px 32px, auto;
  border: 6px solid rgba(116, 230, 255, 0.42);
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 4px rgba(255, 255, 255, 0.12),
    inset 0 0 80px rgba(156, 240, 255, 0.34),
    0 18px 42px rgba(0, 0, 0, 0.36);
}

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

.cpu-strip-top {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.table-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(190px, 230px) minmax(420px, 1fr) minmax(190px, 230px);
  gap: 16px;
  align-items: stretch;
}

.cpu-side {
  min-height: 0;
  display: flex;
  align-items: center;
}

.cpu-side-right {
  justify-content: flex-end;
}

.player-panel {
  width: min(100%, 230px);
  min-height: 166px;
  max-height: 100%;
  display: grid;
  grid-template-rows: 34px 38px minmax(54px, 1fr);
  gap: 6px;
  overflow: hidden;
  padding: 12px;
  color: #fff;
  background: linear-gradient(180deg, rgba(23, 42, 87, 0.94), rgba(8, 18, 44, 0.9));
  border: 2px solid rgba(152, 224, 255, 0.42);
  border-radius: 14px;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.34), inset 0 1px rgba(255, 255, 255, 0.14);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.cpu-strip-top .player-panel {
  width: min(230px, 100%);
  min-height: 166px;
}

.player-panel.is-active {
  transform: translateY(-3px);
  border-color: rgba(255, 242, 130, 0.92);
  box-shadow: 0 0 0 4px rgba(255, 227, 74, 0.34), 0 0 30px rgba(255, 73, 43, 0.32), 0 16px 28px rgba(0, 0, 0, 0.32);
}

.player-name-line {
  min-width: 0;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.player-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: #fff;
  background: linear-gradient(135deg, #ff4639, #ffc536 52%, #2177ef);
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  font-size: 0.74rem;
  font-weight: 900;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.26);
}

.player-name,
.card-total {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.card-total {
  color: #edf7ff;
}

.mini-card-row {
  min-width: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding-left: 4px;
}

.mini-card {
  flex: 0 0 22px;
  width: 22px;
  height: 32px;
  margin-left: -3px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.95) 0 18%, transparent 19%),
    linear-gradient(135deg, #e93436 0 25%, #ffd23f 25% 50%, #20b15a 50% 75%, #2a76ee 75%);
  border: 2px solid #fff;
  border-radius: 5px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.28);
}

.last-play {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 18px minmax(0, 1fr);
  gap: 3px;
  overflow: hidden;
  padding: 7px 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
}

.last-label,
.feed-title {
  color: #ffe45f;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.last-empty,
.last-draw {
  min-width: 0;
  align-self: center;
  overflow: hidden;
  color: #e8f2ff;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.last-draw {
  justify-self: start;
  padding: 5px 9px;
  color: #102031;
  background: linear-gradient(180deg, #fff6c4, #ffca3d);
  border-radius: 999px;
  font-size: 0.82rem;
}

.last-card-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 900;
}

.last-card-wrap span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-center {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: 38px minmax(0, 1fr) 78px 44px;
  align-items: center;
  justify-items: center;
  gap: 10px;
  overflow: visible;
  padding: 10px;
}

.direction-ring {
  position: absolute;
  left: 50%;
  top: 49%;
  z-index: 0;
  width: min(820px, 96%);
  height: min(350px, 76%);
  pointer-events: none;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  opacity: 0.7;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(218, 255, 255, 0.16), transparent 52%),
    radial-gradient(ellipse at 50% 50%, transparent 42%, rgba(112, 232, 255, 0.28) 43%, rgba(112, 232, 255, 0.12) 53%, transparent 55%);
}

.direction-ring::before {
  content: "";
  position: absolute;
  inset: 30px 48px;
  border: 9px solid rgba(220, 255, 255, 0.16);
  border-radius: 50%;
  box-shadow: 0 0 24px rgba(89, 235, 255, 0.26), inset 0 0 24px rgba(89, 235, 255, 0.16);
}

.flow-arrow {
  position: absolute;
  width: clamp(70px, 8vw, 108px);
  height: clamp(28px, 3.1vw, 42px);
  opacity: 0.74;
  background: linear-gradient(90deg, rgba(237, 255, 255, 0), rgba(237, 255, 255, 0.78) 44%, #ffffff 82%);
  clip-path: polygon(0 34%, 62% 34%, 62% 12%, 100% 50%, 62% 88%, 62% 66%, 0 66%);
  filter: drop-shadow(0 0 12px rgba(103, 236, 255, 0.76));
  transition: transform 220ms ease, opacity 220ms ease;
}

.flow-arrow-top {
  left: 58%;
  top: 14%;
  transform: translate(-50%, -50%);
}

.flow-arrow-right {
  right: 7%;
  top: 50%;
  transform: translate(50%, -50%) rotate(90deg);
}

.flow-arrow-bottom {
  left: 42%;
  bottom: 14%;
  transform: translate(-50%, 50%) rotate(180deg);
}

.flow-arrow-left {
  left: 7%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(270deg);
}

.game-board.is-counter .flow-arrow-top {
  transform: translate(-50%, -50%) rotate(180deg);
}

.game-board.is-counter .flow-arrow-right {
  transform: translate(50%, -50%) rotate(270deg);
}

.game-board.is-counter .flow-arrow-bottom {
  transform: translate(-50%, 50%);
}

.game-board.is-counter .flow-arrow-left {
  transform: translate(-50%, -50%) rotate(90deg);
}

.status-line,
.pile-row,
.start-panel,
.play-feed,
.message-box {
  position: relative;
  z-index: 2;
}

.status-line {
  min-width: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.status-pill {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  color: #fff;
  background: linear-gradient(180deg, rgba(18, 31, 48, 0.96), rgba(8, 17, 30, 0.96));
  border-radius: 8px;
  box-shadow: 0 7px 12px rgba(0, 0, 0, 0.24);
  font-weight: 900;
  white-space: nowrap;
}

.color-pill.red {
  background: var(--red);
}

.color-pill.yellow {
  color: #2a2200;
  background: var(--yellow);
}

.color-pill.green {
  background: var(--green);
}

.color-pill.blue {
  background: var(--blue);
}

.color-pill.neutral {
  color: #0d1b2c;
  background: linear-gradient(180deg, #ffffff, #c8d5e5);
}

.pile-row {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(46px, 7vw, 88px);
}

.pile {
  width: var(--pile-w);
  height: var(--pile-h);
  border: 5px solid rgba(255, 255, 255, 0.96);
  border-radius: 12px;
  box-shadow: 0 18px 28px rgba(0, 0, 0, 0.36), 0 0 0 5px rgba(0, 0, 0, 0.14);
  transform: rotateX(5deg);
}

.draw-pile {
  display: grid;
  place-items: center;
  gap: 4px;
  color: #fff;
  background:
    radial-gradient(circle at 50% 54%, #fff 0 10%, transparent 11%),
    conic-gradient(from 28deg, #fb3340, #ffcf35, #22b960, #2478f4, #fb3340);
}

.draw-pile:disabled {
  filter: grayscale(0.18) brightness(0.9);
}

.pile-title {
  font-size: 1.15rem;
  font-weight: 900;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.36);
}

.pile-count {
  display: inline-flex;
  min-width: 34px;
  min-height: 27px;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: #fff;
  border-radius: 999px;
  font-weight: 900;
}

.discard-pile {
  display: grid;
  place-items: center;
  background: rgba(196, 247, 255, 0.24);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.36), 0 18px 28px rgba(0, 0, 0, 0.36);
}

.pile-placeholder {
  display: grid;
  place-items: center;
  width: 82%;
  height: 82%;
  color: rgba(255, 255, 255, 0.92);
  border: 3px dashed rgba(255, 255, 255, 0.58);
  border-radius: 10px;
  font-weight: 900;
}

.start-panel {
  min-width: 0;
  width: min(300px, 100%);
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 16px 20px;
  color: #fff;
  background: rgba(7, 15, 28, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.3);
}

.start-panel.is-hidden {
  display: none;
}

.start-panel span {
  max-width: 100%;
  overflow: hidden;
  color: #dbe8f6;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.start-button {
  min-width: 188px;
  min-height: 58px;
  color: #fff;
  background: linear-gradient(180deg, #ffdf4d, #ff7926 46%, #e51d2f);
  border: 3px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  box-shadow: 0 12px 22px rgba(194, 31, 22, 0.42), 0 0 24px rgba(255, 219, 68, 0.44);
  font-size: 1.1rem;
}

.play-feed {
  width: min(760px, 100%);
  height: 78px;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  overflow: hidden;
  padding: 9px 12px;
  color: #fff;
  background: rgba(8, 19, 47, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), 0 12px 22px rgba(0, 0, 0, 0.24);
}

.feed-list {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  overflow: hidden;
}

.feed-item {
  min-width: 0;
  height: 58px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "player player"
    "card text";
  align-items: center;
  gap: 3px 7px;
  overflow: hidden;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 10px;
}

.feed-player {
  grid-area: player;
  min-width: 0;
  overflow: hidden;
  color: #b9d9ff;
  font-size: 0.74rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-card,
.feed-chip {
  grid-area: card;
}

.feed-text {
  grid-area: text;
  min-width: 0;
  overflow: hidden;
  color: #fff;
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1.08;
  text-overflow: ellipsis;
}

.feed-chip {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  min-height: 26px;
  color: #172235;
  background: linear-gradient(180deg, #fff7c9, #ffc531);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 900;
}

.feed-empty {
  min-width: 0;
  overflow: hidden;
  color: #dbe8f6;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-box {
  width: min(620px, 100%);
  height: 44px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px 14px;
  color: #0d1b2c;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(229, 241, 248, 0.98));
  border: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: 13px;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.22);
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.human-panel {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: 42px minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
  padding: 14px 16px 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(229, 244, 242, 0.92));
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 14px;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.82), 0 14px 24px rgba(0, 0, 0, 0.22);
}

.human-header {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.player-title {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--ink);
  font-weight: 900;
}

.player-title .card-total {
  color: var(--muted);
}

.human-actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.hand-scroll {
  min-height: 0;
  height: 100%;
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 14px 8px 6px;
  scrollbar-width: none;
}

.hand-scroll::-webkit-scrollbar {
  display: none;
}

.card {
  position: relative;
  flex: 0 0 var(--card-w);
  width: var(--card-w);
  height: var(--card-h);
  display: grid;
  place-items: center;
  margin-right: -6px;
  overflow: hidden;
  color: #fff;
  background: #333;
  border: 5px solid rgba(255, 255, 255, 0.97);
  border-radius: 12px;
  box-shadow: 0 10px 15px rgba(20, 28, 39, 0.28), inset 0 0 0 2px rgba(255, 255, 255, 0.2);
  font-weight: 900;
  scroll-snap-align: start;
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
  user-select: none;
}

button.card {
  cursor: pointer;
}

.card::before,
.mini-face-card::before {
  content: "";
  position: absolute;
  inset: 13px 9px;
  border: 4px solid rgba(255, 255, 255, 0.88);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  transform: rotate(-18deg);
}

.card::after,
.mini-face-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(110deg, rgba(255, 255, 255, 0.34), transparent 34%, transparent 70%, rgba(0, 0, 0, 0.15));
}

.card-symbol {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: calc(var(--card-w) - 18px);
  min-height: 38px;
  padding: 4px;
  color: inherit;
  text-align: center;
  font-size: clamp(1.2rem, 1.8vw, 1.72rem);
  line-height: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.36);
}

.card.small-text .card-symbol {
  font-size: clamp(0.72rem, 1.05vw, 1rem);
}

.card-corner {
  position: absolute;
  z-index: 1;
  left: 7px;
  top: 6px;
  font-size: clamp(0.58rem, 0.82vw, 0.82rem);
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.card-corner.bottom {
  inset: auto 7px 6px auto;
  transform: rotate(180deg);
}

.card.red,
.mini-face-card.red {
  background: var(--red);
}

.card.yellow,
.mini-face-card.yellow {
  color: #2a2200;
  background: var(--yellow);
}

.card.yellow .card-symbol,
.card.yellow .card-corner,
.mini-face-card.yellow .card-symbol,
.mini-face-card.yellow .card-corner {
  text-shadow: none;
}

.card.green,
.mini-face-card.green {
  background: var(--green);
}

.card.blue,
.mini-face-card.blue {
  background: var(--blue);
}

.card.wild,
.mini-face-card.wild {
  background:
    linear-gradient(135deg, var(--red) 0 24%, var(--yellow) 24% 50%, var(--green) 50% 76%, var(--blue) 76%),
    #171d24;
}

.card.wild::after {
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.25), transparent 34%, transparent 70%, rgba(0, 0, 0, 0.24)),
    rgba(0, 0, 0, 0.12);
}

.card.is-playable {
  transform: translateY(-10px);
  filter: saturate(1.14);
  box-shadow: 0 0 0 4px #fff, 0 0 0 9px rgba(255, 222, 69, 0.9), 0 20px 26px rgba(0, 0, 0, 0.34);
}

button.card:hover {
  transform: translateY(-10px) rotate(-1deg);
}

.discard-pile .card {
  --card-w: calc(var(--pile-w) * 0.74);
  transform: none;
  margin-right: 0;
  pointer-events: none;
}

.card.is-played {
  animation: play-pop 220ms ease-out;
}

.hand-scroll .card:not(.is-playable) {
  opacity: 0.96;
}

.mini-face-card {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 52px;
  overflow: hidden;
  color: #fff;
  border: 3px solid #fff;
  border-radius: 7px;
  box-shadow: 0 7px 11px rgba(0, 0, 0, 0.28);
}

.mini-face-card::before {
  inset: 8px 5px;
  border-width: 2px;
}

.mini-face-card .card-symbol {
  width: 30px;
  min-height: 18px;
  font-size: 0.78rem;
}

.mini-face-card.small-text .card-symbol {
  font-size: 0.5rem;
}

.mini-face-card .card-corner {
  left: 3px;
  top: 2px;
  font-size: 0.46rem;
}

.mini-face-card .card-corner.bottom {
  inset: auto 3px 2px auto;
}

.play-feed .mini-face-card {
  width: 32px;
  height: 44px;
  border-width: 2px;
}

.play-feed .mini-face-card .card-symbol {
  width: 25px;
  font-size: 0.64rem;
}

.play-feed .mini-face-card.small-text .card-symbol {
  font-size: 0.43rem;
}

.action-button.needs-draw {
  animation: draw-breathe 1.05s ease-in-out infinite;
  background: linear-gradient(180deg, #ffe66b, #ff9e24 45%, #f03325);
  box-shadow: 0 0 0 0 rgba(255, 226, 80, 0.84), 0 0 28px rgba(255, 191, 51, 0.75);
}

.draw-pile.needs-draw {
  animation: draw-pile-breathe 1.05s ease-in-out infinite;
}

.game-board.is-waiting {
  grid-template-rows: 76px minmax(0, 1fr) 72px;
}

.game-board.is-waiting .player-panel {
  min-height: 56px;
  max-height: 60px;
  grid-template-rows: 1fr;
}

.game-board.is-waiting .mini-card-row,
.game-board.is-waiting .last-play,
.game-board.is-waiting .play-feed {
  display: none;
}

.game-board.is-waiting .table-center {
  grid-template-rows: 38px minmax(0, 1fr) 118px 44px;
}

.game-board.is-waiting .direction-ring {
  opacity: 0.32;
}

.game-board.is-waiting .flow-arrow {
  opacity: 0;
}

.game-board.is-waiting .human-panel {
  height: 100%;
  grid-template-rows: 1fr;
  align-content: center;
}

.game-board.is-waiting .hand-scroll {
  display: none;
}

.game-board.is-waiting .human-header {
  min-height: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 8, 20, 0.76);
}

.modal-backdrop.is-hidden {
  display: none;
}

.modal-card {
  width: min(460px, 100%);
  max-height: calc(100dvh - 36px);
  overflow: auto;
  padding: 22px;
  color: #07172b;
  background: #fff;
  border: 2px solid #fff;
  border-radius: 8px;
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.38), 0 0 34px rgba(86, 217, 255, 0.18);
  text-align: center;
  animation: modal-in 180ms ease-out;
}

.small-modal {
  width: min(360px, 100%);
}

.modal-card h2 {
  margin-bottom: 14px;
  color: #0a1b31;
}

.winner-name {
  margin-bottom: 12px;
  color: var(--red);
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 900;
}

.round-summary {
  display: grid;
  gap: 6px;
  margin: 12px 0 16px;
  color: #102033;
  text-align: left;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  color: #08192d;
  background: #eaf3ff;
  border-radius: 8px;
  font-weight: 900;
}

.color-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.color-choice {
  min-height: 62px;
  color: #fff;
  border: 4px solid #fff;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
  box-shadow: 0 6px 14px rgba(24, 32, 42, 0.18);
}

.color-choice.red {
  background: var(--red);
}

.color-choice.yellow {
  color: #2a2200;
  background: var(--yellow);
}

.color-choice.green {
  background: var(--green);
}

.color-choice.blue {
  background: var(--blue);
}

@keyframes play-pop {
  from {
    transform: scale(0.92) translateY(8px);
  }
  to {
    transform: scale(1) translateY(0);
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes draw-breathe {
  0%,
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 0 0 rgba(255, 226, 80, 0.78), 0 0 24px rgba(255, 191, 51, 0.6);
  }
  50% {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 0 0 8px rgba(255, 226, 80, 0), 0 0 36px rgba(255, 235, 92, 0.92);
  }
}

@keyframes draw-pile-breathe {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.16);
    box-shadow: 0 18px 28px rgba(0, 0, 0, 0.36), 0 0 0 8px rgba(255, 225, 76, 0.76), 0 0 34px rgba(255, 230, 77, 0.82);
  }
}

@media (max-height: 860px) and (min-width: 901px) {
  :root {
    --header-h: 60px;
    --top-row: 142px;
    --hand-row: 184px;
    --card-w: 72px;
    --pile-w: 96px;
  }

  .app-shell {
    gap: 6px;
    padding: 6px 10px 8px;
  }

  .top-bar {
    padding: 6px 10px;
  }

  .brand-mark {
    flex-basis: 44px;
    width: 44px;
    height: 44px;
  }

  h1 {
    font-size: 1.42rem;
  }

  .brand p {
    font-size: 0.84rem;
  }

  .level-button,
  .plain-button,
  .action-button {
    min-height: 36px;
  }

  .game-board {
    gap: 6px;
    padding: 8px 14px;
  }

  .table-grid {
    grid-template-columns: minmax(184px, 220px) minmax(380px, 1fr) minmax(184px, 220px);
  }

  .player-panel {
    min-height: 134px;
    grid-template-rows: 30px 32px minmax(40px, 1fr);
    gap: 5px;
    padding: 10px;
  }

  .cpu-strip-top .player-panel {
    min-height: 134px;
  }

  .player-name-line {
    grid-template-columns: 30px minmax(0, 1fr) auto;
  }

  .mini-card {
    flex-basis: 20px;
    width: 20px;
    height: 30px;
  }

  .last-play {
    grid-template-rows: 0 minmax(0, 1fr);
    gap: 0;
    min-height: 38px;
    padding: 5px 8px;
  }

  .last-label {
    display: none;
  }

  .last-empty,
  .last-draw {
    font-size: 0.88rem;
  }

  .last-card-wrap {
    font-size: 0.74rem;
  }

  .last-card {
    width: 28px;
    height: 38px;
    border-width: 2px;
  }

  .last-card .card-symbol {
    width: 22px;
    font-size: 0.58rem;
  }

  .last-card.small-text .card-symbol {
    font-size: 0.42rem;
  }

  .table-center {
    grid-template-rows: 34px minmax(0, 1fr) 66px 40px;
    gap: 6px;
    padding: 8px;
  }

  .status-pill {
    min-height: 32px;
    padding: 0 11px;
    font-size: 0.94rem;
  }

  .play-feed {
    height: 66px;
    grid-template-columns: 82px minmax(0, 1fr);
    padding: 7px 10px;
  }

  .feed-item {
    height: 52px;
    padding: 5px 7px;
  }

  .message-box {
    height: 40px;
  }

  .human-panel {
    grid-template-rows: 36px minmax(0, 1fr);
    gap: 6px;
    padding: 10px 14px;
  }

  .hand-scroll {
    padding-top: 8px;
    padding-bottom: 4px;
  }

  .card {
    border-width: 4px;
  }

  .card-symbol {
    font-size: 1.3rem;
  }

  .card.small-text .card-symbol {
    font-size: 0.78rem;
  }
}

@media (max-width: 900px) {
  :root {
    --header-h: 132px;
    --top-row: 116px;
    --hand-row: 158px;
    --card-w: 64px;
    --pile-w: 78px;
  }

  .app-shell {
    gap: 6px;
    padding: 6px;
  }

  .top-bar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 6px 8px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
    border-width: 2px;
    font-size: 0.66rem;
  }

  h1 {
    font-size: 1.16rem;
  }

  .brand p {
    display: none;
  }

  .top-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .control-block {
    display: grid;
    grid-template-columns: 66px 1fr;
    gap: 6px;
  }

  .control-label {
    font-size: 0.78rem;
  }

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

  .level-button,
  .plain-button,
  .action-button {
    min-height: 32px;
    padding: 0 8px;
    font-size: 0.86rem;
  }

  .game-board {
    gap: 6px;
    padding: 6px;
  }

  .game-board::after {
    left: 4%;
    right: 4%;
    top: 22%;
    bottom: 24%;
  }

  .cpu-strip-top {
    align-items: start;
  }

  .table-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 54px minmax(0, 1fr) 54px;
    gap: 6px;
  }

  .cpu-side-left {
    order: 0;
  }

  .table-center {
    order: 1;
    grid-template-rows: 30px minmax(0, 1fr) 62px 36px;
    gap: 4px;
    padding: 4px 0;
  }

  .cpu-side-right {
    order: 2;
  }

  .cpu-side {
    display: block;
  }

  .player-panel,
  .cpu-strip-top .player-panel {
    width: 100%;
    min-height: 50px;
    max-height: 54px;
    grid-template-rows: 1fr;
    padding: 6px 8px;
    border-radius: 10px;
  }

  .player-panel.is-active {
    transform: translateY(-1px);
  }

  .mini-card-row,
  .last-play {
    display: none;
  }

  .status-line {
    gap: 4px;
  }

  .status-pill {
    min-height: 26px;
    padding: 0 7px;
    font-size: 0.72rem;
  }

  .pile-row {
    gap: 28px;
  }

  .pile {
    border-width: 4px;
  }

  .direction-ring {
    width: min(360px, 92%);
    height: min(190px, 70%);
  }

  .direction-ring::before {
    inset: 22px 34px;
    border-width: 7px;
  }

  .flow-arrow {
    width: 62px;
    height: 26px;
  }

  .play-feed {
    height: 62px;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 5px;
    padding: 5px 6px;
    border-radius: 10px;
  }

  .feed-title {
    font-size: 0.62rem;
  }

  .feed-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .feed-item {
    height: 50px;
    gap: 2px 5px;
    padding: 4px 5px;
    border-radius: 8px;
  }

  .feed-player,
  .feed-text {
    font-size: 0.62rem;
  }

  .play-feed .mini-face-card {
    width: 30px;
    height: 42px;
  }

  .message-box {
    height: 36px;
    padding: 5px 8px;
    border-width: 2px;
    font-size: 0.84rem;
  }

  .human-panel {
    grid-template-rows: 30px minmax(0, 1fr);
    gap: 6px;
    padding: 8px;
  }

  .human-header {
    align-items: center;
    gap: 8px;
  }

  .human-actions {
    gap: 5px;
  }

  .human-actions .action-button {
    min-width: 48px;
    width: auto;
    white-space: nowrap;
  }

  .human-actions #drawCardButton {
    min-width: 92px;
  }

  .human-actions #newRoundButton {
    display: none;
  }

  .player-title {
    min-width: 72px;
    gap: 5px;
    font-size: 0.9rem;
  }

  .hand-scroll {
    padding: 12px 3px 4px;
  }

  .card {
    margin-right: -4px;
    border-width: 4px;
    border-radius: 10px;
  }

  .card::before {
    inset: 10px 8px;
    border-width: 3px;
  }

  .card-symbol {
    width: 52px;
    font-size: 1.1rem;
  }

  .card.small-text .card-symbol {
    font-size: 0.72rem;
  }

  .card-corner {
    left: 5px;
    top: 4px;
    font-size: 0.62rem;
  }

  .card-corner.bottom {
    inset: auto 5px 4px auto;
  }

  .card.is-playable,
  button.card:hover {
    transform: translateY(-8px) rotate(-1deg);
  }

  .game-board.is-waiting {
    grid-template-rows: 56px minmax(0, 1fr) 56px;
  }

  .game-board.is-waiting .table-center {
    grid-template-rows: 30px minmax(0, 1fr) 96px 36px;
  }

  .game-board.is-waiting .start-panel {
    width: min(260px, 100%);
    padding: 10px 12px;
  }

  .game-board.is-waiting .start-button {
    min-width: 168px;
    min-height: 48px;
  }
}

@media (max-width: 420px) {
  :root {
    --card-w: 62px;
    --hand-row: 156px;
  }

  .status-pill {
    padding: 0 6px;
    font-size: 0.68rem;
  }

  .human-actions #drawCardButton {
    min-width: 88px;
  }
}
