@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

:root {
  --primary-color: #4a90e2;
  --secondary-color: #f5a623;
  --background-color: #e0eaf4;
  --text-color: #333;
  --light-text-color: #fff;
  --border-radius: 12px;
  --box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  --input-border-color: #ddd;
  --footer-border-color: #ddd;
  --footer-text-color: #777;
  --action-button-hover: #357abd;
}

/* Dark Mode Overrides */
@media (prefers-color-scheme: dark) {
  :root {
    --primary-color: #6aa6ff;
    --secondary-color: #ffa94d;
    --background-color: #1e1e2f;
    --text-color: #eee;
    --light-text-color: #111;
    --box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    --input-border-color: #555;
    --footer-border-color: #444;
    --footer-text-color: #aaa;
    --action-button-hover: #5589cc;
  }

  body {
    background-color: var(--background-color);
    color: var(--text-color);
  }



  .result-container {
    background-color: #2a2a3d;
  }

  .action-button.active {
    background-color: var(--secondary-color);
  }

  .input-section input,
  .input-section textarea {
    border: 2px solid var(--input-border-color);
    background-color: #333;
    color: var(--text-color);
  }

  footer {
    border-top: 1px solid var(--footer-border-color);
    color: var(--footer-text-color);
  }

  footer a,
  footer .footer-link {
    color: var(--primary-color);
  }

  .face {
    background: #333;
    border: 2px solid #eee;
    color: var(--text-color);
  }

  .coin-face {
    border-color: #bfa43a;
    color: var(--text-color);
    text-shadow: 1px 1px 2px #bfa43a;
  }



  .red-card,
  .black-card {
    background: white;
    width: 5.8rem;
    /* fixed card width */
    height: 7rem;
    /* fixed card height */
    line-height: 6rem;
    /* vertical centering */
    border-radius: 6px;
    display: inline-block;
    text-align: center;
  }
}

* {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

html,
body {
  touch-action: manipulation;
}

body {
  font-family: 'Poppins', sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  margin: 0;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  text-align: center;
}

.container {
  width: 100%;
  max-width: 900px;
  background: #ffffff;
  /* light mode container */
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  padding: 30px;
  box-sizing: border-box;
}

@media (prefers-color-scheme: dark) {
  .container {
    background-color: #2a2a3d;
    /* dark mode container */
    box-shadow: var(--box-shadow);
    /* you can keep the same or adjust if you want softer shadow */
  }
}

header {
  margin-bottom: 30px;
}

h1 {
  color: var(--primary-color);
  margin: 0;
  font-size: 2.5rem;
  font-weight: 700;
}

#current-selection {
  font-size: 1.8rem;
  color: var(--secondary-color);
  margin-top: 10px;
  font-weight: 600;
  min-height: 32px;
}

main {
  margin-bottom: 30px;
}

.result-container {
  background-color: var(--background-color);
  border-radius: var(--border-radius);
  padding: 30px;
  margin-bottom: 30px;
  min-height: 150px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  /* Mask sliding */
  position: relative;
  /* Needed for absolute children */
}

#result-display {
  position: relative;
  font-size: 2rem;
  font-weight: 600;
  word-wrap: break-word;
}

#result-display.red-card,
#result-display.black-card {
  font-size: 3rem;
  /* overrides the base 2rem */
}

#color-display {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  margin: 0 auto 10px;
  border: 5px solid #fff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

#bottle-display {
  width: auto;
  height: 160px;
  transition: transform 3s cubic-bezier(0.25, 1, 0.5, 1);
  margin: -30px;
  /* equal to result-container padding */
  display: block;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}

.action-button {
  background-color: var(--primary-color);
  color: var(--light-text-color);
  border: none;
  border-radius: var(--border-radius);
  padding: 15px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.action-button:hover {
  background-color: var(--action-button-hover);
  transform: translateY(-2px);
}

.action-button:active {
  transform: translateY(1px);
}

.action-button.active {
  background-color: var(--secondary-color);
}

.input-section {
  width: 100%;
  /* full width of the page */
  padding: 0 20px;
  /* 20px left/right gutters */
  margin: 20px 0;
  /* vertical spacing */
  box-sizing: border-box;
  /* include padding in width */
}

.input-section input,
.input-section textarea {
  padding: 10px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  flex: 1 1 auto;
  /* grow/shrink as needed */
  min-width: 0;
  /* prevent flex overflow */
}

.input-section input {
  max-width: 200px;
  /* keep inputs capped */
}

.input-section textarea {
  width: 100%;
  /* always fill container */
  min-width: 0;
  /* prevents shrinking below parent */
  height: 100px;
  padding: 10px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  resize: vertical;
  box-sizing: border-box;
  /* include padding/border in width */
}


.explanation {
  margin-top: 40px;
  text-align: left;
  line-height: 1.6;
}

.explanation h2 {
  text-align: center;
  color: var(--primary-color);
}

footer {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #ddd;
  font-size: 0.9rem;
  color: #777;
}

footer p {
  margin: 5px 0;
}

footer a,
footer .footer-link {
  color: var(--primary-color);
  text-decoration: none;
}

footer a:hover,
footer .footer-link:hover {
  text-decoration: underline;
}

@media (max-width: 600px) {
  body {
    padding: 10px;
  }

  .container {
    padding: 20px;
  }

  h1 {
    font-size: 2rem;
  }

  #current-selection {
    font-size: 1.5rem;
  }

  .button-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .input-section {
    flex-direction: column;
  }
}

#resultDisplay {
  font-family: "Segoe UI Symbol", "DejaVu Sans", "Arial Unicode MS", sans-serif;
  font-size: 2rem;
}

.red-card {
  color: red;
  font-family: "Segoe UI Symbol", "DejaVu Sans", "Arial Unicode MS", sans-serif;
  font-size: 3rem;
}

.black-card {
  color: black;
  font-family: "Segoe UI Symbol", "DejaVu Sans", "Arial Unicode MS", sans-serif;
  font-size: 3rem;
}


.dice-container {
  perspective: 600px;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 150px;
  /* Adjust container height to fit larger dice */
}

.dice {
  width: 100px;
  /* Increase dice width */
  height: 100px;
  /* Increase dice height */
  position: relative;
  transform-style: preserve-3d;
  transition: transform 1s cubic-bezier(.36, 2, .57, .5);
}

.face {
  position: absolute;
  width: 100px;
  /* Match dice width */
  height: 100px;
  /* Match dice height */
  background: #fff;
  border: 2px solid #333;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  backface-visibility: hidden;
}

.dot {
  width: 18px;
  height: 18px;
  background: #222;
  border-radius: 50%;
  position: absolute;
}

.dot.center {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.dot.top-left {
  top: 20%;
  left: 20%;
}

.dot.top-right {
  top: 20%;
  right: 20%;
}

.dot.middle-left {
  top: 50%;
  left: 20%;
  transform: translateY(-50%);
}

.dot.middle-right {

  top: 50%;
  right: 20%;
  transform: translateY(-50%);
}

.dot.bottom-left {
  bottom: 20%;
  left: 20%;
}

.dot.bottom-right {
  bottom: 20%;
  right: 20%;
}

.face.one {
  transform: rotateY(0deg) translateZ(50px);
  /* Adjust translateZ to half of dice size */
}

.face.two {
  transform: rotateY(180deg) translateZ(50px);
}

.face.three {
  transform: rotateY(90deg) translateZ(50px);
}

.face.four {
  transform: rotateY(-90deg) translateZ(50px);
}

.face.five {
  transform: rotateX(90deg) translateZ(50px);
}

.face.six {
  transform: rotateX(-90deg) translateZ(50px);
}

.coin-container {
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 1000px;
  height: 150px;
  width: 150px;
  margin: 0 auto;
}

.coin-outer {
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  /* Enable 3D transformations */
}

.coin {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  /* keeps depth during flip */
  transition: transform 1.2s cubic-bezier(.23, 1.5, .57, 1);
}


.coin-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
  /* hide back when flipped */
}

.coin-heads {
  transform: rotateY(0deg);
}

.coin-tails {
  transform: rotateY(180deg);
}

.coin-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

#result-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 999;
  /* Ensure it's above most elements but below the inject popup */
  background: transparent;
  /* Keep it invisible */
  cursor: pointer;
  /* Indicate it's clickable */
}


.hidden {
  display: none;
}

.popup {
  position: fixed;
  top: 20%;
  /* top third by default */
  left: 50%;
  transform: translateX(-50%);
  background: var(--background-color);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  padding: 20px;
  z-index: 1000;
  text-align: center;
  width: 250px;
  color: var(--text-color);
}

.popup-content h2 {
  margin: 0 0 10px;
  font-size: 1.2rem;
  color: var(--text-color);
}

.popup-content input {
  width: 90%;
  padding: 6px;
  border: 1px solid var(--input-border-color);
  border-radius: var(--border-radius);
  background: var(--light-text-color);
  color: var(--text-color);
}

.status {
  margin-top: 10px;
  font-weight: bold;
  color: green;
  /* stays green for success */
}

#cancelPopup,
#okPopup {
  margin-left: 10px;
  margin-top: 15px;
  padding: 6px 12px;
  border: none;
  border-radius: var(--border-radius);
  background: #6aa6ff;
  cursor: pointer;
  color: white;
  transition: background 0.2s;
}

#cancelPopup:hover {
  background: var(--action-button-hover);
  color: var(--light-text-color);
}

.tabs {
  display: flex;
  justify-content: center;
  margin-bottom: 1em;
  gap: 10px;
  flex-wrap: wrap;
}

.tab {
  background: var(--background-color);
  border: 1px solid var(--input-border-color);
  padding: 10px 15px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-weight: bold;
  color: var(--text-color);
  transition: background 0.3s;
}

.tab:hover {
  background: var(--action-button-hover);
  color: var(--light-text-color);
}

.tab.active {
  background: var(--primary-color);
  color: var(--light-text-color);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
  display: block;
}

.blur {
  filter: blur(6px);
  pointer-events: none;
  /* prevent clicking background while blurred */
  user-select: none;
}


.card-display {
  top: 0;
  left: 0;
  right: 0;
  margin: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 112.5px;
  height: 150px;
  overflow: hidden;
  border-radius: 7px;
  background-color: #fff;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card-image {
  height: 100%;
  width: auto;
  object-fit: cover;
}

/* Bounce out (shrink + blur quickly) */
.card-display.bounce-out {
  animation: bounceOut 0.1s ease forwards;
}

/* Bounce in with subtle overshoot */
.card-display.bounce-in {
  animation: bounceIn 0.2s cubic-bezier(0.22, 1.4, 0.36, 1) forwards;
}

@keyframes bounceOut {
  from {
    transform: scale(1);
    /* filter: blur(0); */
    opacity: 1;
  }

  to {
    transform: scale(0.95);
    /* filter: blur(2px); */
    opacity: 0.8;
  }
}

@keyframes bounceIn {
  0% {
    transform: scale(0.95);
    /* filter: blur(2px); */
    opacity: 0.8;
  }

  60% {
    transform: scale(1.03);
    /* filter: blur(0.5px); */
    opacity: 1;
  }

  100% {
    transform: scale(1);
    /* filter: blur(0); */
    opacity: 1;
  }
}


.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.popup-box {
  background: var(--background-color);
  color: var(--text-color);
  padding: 20px;
  border-radius: var(--border-radius);
  max-width: 400px;
  width: 90%;
  box-shadow: var(--box-shadow);
  position: relative;
  margin: 2vh 2vh;
  max-height: 90dvh;
  /* use dynamic viewport height */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.popup-box h2 {
  margin-top: 0;
  color: var(--primary-color);
}

.popup-box p {
  font-size: 0.95rem;
  margin-bottom: 15px;
  color: var(--text-color);
}

.popup-box label {
  display: block;
  margin: 10px 0;
  font-weight: 500;
}

.popup-box input,
.popup-box textarea {
  width: 90%;
  padding: 10px;
  margin-top: 4px;
  border: 1px solid var(--input-border-color);
  border-radius: var(--border-radius);
  background: #fff;
  color: var(--text-color);
  font-size: 0.9rem;
}

@media (prefers-color-scheme: dark) {

  .popup-box input,
  .popup-box textarea {
    background: #2a2a3d;
    color: var(--text-color);
  }
}

.popup-box button[type="submit"] {
  margin-top: 12px;
  padding: 10px;
  width: 100%;
  background: var(--primary-color);
  color: var(--light-text-color);
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.3s ease;
}

.popup-box button[type="submit"]:hover {
  background: var(--action-button-hover);
}

.close-btn {
  background: none;
  border: none;
  font-size: 22px;
  position: absolute;
  top: 12px;
  right: 15px;
  cursor: pointer;
  color: var(--text-color);
}


.popup-box.privacy-box {
  background: var(--background-color);
  color: var(--text-color);
  width: 560px;
  max-width: 94%;
  padding: 20px;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  position: relative;
  font-size: 0.95rem;
}

.privacy-box h2 {
  color: var(--primary-color);
  margin-top: 0;
}

.policy-content p {
  margin: 0.6rem 0;
  line-height: 1.35;
}

.privacy-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  justify-content: flex-end;
}

.small {
  padding: 8px 12px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
}

.small.primary {
  background: var(--primary-color);
  color: var(--light-text-color);
}

.small.secondary {
  background: transparent;
  border: 1px solid var(--footer-border-color);
  color: var(--text-color);
}

.small.primary:hover {
  background: var(--action-button-hover);
}

.close-btn {
  background: none;
  border: none;
  font-size: 20px;
  position: absolute;
  top: 12px;
  right: 14px;
  cursor: pointer;
  color: var(--text-color);
}

@media (prefers-color-scheme: dark) {
  .privacy-box {
    background: var(--background-color);
    color: var(--text-color);
  }

  .small.secondary {
    border-color: var(--footer-border-color);
    color: var(--text-color);
  }
}


.popup-box.faq-box {
  background: var(--background-color);
  color: var(--text-color);
  width: 640px;
  max-width: 96%;
  padding: 20px;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  position: relative;
  font-size: 0.95rem;
}

.faq-box h2 {
  color: var(--primary-color);
  margin-top: 0;
}

.faq-content h3 {
  margin: 0.6rem 0 0.25rem;
}

.faq-content p {
  margin: 0 0 0.6rem;
  line-height: 1.35;
}

.faq-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  justify-content: flex-end;
}

.small {
  padding: 8px 12px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
}

.small.primary {
  background: var(--primary-color);
  color: var(--light-text-color);
}

.small.secondary {
  background: transparent;
  border: 1px solid var(--footer-border-color);
  color: var(--text-color);
}

.small.primary:hover {
  background: var(--action-button-hover);
}

.close-btn {
  background: none;
  border: none;
  font-size: 20px;
  position: absolute;
  top: 12px;
  right: 14px;
  cursor: pointer;
  color: var(--text-color);
}

@media (prefers-color-scheme: dark) {
  .faq-box {
    background: var(--background-color);
    color: var(--text-color);
  }

  .small.secondary {
    border-color: var(--footer-border-color);
    color: var(--text-color);
  }
}


.toggle-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10vw;
}

.invisible-toggle {
  background: transparent;
  border: none;
  width: 15vw;
  height: 15vw;
  cursor: pointer;
  /* completely invisible */
  opacity: 0;
}

#rerun-randomizer {
  transition: color 0.5s ease;
}