:root {
  --bg: #262421;
  --bg-soft: #312e2b;
  --bg-elevated: #3a3733;
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #f3f2ef;
  --muted: #b9b6b0;
  --muted-strong: #d7d4cf;
  --accent: #81b64c;
  --accent-strong: #95c45b;
  --accent-soft: rgba(129, 182, 76, 0.14);
  --accent-border: rgba(129, 182, 76, 0.22);
  --accent-glow: rgba(129, 182, 76, 0.15);
  --accent-glow-strong: rgba(255, 214, 102, 0.08);
  --warning: #f4c542;
  --warning-soft: rgba(244, 197, 66, 0.24);
  --light-square: #eeeed2;
  --dark-square: #769656;
  --last-move: rgba(246, 246, 105, 0.36);
  --capture: #df665d;
  --shadow: 0 26px 60px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Aptos", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, var(--accent-glow), transparent 30%),
    radial-gradient(circle at bottom right, var(--accent-glow-strong), transparent 24%),
    linear-gradient(180deg, #1f1d1b 0%, #262421 100%);
  transition: background 220ms ease, color 220ms ease;
}

body[data-mode="shared_fate"] {
  --accent: #58b0c6;
  --accent-strong: #79c8da;
  --accent-soft: rgba(88, 176, 198, 0.14);
  --accent-border: rgba(88, 176, 198, 0.24);
  --accent-glow: rgba(88, 176, 198, 0.18);
  --accent-glow-strong: rgba(162, 221, 238, 0.09);
  --light-square: #e4edf1;
  --dark-square: #61889c;
}

body[data-mode="double_roll"] {
  --accent: #cf8f3a;
  --accent-strong: #e2ab54;
  --accent-soft: rgba(207, 143, 58, 0.14);
  --accent-border: rgba(226, 171, 84, 0.24);
  --accent-glow: rgba(207, 143, 58, 0.18);
  --accent-glow-strong: rgba(255, 186, 94, 0.1);
  --light-square: #efe4cc;
  --dark-square: #987248;
}

body[data-mode="lock_in"] {
  --accent: #b06a84;
  --accent-strong: #ca849d;
  --accent-soft: rgba(176, 106, 132, 0.14);
  --accent-border: rgba(202, 132, 157, 0.24);
  --accent-glow: rgba(176, 106, 132, 0.18);
  --accent-glow-strong: rgba(228, 170, 191, 0.1);
  --light-square: #ede0e5;
  --dark-square: #8f6473;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 42px 42px;
  opacity: 0.4;
  pointer-events: none;
}

body.screen-shake {
  animation: screen-shake 420ms ease;
}

.app-shell {
  position: relative;
  width: min(1420px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.2rem 0 2.25rem;
}

.panel {
  background: linear-gradient(180deg, rgba(58, 55, 51, 0.96), rgba(43, 40, 37, 0.96));
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.15rem 1.35rem;
  animation: fade-rise 300ms ease;
}

.brand-lockup {
  display: grid;
  gap: 0.45rem;
}

.eyebrow,
.section-label,
.player-label {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand-lockup h1,
.board-copy h2,
.rules-panel h2,
.player-card h2,
.history-panel h2 {
  margin: 0;
}

.brand-lockup h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.tagline {
  margin: 0.4rem 0 0;
  max-width: 48rem;
  color: var(--muted);
  line-height: 1.55;
}

.topbar-tools {
  display: flex;
  align-items: center;
  justify-content: end;
  flex: 1 1 auto;
  min-width: 0;
  gap: 1rem;
}

.online-dock {
  display: grid;
  gap: 0.7rem;
  min-width: min(100%, 560px);
  padding: 0.85rem 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.online-copy {
  display: grid;
  gap: 0.3rem;
}

.online-copy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.online-status {
  margin: 0;
  color: var(--muted-strong);
  font-size: 0.92rem;
  line-height: 1.4;
}

.online-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.online-input {
  flex: 1 1 150px;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0.8rem 0.95rem;
  background: rgba(7, 10, 12, 0.72);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.online-input-name {
  flex-basis: 170px;
  text-transform: none;
  letter-spacing: normal;
}

.online-select {
  flex-basis: 180px;
  cursor: pointer;
}

#play-cpu {
  min-width: 132px;
}

.online-mode-description {
  color: #dbe4d1;
}

.mode-rules-panel {
  display: none;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.2), rgba(12, 15, 18, 0.46));
  border: 1px solid var(--accent-border);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.mode-rules-panel.is-open {
  display: grid;
}

.mode-rules-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.75rem;
}

.mode-rules-head h3 {
  margin: 0.35rem 0 0;
  font-size: 1.15rem;
}

.mode-rules-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.38rem 0.65rem;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: #edf6e3;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mode-rules-copy {
  margin: 0;
  color: var(--muted-strong);
  line-height: 1.5;
}

.mode-rules-list {
  margin: 0;
  padding-left: 1.05rem;
  color: var(--muted);
  line-height: 1.55;
}

.mode-rules-list li + li {
  margin-top: 0.3rem;
}

.online-input::placeholder {
  color: #99a59b;
}

.online-input:focus {
  outline: 2px solid rgba(129, 182, 76, 0.36);
  outline-offset: 1px;
}

.turn-stack {
  display: grid;
  gap: 0.4rem;
  min-width: 220px;
  padding: 0.85rem 1rem;
  text-align: right;
  flex: 0 0 auto;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.14));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.turn-pill {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  justify-self: end;
  padding: 0.58rem 0.95rem;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: #e9f5d9;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18), inset 0 0 18px rgba(255, 255, 255, 0.03);
}

.turn-caption {
  margin: 0;
  color: var(--muted-strong);
  font-size: 0.96rem;
  line-height: 1.4;
}

.button {
  border: none;
  border-radius: 14px;
  padding: 0.9rem 1.15rem;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: #14210a;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(129, 182, 76, 0.22);
  transition: transform 150ms ease, filter 150ms ease, box-shadow 150ms ease;
}

.button-secondary {
  background: linear-gradient(180deg, #424c54, #31383e);
  color: #f1f4ef;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.2);
}

.button-compact {
  padding: 0.62rem 0.82rem;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.button:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
  box-shadow: 0 16px 28px rgba(129, 182, 76, 0.28);
}

.button-secondary:hover {
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.24);
}

.button:disabled,
.button-secondary:disabled,
.online-input:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  filter: grayscale(0.15);
  box-shadow: none;
}

.button:active {
  transform: translateY(0);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  gap: 1rem;
  margin-top: 1rem;
  align-items: start;
}

.board-column,
.sidebar {
  display: grid;
  gap: 1rem;
}

.board-stage,
.rules-panel,
.player-panel,
.history-panel {
  animation: fade-rise 380ms ease;
}

.board-stage {
  padding: 1rem;
}

.board-meta {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.board-copy {
  display: grid;
  gap: 0.55rem;
}

.board-copy h2 {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  line-height: 1.08;
}

.turn-copy {
  margin: 0;
  max-width: 38rem;
  color: var(--muted);
  line-height: 1.55;
}

.chip-row {
  display: none;
  flex-wrap: wrap;
  justify-content: end;
  gap: 0.65rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 2.6rem;
  padding: 0.65rem 0.85rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--muted-strong);
  font-size: 0.9rem;
  font-weight: 700;
}

.chip-accent {
  background: rgba(129, 182, 76, 0.16);
  border-color: rgba(129, 182, 76, 0.28);
  color: #e4f5ce;
}

.board-wrap {
  display: grid;
  place-items: center;
  width: 100%;
  overflow: auto;
  padding: 0.2rem;
}

.roll-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

body.lock-in-roll-mode .roll-strip {
  grid-template-columns: 1fr;
}

body.lock-in-roll-mode #piece-roll-card {
  display: none;
}

.roll-card {
  position: relative;
  overflow: hidden;
  padding: 0.95rem 1rem;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(15, 17, 20, 0.85), rgba(10, 12, 14, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: border-color 180ms ease, transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.roll-card::before {
  content: "";
  position: absolute;
  inset: -40% auto -40% -35%;
  width: 34%;
  background: linear-gradient(90deg, transparent, rgba(129, 182, 76, 0.18), transparent);
  transform: translateX(-220%) skewX(-18deg);
  opacity: 0;
}

.roll-card-active {
  border-color: rgba(129, 182, 76, 0.45);
  background: rgba(129, 182, 76, 0.08);
  box-shadow: 0 0 0 1px rgba(129, 182, 76, 0.16);
}

.roll-card-spinning {
  transform: translateY(-1px);
}

.roll-card-spinning::before {
  opacity: 1;
  animation: roll-sheen 680ms linear infinite;
}

.roll-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.roll-value {
  margin: 0.75rem 0 0;
  min-height: 2rem;
  font-size: clamp(1.2rem, 2.5vw, 1.7rem);
  line-height: 1.12;
}

.roll-copy {
  margin: 0.35rem 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.roll-reel {
  position: relative;
  height: 148px;
  margin-top: 0.7rem;
  overflow: hidden;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(35, 38, 42, 0.96), rgba(19, 22, 26, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 0 28px rgba(0, 0, 0, 0.34);
}

.roll-track {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  gap: 0.85rem;
  align-items: center;
  height: 100%;
  padding: 0 1rem;
  will-change: transform;
}

.roll-item {
  flex: 0 0 124px;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.3rem;
  padding: 0.8rem 0.6rem 0.78rem;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(55, 60, 67, 0.92), rgba(28, 32, 36, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
}

.roll-item-winning {
  border-color: rgba(129, 182, 76, 0.44);
  box-shadow: 0 0 0 1px rgba(129, 182, 76, 0.14), 0 10px 18px rgba(0, 0, 0, 0.2);
}

.roll-item-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  object-fit: contain;
  user-select: none;
}

.roll-item-title {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  color: #f8f8f7;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.roll-item-subtitle {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  color: #d7ded2;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.roll-reel-pointer {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 50%;
  width: 132px;
  transform: translateX(-50%);
  border-radius: 12px;
  border: 2px solid rgba(129, 182, 76, 0.8);
  background: rgba(129, 182, 76, 0.07);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35),
    inset 0 0 22px rgba(129, 182, 76, 0.14);
  pointer-events: none;
  z-index: 3;
}

.roll-reel-pointer::before,
.roll-reel-pointer::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
}

.roll-reel-pointer::before {
  top: -10px;
  border-top: 0;
  border-bottom: 10px solid rgba(129, 182, 76, 0.92);
}

.roll-reel-pointer::after {
  bottom: -10px;
  border-bottom: 0;
  border-top: 10px solid rgba(129, 182, 76, 0.92);
}

.roll-reel-edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 64px;
  z-index: 4;
  pointer-events: none;
}

.roll-reel-edge-left {
  left: 0;
  background: linear-gradient(90deg, rgba(14, 16, 18, 0.98), rgba(14, 16, 18, 0));
}

.roll-reel-edge-right {
  right: 0;
  background: linear-gradient(270deg, rgba(14, 16, 18, 0.98), rgba(14, 16, 18, 0));
}

.board {
  --square-size: 84px;
  box-sizing: content-box;
  display: grid;
  grid-template-columns: repeat(8, var(--square-size));
  grid-template-rows: repeat(8, var(--square-size));
  width: auto;
  height: auto;
  max-width: none;
  overflow: hidden;
  border: 14px solid #1e1c19;
  border-radius: 18px;
  background: #1e1c19;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 28px 55px rgba(0, 0, 0, 0.38);
}

.board.board-locked {
  pointer-events: none;
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  border: none;
  padding: 0;
  background: transparent;
  cursor: default;
  overflow: hidden;
  transition: filter 140ms ease, transform 140ms ease;
}

.square-legal,
.square-capture,
.square-forced {
  cursor: pointer;
}

.square::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.square:hover {
  filter: brightness(1.03);
}

.square:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.7);
  outline-offset: -3px;
}

.square-light {
  background: var(--light-square);
}

.square-dark {
  background: var(--dark-square);
}

.square-last-from::before,
.square-last-to::before {
  background: var(--last-move);
  opacity: 1;
}

.square-forced {
  box-shadow:
    inset 0 0 0 4px rgba(244, 197, 66, 0.96),
    inset 0 0 34px rgba(244, 197, 66, 0.24),
    0 0 0 1px rgba(255, 224, 120, 0.22);
  animation: forced-pulse 1.6s ease-in-out infinite;
}

.square-legal::after,
.square-capture::after {
  content: "";
  position: absolute;
  z-index: 0;
  border-radius: 999px;
  animation: dot-in 140ms ease;
}

.square-legal::after {
  width: 26%;
  aspect-ratio: 1;
  background: rgba(17, 20, 15, 0.4);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.08);
}

.square-capture::after {
  width: 76%;
  height: 76%;
  border: 5px solid rgba(188, 38, 38, 0.9);
  box-shadow: inset 0 0 0 999px rgba(188, 38, 38, 0.12), 0 0 26px rgba(188, 38, 38, 0.16);
}

.square-impact::before,
.square-impact-capture::before {
  opacity: 1;
  animation: landing-flash 260ms ease;
}

.square-impact::before {
  background: rgba(129, 182, 76, 0.18);
}

.square-impact-capture::before {
  background: rgba(223, 102, 93, 0.24);
}

.piece {
  position: relative;
  z-index: 1;
  width: 84%;
  height: 84%;
  object-fit: contain;
  user-select: none;
  transition: transform 140ms ease, filter 140ms ease, opacity 160ms ease;
}

.square:hover .piece {
  transform: translateY(-2%) scale(1.02);
}

.piece-white {
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
}

.piece-black {
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.18));
}

.piece-forced {
  filter: drop-shadow(0 0 14px rgba(255, 220, 96, 0.44));
  transform: scale(1.06);
}

.piece-hidden {
  opacity: 0;
}

.piece-arrive {
  animation: piece-land 220ms ease;
}

.piece-clone {
  position: fixed;
  left: 0;
  top: 0;
  margin: 0;
  pointer-events: none;
  z-index: 40;
  transition: transform 220ms cubic-bezier(0.22, 0.9, 0.33, 1.12);
}

.coord-file,
.coord-rank {
  position: absolute;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1;
  opacity: 0.64;
  pointer-events: none;
}

.coord-file {
  right: 0.34rem;
  bottom: 0.28rem;
}

.coord-rank {
  left: 0.3rem;
  top: 0.24rem;
}

.player-panel,
.history-panel,
.rules-panel {
  padding: 1rem;
}

.player-panel {
  display: grid;
  gap: 0.85rem;
}

.player-card {
  padding: 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: border-color 180ms ease, transform 180ms ease, background 180ms ease;
}

.player-card-active {
  border-color: rgba(129, 182, 76, 0.48);
  background: rgba(129, 182, 76, 0.08);
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px rgba(129, 182, 76, 0.2), 0 18px 30px rgba(0, 0, 0, 0.16);
}

.player-card-winner {
  border-color: rgba(244, 197, 66, 0.48);
}

.player-card-defeated {
  opacity: 0.78;
}

.player-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.75rem;
}

.player-id {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.player-avatar {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.player-avatar-light {
  background: linear-gradient(180deg, #f6f3e5, #d8d3bf);
}

.player-avatar-dark {
  background: linear-gradient(180deg, #48534a, #262e28);
}

.player-card h2 {
  font-size: 1.2rem;
}

.player-status {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.player-card-active .player-status {
  background: rgba(129, 182, 76, 0.18);
  color: #e8f5d6;
}

.player-card-winner .player-status {
  background: rgba(244, 197, 66, 0.18);
  color: #fff0bf;
}

.player-detail,
.player-count,
.history-header p,
.rules-panel li {
  color: var(--muted);
}

.player-detail,
.player-count {
  margin: 0.7rem 0 0;
  line-height: 1.5;
}

.player-count {
  font-size: 0.94rem;
}

.rules-panel h2,
.history-panel h2 {
  font-size: 1.35rem;
}

.rules-panel ul {
  margin: 0.9rem 0 0;
  padding-left: 1.05rem;
  line-height: 1.6;
}

.history-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.history-header p {
  margin: 0;
  font-size: 0.92rem;
}

.history-list {
  margin: 0.95rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.55rem;
  max-height: 34rem;
  overflow: auto;
}

.history-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 0.45rem;
  align-items: center;
  padding: 0.36rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.04);
  animation: row-in 260ms ease;
}

.move-index {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.move-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  min-height: 2.7rem;
  padding: 0.65rem 0.75rem;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.move-cell-empty {
  opacity: 0.28;
}

.move-cell-latest {
  border-color: rgba(129, 182, 76, 0.32);
  box-shadow: 0 0 0 1px rgba(129, 182, 76, 0.16);
}

.move-main {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  color: var(--text);
}

.move-badge {
  flex: 0 0 auto;
  padding: 0.26rem 0.5rem;
  border-radius: 999px;
  background: rgba(129, 182, 76, 0.14);
  color: #daf0be;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-empty {
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.outcome-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(8, 10, 12, 0.58);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 60;
}

.outcome-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.outcome-card {
  position: relative;
  width: min(100%, 460px);
  padding: 1.4rem 1.35rem 1.25rem;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(28, 32, 26, 0.98), rgba(15, 19, 16, 0.98));
  box-shadow: 0 32px 70px rgba(0, 0, 0, 0.42);
  transform: translateY(16px) scale(0.96);
  transition: transform 220ms cubic-bezier(0.2, 0.9, 0.2, 1.1);
  overflow: hidden;
}

.outcome-modal.is-open .outcome-card {
  transform: translateY(0) scale(1);
}

.outcome-card-victory {
  background:
    radial-gradient(circle at top, rgba(129, 182, 76, 0.22), transparent 42%),
    linear-gradient(180deg, rgba(28, 37, 25, 0.98), rgba(15, 19, 16, 0.98));
  box-shadow: 0 32px 70px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(129, 182, 76, 0.2);
}

.outcome-card-defeat {
  background:
    radial-gradient(circle at top, rgba(190, 74, 74, 0.22), transparent 42%),
    linear-gradient(180deg, rgba(41, 24, 24, 0.98), rgba(18, 12, 12, 0.98));
  box-shadow: 0 32px 70px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(190, 74, 74, 0.22);
}

.outcome-card-draw {
  background:
    radial-gradient(circle at top, rgba(88, 176, 198, 0.2), transparent 42%),
    linear-gradient(180deg, rgba(21, 31, 35, 0.98), rgba(12, 17, 18, 0.98));
  box-shadow: 0 32px 70px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(88, 176, 198, 0.22);
}

.outcome-kicker {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.outcome-title {
  margin: 0.55rem 0 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 0.98;
}

.outcome-copy {
  margin: 0.85rem 0 1.15rem;
  color: var(--muted-strong);
  font-size: 1rem;
  line-height: 1.6;
}

.outcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.outcome-confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -16px;
  width: 10px;
  height: 18px;
  border-radius: 999px;
  opacity: 0;
  animation: confetti-fall 1100ms cubic-bezier(0.2, 0.9, 0.35, 1) forwards;
}

.move-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}

@keyframes fade-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateX(10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes forced-pulse {
  0%,
  100% {
    box-shadow:
      inset 0 0 0 3px rgba(244, 197, 66, 0.92),
      inset 0 0 18px rgba(244, 197, 66, 0.14);
  }

  50% {
    box-shadow:
      inset 0 0 0 3px rgba(244, 197, 66, 0.96),
      inset 0 0 28px rgba(244, 197, 66, 0.22);
  }
}

@keyframes dot-in {
  from {
    opacity: 0;
    transform: scale(0.3);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes piece-land {
  0% {
    transform: scale(0.92);
  }

  65% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes roll-sheen {
  from {
    transform: translateX(-220%) skewX(-18deg);
  }

  to {
    transform: translateX(520%) skewX(-18deg);
  }
}

@keyframes landing-flash {
  0% {
    opacity: 0.34;
  }

  100% {
    opacity: 0;
  }
}

@keyframes confetti-fall {
  0% {
    opacity: 0;
    transform: translateY(-18px) rotate(0deg) scale(0.8);
  }

  12% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(250px) rotate(540deg) scale(1);
  }
}

@keyframes screen-shake {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }

  20% {
    transform: translate3d(-8px, 2px, 0);
  }

  40% {
    transform: translate3d(7px, -3px, 0);
  }

  60% {
    transform: translate3d(-6px, 2px, 0);
  }

  80% {
    transform: translate3d(5px, -2px, 0);
  }
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr 380px;
  }

  .board-meta {
    flex-direction: column;
    align-items: start;
  }

  .chip-row {
    justify-content: start;
  }

  .roll-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .app-shell {
    width: min(100%, calc(100% - 1rem));
    padding-top: 0.75rem;
  }

  .topbar {
    flex-direction: column;
    align-items: start;
  }

  .topbar-tools {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    justify-content: start;
  }

  .online-dock {
    min-width: 0;
    width: 100%;
  }

  .turn-stack {
    text-align: left;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar,
  .board-stage,
  .player-panel,
  .history-panel,
  .rules-panel {
    padding: 0.9rem;
  }

  .board {
    border-width: 10px;
    border-radius: 14px;
  }

  .roll-card {
    padding: 0.85rem 0.9rem;
  }

  .roll-reel {
    height: 132px;
  }

  .roll-item {
    flex-basis: 108px;
    min-height: 100px;
  }

  .roll-item-icon {
    width: 34px;
    height: 34px;
  }

  .roll-reel-pointer {
    width: 116px;
  }

  .chip-row {
    gap: 0.45rem;
  }

  .chip {
    width: 100%;
    justify-content: center;
  }

  .history-row {
    grid-template-columns: 36px 1fr;
  }
}
