/* ============================================================
   Secret Hitler – Role Generator  |  style.css
   ============================================================ */

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

:root {
  --color-bg:        #1a0a00;
  --color-surface:   #2c1500;
  --color-border:    #7a3e00;
  --color-gold:      #c9982a;
  --color-gold-light:#f0c040;
  --color-text:      #f5e9d0;
  --color-muted:     #a08060;
  --color-liberal:   #3a7abf;
  --color-fascist:   #c0392b;
  --color-hitler:    #6b0000;
  --font-serif:      Georgia, 'Times New Roman', serif;
  --font-sans:       'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --radius:          8px;
  --transition:      0.25s ease;
}

body {
  background-color: var(--color-bg);
  background-image:
    radial-gradient(ellipse at top, #3a1a00 0%, #1a0a00 60%);
  color: var(--color-text);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------- Header ---------- */
header {
  text-align: center;
  padding: 2.5rem 1rem 1rem;
}

header h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 6vw, 3.8rem);
  color: var(--color-gold);
  letter-spacing: 0.06em;
  text-shadow: 0 0 30px #c9982a88;
}

header .subtitle {
  color: var(--color-muted);
  font-size: 1rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 0.25rem;
}

/* ---------- Main ---------- */
main {
  width: 100%;
  max-width: 680px;
  padding: 1rem 1rem 3rem;
  flex: 1;
}

.card-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.8rem 2rem;
  margin-top: 1.5rem;
  box-shadow: 0 4px 24px #00000088;
}

.card-panel h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--color-gold);
  margin-bottom: 0.5rem;
}

.hint {
  color: var(--color-muted);
  font-size: 0.88rem;
  margin-bottom: 1.2rem;
  line-height: 1.5;
}

/* ---------- Form ---------- */
.input-row {
  display: flex;
  gap: 0.5rem;
}

input[type="text"] {
  flex: 1;
  background: #120800;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 1rem;
  padding: 0.55rem 0.8rem;
  outline: none;
  transition: border-color var(--transition);
}

input[type="text"]:focus {
  border-color: var(--color-gold);
}

input[type="text"]::placeholder {
  color: var(--color-muted);
}

/* ---------- Buttons ---------- */
.btn {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.55rem 1.2rem;
  transition: background var(--transition), opacity var(--transition), transform 0.1s;
  letter-spacing: 0.03em;
}

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

.btn-primary {
  background: var(--color-gold);
  color: #1a0a00;
  width: 100%;
  margin-top: 1rem;
  font-size: 1.05rem;
  padding: 0.7rem;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-gold-light);
}

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-secondary {
  background: #3a1e00;
  color: var(--color-gold);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: #4e2a00;
}

/* ---------- Player list ---------- */
#player-list {
  list-style: none;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#player-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #120800;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.5rem 0.8rem;
  font-size: 0.95rem;
  animation: fadeIn 0.2s ease;
}

.player-number {
  color: var(--color-gold);
  font-weight: 700;
  margin-right: 0.6rem;
  min-width: 1.4rem;
  text-align: right;
}

.player-name {
  flex: 1;
}

.remove-btn {
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.2rem;
  transition: color var(--transition);
}

.remove-btn:hover {
  color: #e74c3c;
}

.player-count {
  color: var(--color-muted);
  font-size: 0.82rem;
  margin-top: 0.6rem;
  text-align: right;
}

/* ---------- Role grid ---------- */
.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

/* ---------- Role card ---------- */
.role-card {
  perspective: 800px;
  cursor: pointer;
  height: 200px;
}

.role-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius);
}

.role-card.flipped .role-card-inner {
  transform: rotateY(180deg);
}

/* Shared face styles */
.role-front,
.role-back {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 0.6rem;
  border: 2px solid var(--color-border);
  box-shadow: 0 4px 12px #00000066;
  user-select: none;
}

/* Front – name face */
.role-front {
  background: linear-gradient(160deg, #2c1500, #1a0a00);
  gap: 0.5rem;
}

.role-front .card-icon {
  font-size: 2.2rem;
}

.role-front .card-player-name {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--color-text);
  text-align: center;
  word-break: break-word;
}

.role-front .card-tap-hint {
  font-size: 0.7rem;
  color: var(--color-muted);
  margin-top: auto;
}

/* Back – role face */
.role-back {
  transform: rotateY(180deg);
  gap: 0.4rem;
}

.role-back .role-label {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.03em;
}

.role-back .role-icon {
  font-size: 2.4rem;
  margin-bottom: 0.2rem;
}

.role-back .role-desc {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
  line-height: 1.4;
}

.role-back .card-tap-hint {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: auto;
}

/* Liberal */
.role-back.liberal {
  background: linear-gradient(160deg, #1a3a5c, #0d1f33);
  border-color: #4a8fd4;
}

.role-back.liberal .role-label {
  color: #7bc3ff;
}

/* Fascist */
.role-back.fascist {
  background: linear-gradient(160deg, #5c1a1a, #330d0d);
  border-color: #c0392b;
}

.role-back.fascist .role-label {
  color: #ff8080;
}

/* Hitler */
.role-back.hitler {
  background: linear-gradient(160deg, #3c0000, #1a0000);
  border-color: #8b0000;
}

.role-back.hitler .role-label {
  color: #ff4040;
}

/* ---------- Results actions ---------- */
.results-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.results-actions .btn {
  flex: 1;
  min-width: 130px;
  text-align: center;
}

.results-actions .btn-primary {
  width: auto;
  margin-top: 0;
}

/* ---------- Customization panel ---------- */
.customize-panel {
  margin-top: 1.2rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #120800;
  overflow: hidden;
}

.customize-summary {
  cursor: pointer;
  color: var(--color-gold);
  font-size: 0.9rem;
  padding: 0.6rem 0.8rem;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: background var(--transition);
}

.customize-summary::-webkit-details-marker { display: none; }

.customize-summary:hover {
  background: #1e0c00;
}

.customize-hint {
  color: var(--color-muted);
  font-size: 0.78rem;
  font-weight: 400;
}

.customize-body {
  padding: 0.8rem;
  border-top: 1px solid var(--color-border);
}

.customize-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.8rem;
  margin-top: 0.6rem;
}

.customize-role {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.customize-role-icon {
  font-size: 1.6rem;
  text-align: center;
}

.customize-role-label {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  text-align: center;
}

.liberal-label { color: var(--color-liberal); }
.fascist-label { color: var(--color-fascist); }
.hitler-label  { color: #ff4040; }

.customize-field-label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--color-muted);
}

.customize-field-label input[type="text"] {
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
}

.file-input {
  font-size: 0.75rem;
  color: var(--color-muted);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}

.custom-preview {
  width: 100%;
  max-height: 80px;
  object-fit: contain;
  border-radius: 4px;
}

/* ---------- Print section (screen: hidden, print: visible) ---------- */
@media screen {
  #print-section {
    display: none;
  }
}

/* ---------- @media print ---------- */
@media print {
  header,
  main,
  footer {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    display: block;
  }

  #print-section {
    display: block;
  }

  .print-page-title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.4rem;
    text-align: center;
    margin-bottom: 0.35in;
    color: #222;
  }

  .print-grid {
    display: grid;
    grid-template-columns: repeat(3, 2.5in);
    gap: 0.2in;
    justify-content: center;
  }

  .print-card {
    width: 2.5in;
    height: 3.5in;
    border: 1px dashed #aaa;
    border-radius: 6px;
    padding: 0.18in 0.15in;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.1in;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-card.liberal { background: #f0f8ff; border-color: #3a7abf; }
  .print-card.fascist { background: #fff0f0; border-color: #c0392b; }
  .print-card.hitler  { background: #ffe8e8; border-color: #8b0000; }

  .print-card-role {
    font-family: Georgia, serif;
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
    width: 100%;
  }

  .print-card.liberal .print-card-role { color: #1a4a80; }
  .print-card.fascist .print-card-role { color: #8b0000; }
  .print-card.hitler  .print-card-role { color: #6b0000; }

  .print-card-icon {
    font-size: 2.4rem;
    flex: 1;
    display: flex;
    align-items: center;
  }

  .print-card-img {
    max-width: 1.8in;
    max-height: 1.6in;
    object-fit: contain;
    flex: 1;
  }

  .print-card-name {
    font-family: Georgia, serif;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    border-top: 1px solid #999;
    padding-top: 0.08in;
    width: 100%;
  }

  .print-card-desc {
    font-size: 0.62rem;
    text-align: center;
    color: #444;
    line-height: 1.35;
  }
}

/* ---------- Utility ---------- */
.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Footer ---------- */
footer {
  text-align: center;
  color: var(--color-muted);
  font-size: 0.78rem;
  padding: 1rem;
}

footer a {
  color: var(--color-gold);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .card-panel {
    padding: 1.2rem 1rem;
  }

  .role-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .role-card {
    height: 180px;
  }
}

/* ---------- Player count select ---------- */
select.count-select-input {
  flex: 1;
  background: #120800;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 1rem;
  padding: 0.55rem 0.8rem;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23a08060' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2rem;
}

select.count-select-input:focus {
  border-color: var(--color-gold);
}

select.count-select-input option {
  background: #120800;
  color: var(--color-text);
}


.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.2rem;
}

.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  background: #120800;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.4rem 1rem 1rem;
  cursor: pointer;
  text-align: center;
  transition: background var(--transition), border-color var(--transition), transform 0.1s;
  color: var(--color-text);
}

.mode-card:hover {
  background: #1e0c00;
  border-color: var(--color-gold);
  transform: translateY(-2px);
}

.mode-card:active {
  transform: scale(0.98);
}

.mode-card-featured {
  border-color: var(--color-gold);
  background: linear-gradient(160deg, #2c1500, #120800);
}

.mode-badge {
  position: absolute;
  top: -0.55rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-gold);
  color: #1a0a00;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.mode-icon {
  font-size: 2.2rem;
}

.mode-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--color-gold);
}

.mode-desc {
  font-size: 0.78rem;
  color: var(--color-muted);
  line-height: 1.45;
}

/* ---------- Section header with back button ---------- */
.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.section-header h2 {
  margin-bottom: 0;
}

.btn-back {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 0.82rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.btn-back:hover {
  color: var(--color-gold);
  border-color: var(--color-gold);
}

/* ---------- Step headings ---------- */
.step-heading {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--color-gold);
  margin-bottom: 0.4rem;
}

/* ---------- Custom role form row ---------- */
.custom-role-input-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.icon-input {
  flex: 0 0 3.5rem;
  text-align: center;
  font-size: 1.1rem;
}

.count-input {
  flex: 0 0 4rem;
  text-align: center;
}

/* ---------- Custom role list ---------- */
.custom-role-list {
  list-style: none;
  margin-top: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.custom-role-list li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: #120800;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.5rem 0.8rem;
  font-size: 0.92rem;
  animation: fadeIn 0.2s ease;
}

.custom-role-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.custom-role-list .role-icon-col {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.custom-role-list .role-name-col {
  flex: 1;
  font-weight: 600;
}

.custom-role-list .role-count-badge {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  color: var(--color-muted);
  white-space: nowrap;
}

/* ---------- Custom role colour palette (5 colours, cycle) ---------- */
/* Used on screen role cards (.role-back.custom-N) and print cards (.print-card.custom-N) */

/* 0 = blue */
.role-back.custom-0 { background: linear-gradient(160deg, #1a3a5c, #0d1f33); border-color: #4a8fd4; }
.role-back.custom-0 .role-label { color: #7bc3ff; }
.custom-swatch-0 { background: #4a8fd4; }

/* 1 = red */
.role-back.custom-1 { background: linear-gradient(160deg, #5c1a1a, #330d0d); border-color: #c0392b; }
.role-back.custom-1 .role-label { color: #ff8080; }
.custom-swatch-1 { background: #c0392b; }

/* 2 = green */
.role-back.custom-2 { background: linear-gradient(160deg, #1a4a1a, #0d2a0d); border-color: #27ae60; }
.role-back.custom-2 .role-label { color: #7fff7f; }
.custom-swatch-2 { background: #27ae60; }

/* 3 = purple */
.role-back.custom-3 { background: linear-gradient(160deg, #3a1a5c, #1f0d33); border-color: #8e44ad; }
.role-back.custom-3 .role-label { color: #cc99ff; }
.custom-swatch-3 { background: #8e44ad; }

/* 4 = amber */
.role-back.custom-4 { background: linear-gradient(160deg, #5c3a1a, #33200d); border-color: #e67e22; }
.role-back.custom-4 .role-label { color: #ffaa55; }
.custom-swatch-4 { background: #e67e22; }

/* ---------- Print colours for custom roles ---------- */
@media print {
  .print-card.custom-0 { background: #f0f8ff; border-color: #3a7abf; }
  .print-card.custom-0 .print-card-role { color: #1a4a80; }

  .print-card.custom-1 { background: #fff0f0; border-color: #c0392b; }
  .print-card.custom-1 .print-card-role { color: #8b0000; }

  .print-card.custom-2 { background: #f0fff0; border-color: #27ae60; }
  .print-card.custom-2 .print-card-role { color: #1a5c1a; }

  .print-card.custom-3 { background: #f8f0ff; border-color: #8e44ad; }
  .print-card.custom-3 .print-card-role { color: #5a1a8b; }

  .print-card.custom-4 { background: #fff8f0; border-color: #e67e22; }
  .print-card.custom-4 .print-card-role { color: #7a4000; }
}
