/* =============================================================
   Lucky Packet — Main Stylesheet
   style.css
   ============================================================= */

/* ============================================================
   THEME VARIABLES — Edit these to restyle the whole game
   ============================================================ */
:root {
  /* --- Brand colours --- */
  --color-primary:        #8b0000;   /* deep red — main brand colour */
  --color-primary-mid:    #c0392b;   /* mid red — login gradient */
  --color-gold:           #ffd700;   /* gold — headings, credits */
  --color-gold-dark:      #c8a400;   /* darker gold — buttons */
  --color-gold-darker:    #a88700;   /* button hover */

  /* --- Game page --- */
  --game-bg-color:        #b20000;   /* fallback if background image fails */
  --game-overlay:         rgba(120, 0, 0, 0.55); /* tint over background image */

  /* --- Cards --- */
  --card-border-radius:   10px;

  /* --- Animation --- */
  --shake-duration:       0.6s;      /* how long the shake lasts */

  /* --- Bottom bar --- */
  --bar-bg:               rgba(0, 0, 0, 0.65);
  --bar-label-color:      rgba(255, 255, 255, 0.6);
  --bar-value-color:      #ffd700;

  /* --- Modals --- */
  --modal-overlay-bg:     rgba(0, 0, 0, 0.75);
  --modal-title-color:    #8b0000;
  --modal-prize-color:    #c8a400;

  /* --- Login page --- */
  --login-heading-color:  #8b0000;
  --login-box-shadow:     0 8px 40px rgba(0, 0, 0, 0.35);

  /* --- Alerts --- */
  --alert-error-bg:       #ffe0e0;
  --alert-error-text:     #8b0000;
  --alert-success-bg:     #e6f9ee;
  --alert-success-text:   #145a2e;
  --alert-warning-bg:     #fff8e1;
  --alert-warning-text:   #7a5c00;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  min-height: 100vh;
  color: #1a1a1a;
  background-color: var(--game-bg-color);
}

img { max-width: 100%; display: block; }
a   { text-decoration: none; color: inherit; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 0.55rem 1.3rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
  text-align: center;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--color-gold-dark);
  color: #fff;
  border-color: var(--color-gold-dark);
}
.btn-primary:hover { background: var(--color-gold-darker); border-color: var(--color-gold-darker); }

.btn-outline {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.7);
}
.btn-outline:hover { background: rgba(255, 255, 255, 0.15); }

/* Dark outline — used inside white modals */
.btn-outline-dark {
  background: transparent;
  color: #555;
  border-color: #bbb;
  border-width: 2px;
  border-style: solid;
  border-radius: 6px;
  padding: 0.55rem 1.3rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-outline-dark:hover { background: #f0f0f0; }

.btn-full { width: 100%; }

/* ---------- Alerts ---------- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.alert-error   { background: var(--alert-error-bg);   color: var(--alert-error-text);   border: 1px solid #f5c0c0; }
.alert-success { background: var(--alert-success-bg); color: var(--alert-success-text); border: 1px solid #a8e6bf; }
.alert-warning { background: var(--alert-warning-bg); color: var(--alert-warning-text); border: 1px solid #ffe082; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: #444;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-gold-dark);
  box-shadow: 0 0 0 3px rgba(200, 164, 0, 0.2);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-mid) 50%, var(--color-primary) 100%);
}

.login-wrap { width: 100%; max-width: 420px; padding: 1rem; }

.login-box {
  background: #fff;
  border-radius: 14px;
  padding: 2.5rem 2rem;
  box-shadow: var(--login-box-shadow);
}

.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo img { max-height: 80px; margin: 0 auto; }

.login-box h1 {
  text-align: center;
  font-size: 1.6rem;
  color: var(--login-heading-color);
  margin-bottom: 0.25rem;
}
.login-subtitle {
  text-align: center;
  color: #888;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ============================================================
   GAME PAGE
   ============================================================ */
.game-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

.game-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--game-overlay);
  z-index: 0;
  pointer-events: none;
}

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

/* Header */
.game-header { text-align: center; padding: 1.5rem 1rem 0.5rem; }
.game-logo   { max-height: 80px; margin: 0 auto 0.75rem; }

.game-title {
  font-size: 2rem;
  color: var(--color-gold);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.game-subtitle {
  font-size: 1.1rem;
  color: #fff;
  font-weight: 400;
  letter-spacing: 0.04em;
  margin-top: 0.25rem;
}

/* Card Grid */
.card-grid-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  width: 100%;
  max-width: 560px;
}

/* ============================================================
   CARDS — no background, just the image
   ============================================================ */
.card-slot {
  cursor: pointer;
  border-radius: var(--card-border-radius);
  overflow: hidden;
}

/* Used & disabled: no colour change, just block interaction */
.card-slot.used     { cursor: default;     pointer-events: none; }
.card-slot.disabled { cursor: not-allowed; pointer-events: none; }

.card-inner {
  position: relative;
  width: 100%;
  padding-top: 140%;           /* 5:7 aspect ratio */
  border-radius: var(--card-border-radius);
  background: transparent;     /* no background colour */
  overflow: hidden;
}

/* The card image fills the slot */
.card-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--card-border-radius);
  display: block;
}

/* ---- Shake animation ---- */
.card-inner.shaking {
  animation: cardShake var(--shake-duration) ease forwards;
}

@keyframes cardShake {
  0%   { transform: translateX(0)    rotate(0deg);  }
  10%  { transform: translateX(-8px) rotate(-3deg); }
  20%  { transform: translateX(8px)  rotate(3deg);  }
  30%  { transform: translateX(-8px) rotate(-3deg); }
  40%  { transform: translateX(8px)  rotate(3deg);  }
  50%  { transform: translateX(-6px) rotate(-2deg); }
  60%  { transform: translateX(6px)  rotate(2deg);  }
  70%  { transform: translateX(-4px) rotate(-1deg); }
  80%  { transform: translateX(4px)  rotate(1deg);  }
  90%  { transform: translateX(-2px) rotate(0deg);  }
  100% { transform: translateX(0)    rotate(0deg);  }
}

/* No credits message */
.no-credits-msg {
  text-align: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 10px;
  color: var(--color-gold);
  font-size: 1.1rem;
  margin-top: 1rem;
  max-width: 400px;
}

/* Bottom Bar */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bar-bg);
  backdrop-filter: blur(4px);
}
.bottom-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}
.bottom-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bar-label-color);
}
.bottom-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--bar-value-color);
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay-bg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 2rem 1.75rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-icon       { font-size: 3rem; margin-bottom: 0.5rem; }
.modal-title      { font-size: 1.5rem; color: var(--modal-title-color); margin-bottom: 0.5rem; }
.modal-prize-name { font-size: 1.25rem; font-weight: 700; color: var(--modal-prize-color); margin-bottom: 0.5rem; }
.modal-prize-desc { color: #555; margin-bottom: 1.5rem; font-size: 0.95rem; }

/* Two-button row in prize modal */
.modal-btns {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.modal-terms    { max-width: 560px; text-align: left; }
.modal-terms h2 { text-align: center; color: var(--modal-title-color); margin-bottom: 1rem; }
.terms-body {
  max-height: 300px;
  overflow-y: auto;
  padding: 0.75rem;
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: #333;
  margin-bottom: 1rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 500px) {
  .card-grid     { grid-template-columns: repeat(2, 1fr); max-width: 340px; }
  .game-subtitle { font-size: 0.95rem; }
  .bottom-bar    { gap: 0.5rem; }
  .btn           { padding: 0.5rem 0.9rem; font-size: 0.82rem; }
  .modal-btns    { flex-direction: column; }
  .modal-btns .btn,
  .modal-btns .btn-outline-dark { width: 100%; }
}

@media (max-width: 360px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
}
