:root {
  --bg: #f5f9ff;
  --bg-soft: #e9f7ff;
  --card: rgba(255, 255, 255, 0.84);
  --card-strong: rgba(255, 255, 255, 0.94);
  --text: #20304b;
  --text-soft: #5e6d88;
  --primary: #ff7c64;
  --primary-dark: #f2566a;
  --green: #31c48d;
  --yellow: #ffcf5a;
  --blue: #54a8ff;
  --violet: #9c79ff;
  --danger: #ff6b7c;
  --shadow: 0 18px 40px rgba(68, 89, 132, 0.16);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Nunito", sans-serif;
  background:
    radial-gradient(circle at top left, #fff7bc 0, rgba(255, 247, 188, 0) 36%),
    radial-gradient(circle at 80% 15%, #d8f6ff 0, rgba(216, 246, 255, 0) 28%),
    linear-gradient(180deg, #eaf8ff 0%, #f9fbff 100%);
  color: var(--text);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(84, 168, 255, 0.36);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: 20px;
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(20px);
  opacity: 0.52;
  pointer-events: none;
  animation: drift 10s ease-in-out infinite;
}

.bg-orb--one {
  top: 5%;
  left: 2%;
  width: 180px;
  height: 180px;
  background: rgba(255, 207, 90, 0.5);
}

.bg-orb--two {
  top: 22%;
  right: -20px;
  width: 220px;
  height: 220px;
  background: rgba(84, 168, 255, 0.34);
  animation-delay: -3s;
}

.bg-orb--three {
  bottom: 6%;
  left: 10%;
  width: 180px;
  height: 180px;
  background: rgba(156, 121, 255, 0.28);
  animation-delay: -6s;
}

.app-card {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px;
  border-radius: 36px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.screen {
  display: grid;
  gap: 20px;
  animation: screenIn 280ms ease;
}

.hero {
  display: grid;
  gap: 18px;
  justify-items: start;
  padding: 18px 6px 8px;
}

.hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: #48617d;
  font-weight: 800;
}

.hero__badge--game {
  background: rgba(255, 248, 205, 0.92);
}

.hero__title,
.panel-header h2,
.game-header h2,
.result-hero h2,
.info-panel h2,
.score-header h3,
.panel-card h3 {
  margin: 0;
  font-family: "Baloo 2", sans-serif;
  line-height: 0.95;
}

.hero__title {
  font-size: clamp(3.5rem, 9vw, 6rem);
  color: #16385d;
}

.hero__subtitle {
  max-width: 620px;
  margin: 0;
  font-size: 1.14rem;
  line-height: 1.6;
  color: var(--text-soft);
}

.hero__animals {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 2.3rem;
}

.hero__animals span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 10px 22px rgba(106, 134, 189, 0.12);
}

.hero__actions,
.result-actions,
.config-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.back-btn,
.pill-btn,
.animal-btn {
  border-radius: 18px;
  font-weight: 800;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 56px;
  padding: 14px 22px;
}

.primary-btn {
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 16px 28px rgba(242, 86, 106, 0.26);
}

.secondary-btn {
  color: #254365;
  background: linear-gradient(135deg, #fff6be, #ffd56b);
  box-shadow: 0 14px 24px rgba(255, 207, 90, 0.22);
}

.ghost-btn {
  color: #2b4263;
  background: rgba(255, 255, 255, 0.72);
}

.portal-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.secondary-btn--small,
.ghost-btn--small {
  min-height: 44px;
  padding: 10px 16px;
}

.home-panels,
.config-layout,
.game-layout {
  display: grid;
  gap: 18px;
}

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

.info-panel,
.panel-card,
.board-panel,
.side-panel {
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.info-panel,
.panel-card,
.board-panel {
  padding: 22px;
}

.info-panel p,
.score-header p,
.config-players-header p,
.panel-card p,
.panel-card small {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.55;
}

.info-panel--warm {
  background: linear-gradient(180deg, rgba(255, 249, 220, 0.92), rgba(255, 255, 255, 0.82));
}

.panel-header,
.game-header,
.config-players-header,
.board-meta,
.dice-card,
.score-header,
.turn-banner,
.ranking-item,
.player-hud,
.player-config__top,
.animal-grid,
.dice-text,
.toggle-row {
  display: flex;
  align-items: center;
}

.panel-header,
.game-header {
  justify-content: space-between;
}

.panel-header {
  padding: 6px 4px 0;
}

.panel-header h2,
.game-header h2,
.result-hero h2 {
  font-size: clamp(2rem, 6vw, 3.2rem);
}

.back-btn {
  width: 48px;
  height: 48px;
  font-size: 1.3rem;
  color: #28415e;
  background: rgba(255, 255, 255, 0.84);
}

.panel-card--tall {
  min-height: 360px;
  align-content: start;
}

.steps-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 24px;
  color: var(--text);
  line-height: 1.55;
}

.tip-box {
  margin: 18px 0;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 244, 189, 0.9), rgba(255, 255, 255, 0.84));
  color: #4d5161;
  line-height: 1.5;
}

.tip-box--tiny {
  margin: 0;
  font-size: 0.95rem;
}

.settings-card,
.option-block,
.player-config,
.dice-text {
  display: grid;
  gap: 12px;
}

.toggle-row {
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.66);
}

.toggle-row input {
  width: 24px;
  height: 24px;
  accent-color: var(--primary);
}

.config-layout {
  grid-template-columns: 320px minmax(0, 1fr);
}

.option-label {
  font-weight: 900;
  color: #3b5372;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill-btn {
  min-height: 48px;
  padding: 10px 16px;
  color: #2d486b;
  background: rgba(255, 255, 255, 0.74);
}

.pill-btn.is-selected {
  color: white;
  background: linear-gradient(135deg, #49b3ff, #7b76ff);
  box-shadow: 0 12px 22px rgba(111, 125, 255, 0.28);
}

.player-config-list,
.player-hud-list,
.ranking-list {
  display: grid;
  gap: 14px;
}

.player-config {
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.66);
}

.player-config__top {
  justify-content: space-between;
  gap: 12px;
}

.player-config__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
}

.player-config input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 2px solid rgba(108, 145, 189, 0.16);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.85);
}

.animal-grid {
  flex-wrap: wrap;
  gap: 10px;
}

.animal-btn {
  display: inline-grid;
  gap: 4px;
  min-width: 92px;
  padding: 10px 12px;
  color: #2b4160;
  background: rgba(255, 255, 255, 0.88);
  text-align: center;
}

.animal-btn__emoji {
  font-size: 1.6rem;
}

.animal-btn__label {
  font-size: 0.86rem;
}

.animal-btn.is-selected {
  color: white;
  background: linear-gradient(135deg, var(--animal-color, #ff9560), #7b76ff);
}

.animal-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.game-layout {
  grid-template-columns: minmax(0, 1.4fr) 320px;
  align-items: start;
}

.board-panel {
  display: grid;
  gap: 16px;
}

.board-meta {
  flex-wrap: wrap;
  gap: 12px;
}

.board-meta__chip,
.turn-banner {
  border-radius: 999px;
  font-weight: 800;
}

.board-meta__chip {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.84);
}

.turn-banner {
  justify-content: center;
  min-height: 54px;
  padding: 12px 18px;
  background: linear-gradient(135deg, rgba(255, 245, 208, 0.94), rgba(255, 255, 255, 0.92));
  color: #354c69;
  font-size: 1.02rem;
}

.board-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(var(--board-side, 6), minmax(0, 1fr));
}

.board-cell {
  position: relative;
  min-height: clamp(82px, 12vw, 112px);
  padding: 8px 8px 10px;
  border-radius: 22px;
  color: #2c4566;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 250, 255, 0.92));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.36);
  overflow: hidden;
}

.board-cell::after {
  content: "";
  position: absolute;
  inset: auto 10px 8px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.46);
}

.board-cell--alt {
  background: linear-gradient(180deg, rgba(237, 249, 255, 0.98), rgba(234, 242, 255, 0.92));
}

.board-cell--start {
  background: linear-gradient(180deg, rgba(211, 255, 224, 0.98), rgba(232, 255, 238, 0.9));
}

.board-cell--goal {
  background: linear-gradient(180deg, rgba(255, 241, 184, 0.98), rgba(255, 250, 214, 0.92));
}

.board-cell--positive .cell-value {
  color: #1ea66f;
}

.board-cell--negative .cell-value {
  color: #ef5a6f;
}

.board-cell--active {
  transform: translateY(-3px);
  box-shadow: 0 18px 26px rgba(85, 126, 192, 0.18);
}

.cell-head,
.player-token,
.ranking-item,
.player-hud {
  display: flex;
  align-items: center;
}

.cell-head {
  justify-content: space-between;
  gap: 10px;
  font-weight: 900;
}

.cell-index {
  font-size: 0.92rem;
}

.cell-icon {
  font-size: 1.3rem;
}

.cell-value {
  margin-top: 8px;
  font-family: "Baloo 2", sans-serif;
  font-size: clamp(1.4rem, 3.8vw, 2rem);
  line-height: 1;
}

.cell-label {
  margin-top: 8px;
  color: #48617d;
  font-weight: 900;
}

.cell-tokens {
  position: absolute;
  right: 8px;
  bottom: 14px;
  width: 48px;
  height: 48px;
}

.player-token {
  position: absolute;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 14px rgba(42, 65, 96, 0.18);
  font-size: 1rem;
}

.player-token--slot-0 { top: 0; left: 0; }
.player-token--slot-1 { top: 0; right: 0; }
.player-token--slot-2 { bottom: 0; left: 0; }
.player-token--slot-3 { bottom: 0; right: 0; }

.food-burst {
  position: absolute;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 999px;
  color: white;
  font-weight: 900;
  background: rgba(32, 48, 75, 0.84);
  animation: popUp 900ms ease forwards;
}

.food-burst--gain {
  background: rgba(49, 196, 141, 0.92);
}

.food-burst--loss {
  background: rgba(255, 107, 124, 0.92);
}

.panel-card--compact {
  display: grid;
  gap: 16px;
}

.dice-card {
  gap: 16px;
}

.dice-face {
  display: grid;
  place-items: center;
  flex: 0 0 88px;
  width: 88px;
  height: 88px;
  border-radius: 24px;
  font-size: 2.4rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(229, 244, 255, 0.92));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.dice-face.is-rolling {
  animation: wobble 160ms linear infinite;
}

.dice-text strong {
  font-size: 1.05rem;
}

.player-hud {
  gap: 14px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
}

.player-hud.is-current {
  outline: 3px solid rgba(255, 207, 90, 0.56);
  background: linear-gradient(135deg, rgba(255, 251, 214, 0.98), rgba(255, 255, 255, 0.84));
}

.player-chip {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  font-size: 1.7rem;
  flex: 0 0 56px;
}

.player-hud__body {
  display: grid;
  gap: 4px;
  flex: 1;
}

.player-hud__title {
  font-weight: 900;
}

.player-hud__meta {
  color: var(--text-soft);
  font-size: 0.94rem;
}

.player-hud__score {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.player-hud__score span {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  font-size: 0.9rem;
  font-weight: 800;
}

.result-hero {
  display: grid;
  gap: 10px;
  justify-items: start;
}

.result-winner {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 900;
}

.result-note {
  margin: 0;
  color: var(--text-soft);
}

.ranking-item {
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.74);
}

.ranking-item--winner {
  background: linear-gradient(135deg, rgba(255, 247, 187, 0.96), rgba(255, 255, 255, 0.88));
}

.ranking-item__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ranking-item__badge {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.92);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 50;
  transform: translateX(-50%);
  min-width: 220px;
  max-width: calc(100vw - 24px);
  padding: 12px 16px;
  border-radius: 999px;
  color: white;
  text-align: center;
  font-weight: 900;
  background: rgba(32, 48, 75, 0.92);
  box-shadow: 0 16px 26px rgba(44, 69, 102, 0.22);
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 18px;
  border-radius: 4px;
  opacity: 0.92;
  animation: confettiFall 1800ms ease-in forwards;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(16px, -10px, 0); }
}

@keyframes wobble {
  0% { transform: rotate(-6deg) scale(1.02); }
  50% { transform: rotate(6deg) scale(0.98); }
  100% { transform: rotate(-6deg) scale(1.02); }
}

@keyframes popUp {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.86);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -28px) scale(1.02);
  }
}

@keyframes confettiFall {
  from {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  to {
    transform: translate3d(var(--drift, 0px), 110vh, 0) rotate(560deg);
  }
}

@media (max-width: 980px) {
  .config-layout,
  .game-layout,
  .home-panels {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .app-card {
    padding: 16px;
    border-radius: 28px;
  }

  .hero__actions,
  .result-actions,
  .config-footer,
  .game-header__actions {
    flex-direction: column;
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn {
    width: 100%;
  }

  .board-cell {
    min-height: 74px;
    padding: 7px 7px 9px;
    border-radius: 18px;
  }

  .cell-value {
    font-size: 1.3rem;
  }
}

@media (max-width: 540px) {
  .hero__title {
    font-size: 3.3rem;
  }

  .board-grid {
    gap: 6px;
  }

  .board-cell {
    min-height: 62px;
  }

  .cell-index,
  .cell-label {
    font-size: 0.78rem;
  }

  .cell-icon {
    font-size: 1rem;
  }

  .cell-tokens {
    width: 42px;
    height: 42px;
    bottom: 10px;
  }

  .player-token {
    width: 24px;
    height: 24px;
    font-size: 0.88rem;
  }

  .dice-card,
  .player-hud,
  .ranking-item {
    align-items: flex-start;
  }

  .dice-face {
    width: 72px;
    height: 72px;
    flex-basis: 72px;
    font-size: 2rem;
  }
}
