/* ===== Base & Background ===== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', 'Arial Rounded MT Bold', Tahoma, sans-serif;
  background-image: url('assets/game-bg.png');
  background-color: #2a1a0e;
}

#app {
  background: linear-gradient(
    180deg,
    rgba(30, 15, 5, 0.55) 0%,
    rgba(30, 15, 5, 0.7) 100%
  );
}

/* ===== Header ===== */

.header-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 1rem;
  padding-left: 1rem;
  padding-right: 1rem;
}

.header-corner-logo {
  position: absolute;
  top: 0;
  left: 20px;
  height: 200px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
  z-index: 10;
}

.header-title-block {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.header-banner {
  width: min(90%, 600px);
  height: auto;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

.header-subtitle {
  transform: translateY(-40px);
  margin: 0;
  color: #e8c84a;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.subtitle {
  margin-top: -4px;
  color: #f5e6c8;
  font-size: 1rem;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  letter-spacing: 0.5px;
}

/* ===== Hero Characters ===== */

.hero-characters {
  position: relative;
  width: min(95%, 700px);
  border-radius: 16px;
  height: fit-content;
  display: flex;
  justify-content: center;
  align-items: center;
  transform: translateY(-10%);
}

.hero-panel {
  position: absolute;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}

.hero-panel-left {
  left: 3%;
}

.hero-panel-right {
  right: 3%;
}

.hero-character {
  width: 140px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.hero-name-ribbon {
  display: inline-block;
  margin-top: 2px;
  margin-bottom: 6px;
  padding: 3px 20px;
  background: linear-gradient(135deg, #2a4a7a 0%, #4a6a9a 50%, #2a4a7a 100%);
  color: #f5e6c8;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 4px;
  border: 1px solid rgba(196, 164, 60, 0.6);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.5px;
}

.hero-dragon {
  z-index: 1;
  pointer-events: none;
}

.hero-dragon img {
  width: 260px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

.hero-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: rgba(0, 0, 0, 0.4);
  z-index: 3;
}

@media (min-width: 480px) {
  .hero-character {
    width: 170px;
  }

  .hero-dragon img {
    width: 320px;
  }

  .hero-name-ribbon {
    font-size: 1rem;
    padding: 4px 24px;
  }
}

/* ===== Wild Card (above players) ===== */

.wild-card-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.btn-wild-top {
  min-width: 180px;
}

.wild-card-hint {
  margin: 0;
  font-size: 0.9rem;
  color: #f5e6c8;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  text-align: center;
}

/* ===== How to Play ===== */

.how-to-play-section {
  margin-bottom: 0.5rem;
}

.how-to-play-panel {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(196, 164, 60, 0.5);
}

.how-to-play-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #3d2817;
  border: none;
  border-radius: 0;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.2s;
}

.how-to-play-header:hover {
  background: #4a3219;
}

.how-to-play-header-icon {
  flex-shrink: 0;
}

.how-to-play-chevron {
  margin-left: auto;
  flex-shrink: 0;
  color: rgba(196, 164, 60, 0.9);
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.how-to-play-panel.is-collapsed .how-to-play-chevron {
  transform: rotate(-180deg);
}

.how-to-play-content {
  background: #2e1a3a;
  padding: 1rem 1.25rem;
  color: #fff;
  font-size: 0.95rem;
  line-height: 1.5;
}

.how-to-play-panel.is-collapsed .how-to-play-content {
  display: none;
}

.how-to-play-intro {
  margin: 0 0 0.75rem;
}

.how-to-play-list {
  margin: 0;
  padding-left: 1.25rem;
}

.how-to-play-list li {
  margin-bottom: 0.5rem;
}

.how-to-play-list li:last-child {
  margin-bottom: 0;
}

.how-to-play-list strong {
  color: #f5e6c8;
}

/* ===== Player Cards ===== */

.player-card {
  background: linear-gradient(135deg, #f5e6c8 0%, #e8d4a8 60%, #dcc494 100%);
  border: 3px solid #8b6914;
  border-radius: 12px;
  padding: 0;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  position: relative;
  /* overflow: hidden; */
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-height: 160px;
}

.player-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 2px solid rgba(196, 164, 60, 0.3);
  border-radius: 9px;
  margin: 3px;
  pointer-events: none;
}

.player-card-side {
  position: relative;
  flex-shrink: 0;
  width: 130px;
  min-height: 160px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0.35rem 0.25rem 0.15rem;
}

.player-card-side-inner {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  width: 120%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
}

.player-avatar {
  height: 100%;
  object-fit: cover;
  object-position: bottom center;
  flex-shrink: 0;
  display: block;
}

.player-card-body {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 0.75rem 1rem;
  min-width: 0;
}

.player-card-body .player-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: #4a3000;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid rgba(139, 105, 20, 0.25);
}

/* Counter rows */

.counter-block-seeds {
  margin-bottom: 0.4rem;
}

.counter-block-seeds .counter-row {
  margin-bottom: 0.15rem;
}

.seed-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.seed-icon-bg {
  position: absolute;
  top: 40%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.3rem;
  line-height: 1;
  /* opacity: 0.5; */
  z-index: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.seed-icon-wrap .counter-icon {
  position: relative;
  z-index: 1;
}

.counter-hint {
  font-size: 0.65rem;
  color: #6b5344;
  margin: 0 0 0.4rem 0;
  padding-left: 0;
  line-height: 1.2;
}

.counter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.counter-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.counter-label {
  font-size: 1rem;
  font-weight: 700;
  color: #4a3000;
  margin-left: 0.2rem;
  margin-right: 0.2rem;
  text-transform: capitalize;
}

.counter-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: #4a3000;
  min-width: 36px;
  text-align: center;
}

.counter-buttons {
  display: flex;
  gap: 0.35rem;
  margin-left: auto;
}

.btn-counter {
  width: 40px;
  height: 36px;
  border: none;
  border-radius: 6px;
  font-size: 1.3rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.1s,
    filter 0.1s;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn-counter:active {
  transform: scale(0.92);
}

.btn-plus {
  background: linear-gradient(180deg, #3a9e4a 0%, #2d7a3a 100%);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-plus:hover {
  filter: brightness(1.1);
}

.btn-minus {
  background: linear-gradient(180deg, #b83030 0%, #8b2020 100%);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-minus:hover {
  filter: brightness(1.1);
}

/* ===== Message Bar ===== */

.message-bar {
  background: linear-gradient(135deg, #f5e6c8, #e8d4a8);
  border: 2px solid #8b6914;
  border-radius: 10px;
  padding: 1rem 1.5rem;
  text-align: center;
  width: min(90%, 520px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.message-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: #4a3000;
  margin: 0;
}

/* ===== Action Buttons ===== */

.actions-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  max-width: 500px;
}

.btn {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 24px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.1s,
    filter 0.1s;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn:active {
  transform: scale(0.95);
}

.btn-wild {
  background: linear-gradient(180deg, #3a9e4a 0%, #2d7a3a 100%);
  color: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.btn-wild:hover {
  filter: brightness(1.1);
}

.btn-end {
  background: linear-gradient(180deg, #d4a017 0%, #b8860b 100%);
  color: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.btn-end:hover {
  filter: brightness(1.1);
}

.btn-reset {
  background: linear-gradient(180deg, #b83030 0%, #8b2020 100%);
  color: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.btn-reset:hover {
  filter: brightness(1.1);
}

/* ===== Modals ===== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: linear-gradient(135deg, #f5e6c8, #e8d4a8);
  border: 3px solid #8b6914;
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: modal-pop 0.25s ease-out;
}

@keyframes modal-pop {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #4a3000;
  margin: 0 0 1rem;
}

/* Wild Card Modal */

.wild-modal {
  background: #2a1a4a; /* Deep purple matching image */
  border: 3px solid #f9d86a; /* Bright gold border */
  border-radius: 20px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  max-width: 400px;
}

.wild-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  justify-content: center;
  width: 100%;
}

.wild-header-icon {
  width: 24px;
  height: auto;
  filter: drop-shadow(0 0 4px rgba(249, 216, 106, 0.5));
}

.wild-header-title {
  margin: 0;
  font-family: serif;
  font-size: 1.6rem;
  color: #f9d86a;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.wild-card-inner {
  background: #fcfbf7;
  border-radius: 12px;
  padding: 2rem 1.5rem 1.5rem;
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  margin-bottom: 0.5rem;
}

.wild-card-number {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 0.7rem;
  color: #b0a090;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.wild-main-icon {
  font-size: 3.5rem;
  margin-bottom: 0.8rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.wild-title {
  font-family: serif;
  font-size: 1.2rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #4a3000;
  margin: 0 0 0.8rem;
  letter-spacing: 0.5px;
}

.wild-body {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #5a4a3a;
  margin: 0 0 1.2rem;
}

.wild-badge {
  background: #f3ebd5;
  border: 1px solid #e0cda5;
  border-radius: 20px;
  padding: 0.4rem 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #8b6914;
}

/* Override close button for wild modal */
.wild-modal .btn-close-modal {
  background: transparent;
  box-shadow: none;
  color: #a080c0; /* Muted purple/grey text */
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 0;
  padding: 0.5rem 1rem;
  transition: color 0.2s;
}

.wild-modal .btn-close-modal:hover {
  color: #e0c0ff;
  background: transparent;
  filter: none;
}

.wild-modal .btn-close-modal::before {
  content: '✦ ';
}

.wild-modal .btn-close-modal::after {
  content: ' ✦';
}

/* End Game Modal */

.end-results {
  text-align: left;
  margin-bottom: 1rem;
}

.end-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(139, 105, 20, 0.2);
  font-weight: 600;
  color: #4a3000;
}

.end-result-row:last-child {
  border-bottom: none;
}

.end-result-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.end-result-score {
  font-weight: 800;
  font-size: 1.1rem;
}

.end-winner {
  font-size: 1.2rem;
  font-weight: 800;
  color: #8b6914;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: rgba(196, 164, 60, 0.15);
  border-radius: 8px;
}

.btn-close-modal {
  background: linear-gradient(180deg, #8b6914 0%, #6b4f10 100%);
  color: #f5e6c8;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.btn-close-modal:hover {
  filter: brightness(1.15);
}

/* Confirm Modal */

.confirm-text {
  color: #4a3000;
  font-weight: 600;
  margin: 0 0 1.2rem;
}

.confirm-buttons {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
}

/* ===== Toast Notification ===== */

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(40, 20, 10, 0.9);
  color: #f5e6c8;
  padding: 0.8rem 1.5rem;
  border-radius: 50px;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  pointer-events: none;
  border: 1px solid rgba(196, 164, 60, 0.5);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
  opacity: 1;
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
  /* Override display:none from tailwind hidden class if needed, but we use opacity transition */
  display: block !important;
}

/* ===== Floating Animations ===== */

.floating-item {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  z-index: 9999;
  animation: floatUpFade 0.8s ease-out forwards;
}

.floating-item .floating-sign {
  font-size: 1.25rem;
  font-weight: 800;
  color: #4a3000;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
  line-height: 1;
}

.floating-item .floating-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

@keyframes floatUpFade {
  0% {
    transform: translateY(0) scale(0.5);
    opacity: 0;
  }
  20% {
    transform: translateY(-10px) scale(1.2);
    opacity: 1;
  }
  100% {
    transform: translateY(-50px) scale(1);
    opacity: 0;
  }
}

@keyframes shake-error {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

.player-card.shake-error {
  animation: shake-error 0.4s ease-in-out;
}

/* ===== Footer ===== */

footer img {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

/* ===== Responsive ===== */

@media (max-width: 639px) {
  .header-banner {
    width: min(85%, 300px);
  }

  .subtitle {
    font-size: 0.85rem;
  }

  .hero-character {
    width: 100px;
  }

  .hero-dragon img {
    width: 180px;
  }

  .player-card-side {
    width: 100px;
    min-height: 130px;
  }

  .player-name {
    font-size: 1rem;
  }

  .counter-value {
    font-size: 1.2rem;
  }

  .btn-counter {
    width: 36px;
    height: 32px;
    font-size: 1.1rem;
  }

  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }

  .header-corner-logo {
    height: 80px;
    left: 0;
  }
  .header-subtitle {
    transform: translateY(-20px);
    font-size: 0.45rem;
  }

  .counter-label {
    font-size: 0.8rem;
    margin-left: 0;
    margin-right: 0;
  }

  .counter-value {
    font-size: 1rem;
  }

  .btn-counter {
    width: 32px;
    height: 28px;
  }
}

@media (min-width: 640px) {
  .hero-character {
    width: 200px;
  }

  .hero-dragon img {
    width: 380px;
  }

  .hero-panel-left {
    left: 15%;
  }

  .hero-panel-right {
    right: 10%;
  }
}
