/* ============================================================
   Tajemství názvu města Roudnice
   ============================================================ */

:root {
  --bg: #2b1810;
  --bg-2: #3a221a;
  --bg-3: #4a2c20;
  --gold: #d4af37;
  --gold-soft: #b8962e;
  --gold-bright: #f0c850;
  --cream: #f5f5dc;
  --white: #fff8e7;
  --red: #8b0000;
  --red-bright: #b71c1c;
  --green: #2d5016;
  --green-bright: #4a8b2c;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --display: 'Cinzel', 'Trajan Pro', Georgia, serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  background: radial-gradient(ellipse at top, var(--bg-2) 0%, var(--bg) 60%, #1a0e08 100%);
  color: var(--cream);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button { cursor: pointer; touch-action: manipulation; }

.hidden { display: none !important; }

/* ============ STOPKY ============ */

#timer-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(180deg, #1a0e08 0%, #2b1810 100%);
  border-bottom: 2px solid var(--gold);
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}

.timer-team {
  font-family: var(--display);
  letter-spacing: 1px;
  color: var(--gold);
  font-size: 1rem;
}
.timer-team span {
  color: var(--white);
  font-weight: 700;
}

.timer-clock {
  font-family: var(--display);
  font-weight: 900;
  font-size: 2.5rem;
  color: var(--gold-bright);
  text-shadow: 0 0 12px rgba(212, 175, 55, 0.4);
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}

.timer-progress {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
}

.gate-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 2px solid var(--red);
  background: rgba(139, 0, 0, 0.2);
  color: var(--cream);
  font-family: var(--display);
  font-weight: 700;
  transition: all 0.4s ease;
}
.gate-pill.done {
  border-color: var(--green-bright);
  background: var(--green);
  color: var(--white);
  box-shadow: 0 0 10px var(--green-bright);
}

/* ============ OBRAZOVKY ============ */

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.screen { display: none; animation: fadeIn 0.6s ease; }
.screen.active { display: block; }

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

/* ============ INTRO ============ */

.intro-container {
  max-width: 600px;
  margin: 4rem auto;
  text-align: center;
}

.title-main {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2rem, 6vw, 4rem);
  letter-spacing: 4px;
  color: var(--gold-bright);
  text-shadow: 0 4px 20px rgba(0,0,0,0.8), 0 0 30px rgba(212, 175, 55, 0.3);
  margin-bottom: 1rem;
  line-height: 1.1;
}

.subtitle {
  font-size: 1.4rem;
  color: var(--cream);
  font-style: italic;
  margin-bottom: 3rem;
}

.intro-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: stretch;
}

.intro-form label {
  font-family: var(--display);
  color: var(--gold);
  letter-spacing: 2px;
  text-transform: uppercase;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 1.2rem 1.5rem;
  background: rgba(0,0,0,0.4);
  border: 2px solid var(--gold-soft);
  border-radius: 10px;
  color: var(--white);
  font-family: var(--display);
  font-size: 1.5rem;
  text-align: center;
  letter-spacing: 2px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.2);
}

/* ============ TLAČIDLÁ ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  padding: 1rem 2rem;
  border-radius: 10px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
  border: 2px solid transparent;
  user-select: none;
}
.btn:active { transform: scale(0.97); }

.btn-start {
  background: linear-gradient(180deg, #4a8b2c 0%, #2d5016 100%);
  color: var(--white);
  border-color: #6cbf3a;
  box-shadow: 0 6px 0 #1f3810, 0 10px 20px rgba(0,0,0,0.4);
  font-size: 1.5rem;
  padding: 1.3rem 2rem;
}
.btn-start:hover { background: linear-gradient(180deg, #5aa635 0%, #366018 100%); }

.btn-ghost {
  background: transparent;
  color: var(--gold);
  border-color: var(--gold-soft);
}
.btn-ghost:hover {
  background: rgba(212, 175, 55, 0.1);
  color: var(--gold-bright);
}

.btn-gate {
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold-soft) 100%);
  color: var(--bg);
  border-color: var(--gold-bright);
  font-weight: 900;
}

.btn-primary {
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold-soft) 100%);
  color: var(--bg);
  border-color: var(--gold-bright);
}

/* ============ HERNÁ PLOCHA ============ */

.game-intro {
  text-align: center;
  margin: 1rem auto 2rem;
}
.game-intro h2 {
  font-family: var(--display);
  color: var(--gold-bright);
  letter-spacing: 2px;
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin-bottom: 0.5rem;
}
.reveal-wrap {
  margin: 2.5rem auto 3rem;
  text-align: center;
  max-width: 720px;
  padding: 0 1.5rem;
}
.reveal-hint {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--cream);
  font-style: italic;
  margin-bottom: 1.25rem;
  opacity: 0.9;
}
#btn-reveal {
  animation: reveal-pulse 2.2s ease-in-out infinite;
}
@keyframes reveal-pulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(212, 175, 55, 0.3); }
  50%      { box-shadow: 0 6px 30px rgba(212, 175, 55, 0.7); }
}

.game-intro p {
  color: var(--cream);
  font-style: italic;
}

.gates {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  perspective: 1500px;
}

.gate {
  position: relative;
  aspect-ratio: 3 / 4;
  perspective: 1500px;
}

.gate-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}
.gate.unlocked .gate-inner { transform: rotateY(180deg); }

.gate-front, .gate-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.gate-front {
  border: 3px solid var(--red);
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
}

.gate-img {
  flex: 1;
  background-size: cover;
  background-position: center top;
  background-color: var(--bg-3);
  filter: sepia(0.2) brightness(0.85);
}

.gate-front-overlay {
  background: linear-gradient(180deg, rgba(43,24,16,0.4) 0%, rgba(26,14,8,0.95) 60%);
  padding: 1rem 1rem 1.2rem;
  text-align: center;
  color: var(--white);
}
.gate-front-overlay h3 {
  font-family: var(--display);
  letter-spacing: 1.5px;
  font-size: 1.1rem;
  color: var(--gold-bright);
}
.gate-front-overlay p {
  font-style: italic;
  font-size: 1rem;
  color: var(--cream);
  margin: 0.25rem 0 0.7rem;
}

.lock-icon {
  font-size: 2rem;
  margin: -2.5rem 0 0.5rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
}

.gate-back {
  transform: rotateY(180deg);
  border: 3px solid var(--green-bright);
  background: linear-gradient(180deg, #2d5016 0%, #1a3010 100%);
  padding: 1.25rem;
  overflow-y: auto;
  color: var(--white);
}
.unlock-badge {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  color: var(--white);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-family: var(--display);
  font-size: 0.85rem;
  letter-spacing: 1px;
  margin-bottom: 0.6rem;
}
.gate-back h3 {
  font-family: var(--display);
  color: var(--gold-bright);
  margin-bottom: 0.6rem;
  font-size: 1.1rem;
}
.gate-body { font-size: 0.95rem; line-height: 1.45; }
.gate-body p + p { margin-top: 0.5rem; }
.gate-body strong { color: var(--gold-bright); }

/* ============ MODÁL ============ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.3s ease;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
}

.modal-window {
  position: relative;
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  border: 3px solid var(--gold);
  border-radius: 16px;
  box-shadow: var(--shadow), 0 0 60px rgba(212, 175, 55, 0.2);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  animation: modalIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  width: 3rem;
  height: 3rem;
  font-size: 2.5rem;
  color: var(--gold);
  line-height: 1;
  z-index: 10;
}
.modal-close:hover { color: var(--gold-bright); }

.modal-content h2 {
  font-family: var(--display);
  color: var(--gold-bright);
  text-align: center;
  letter-spacing: 2px;
  margin-bottom: 1rem;
  font-size: 1.6rem;
}
.modal-content p.intro-text {
  text-align: center;
  margin-bottom: 1.5rem;
  font-style: italic;
}

/* ============ BRÁNA 1 – CIFRY ============ */

.gate1-progress {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.gate1-step {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--bg-3);
  border: 2px solid var(--gold-soft);
}
.gate1-step.active { background: var(--gold-bright); }
.gate1-step.done { background: var(--green-bright); border-color: var(--green-bright); }

.gate1-question {
  text-align: center;
  font-size: 1.3rem;
  margin: 1.5rem 0;
  color: var(--white);
  font-family: var(--display);
  letter-spacing: 1px;
}

.gate1-digits {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  margin: 1.5rem 0;
}
.gate1-digit {
  width: 4rem;
  height: 5rem;
  border-radius: 10px;
  background: rgba(0,0,0,0.4);
  border: 2px solid var(--gold-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--gold-bright);
}
.gate1-digit.active {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.25);
  background: rgba(212, 175, 55, 0.1);
}
.gate1-digit.filled { color: var(--white); }

.gate1-keypad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  max-width: 500px;
  margin: 1rem auto;
}
.gate1-key {
  min-height: 60px;
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold-soft) 100%);
  color: var(--bg);
  border-radius: 10px;
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 900;
  border: 2px solid var(--gold-bright);
  box-shadow: 0 4px 0 var(--gold-soft);
}
.gate1-key:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--gold-soft); }

.gate1-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.feedback {
  text-align: center;
  margin-top: 1rem;
  font-family: var(--display);
  letter-spacing: 1px;
  min-height: 1.5rem;
}
.feedback.ok { color: #6cbf3a; }
.feedback.bad { color: #ff6b6b; }

/* ============ BRÁNA 2 – KRÍŽOVKA ============ */

.crossword {
  display: grid;
  grid-template-columns: repeat(11, minmax(28px, 44px));
  gap: 2px;
  justify-content: center;
  margin: 1.5rem auto;
}
.cw-cell {
  aspect-ratio: 1;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(0.9rem, 2.2vw, 1.4rem);
  color: var(--cream);
  text-transform: uppercase;
}
.cw-cell.empty { background: transparent; color: transparent; pointer-events: none; }
.cw-cell.given {
  background: rgba(212, 175, 55, 0.18);
  color: var(--gold-bright);
  border-radius: 4px;
}
.cw-cell.input {
  background: rgba(0,0,0,0.45);
  border: 2px solid var(--gold-soft);
  border-radius: 6px;
  color: var(--white);
}
.cw-cell.input.highlight {
  background: rgba(212, 175, 55, 0.25);
  border-color: var(--gold-bright);
}
.cw-cell.input.correct {
  background: rgba(74, 139, 44, 0.4);
  border-color: var(--green-bright);
  color: var(--white);
}
.cw-cell input {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: inherit;
  color: inherit;
  text-transform: uppercase;
  padding: 0;
}

.crossword-clues {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.5rem;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  font-size: 0.95rem;
}
.crossword-clues div { padding: 0.3rem 0; }
.crossword-clues strong { color: var(--gold-bright); margin-right: 0.4rem; }

/* ============ BRÁNA 3 – PUZZLE ERBU ============ */

.puzzle-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin: 1rem 0;
}

.puzzle-board {
  position: relative;
  width: min(420px, 92vw);
  aspect-ratio: 3 / 4;
  background: rgba(0,0,0,0.4);
  border: 2px dashed var(--gold-soft);
  border-radius: 10px;
  overflow: hidden;
}

.puzzle-tray {
  position: relative;
  width: min(560px, 96vw);
  min-height: 220px;
  background: rgba(0,0,0,0.25);
  border: 2px solid var(--gold-soft);
  border-radius: 10px;
  padding: 0.5rem;
}

.puzzle-piece {
  position: absolute;
  background-image: url('assets/erb.jpg');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  transition: filter 0.15s;
}
.puzzle-piece.dragging {
  cursor: grabbing;
  filter: none;
  z-index: 100;
  will-change: left, top;
}
.puzzle-piece.placed { cursor: default; filter: none; }

.puzzle-status {
  text-align: center;
  font-family: var(--display);
  color: var(--gold);
  letter-spacing: 1px;
}

/* ============ BRÁNA 4 – KOPCE ============ */

.hills-area {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin: 1rem 0;
  align-items: center;
}
.hills-photo {
  position: relative;
  width: min(700px, 96vw);
  aspect-ratio: 960 / 540;
  border-radius: 10px;
  overflow: hidden;
  background-image: url('assets/kopce.jpg');
  background-size: cover;
  background-position: center;
  border: 2px solid var(--gold-soft);
}
.hill-target {
  position: absolute;
  border: 2px dashed rgba(255,255,255,0.6);
  border-radius: 8px;
  background: rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  color: var(--white);
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px #000;
  transition: background 0.2s;
}
.hill-target.hover { background: rgba(212, 175, 55, 0.35); }
.hill-target.filled {
  background: rgba(74, 139, 44, 0.6);
  border-color: var(--green-bright);
  border-style: solid;
}

.hill-tray {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 70px;
}
.hill-label {
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold-soft) 100%);
  color: var(--bg);
  padding: 0.8rem 1.5rem;
  border-radius: 999px;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 1px;
  box-shadow: 0 4px 0 var(--gold-soft);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.hill-label.dragging {
  opacity: 0.5;
  cursor: grabbing;
}
.hill-label.placed { display: none; }

/* ============ OUTRO ============ */

.outro-container {
  max-width: 800px;
  margin: 2rem auto;
  text-align: center;
}
.outro-team {
  font-size: 1.4rem;
  margin: 1rem 0;
  font-family: var(--display);
  letter-spacing: 1px;
}
.outro-team strong { color: var(--gold-bright); }
.outro-time {
  font-size: 1.8rem;
  margin: 0.5rem 0 2rem;
  font-family: var(--display);
}
.outro-time strong {
  color: var(--gold-bright);
  font-size: 2.2rem;
  display: inline-block;
  padding: 0.3rem 1.2rem;
  background: rgba(0,0,0,0.4);
  border: 2px solid var(--gold-soft);
  border-radius: 10px;
  margin-left: 0.5rem;
}

.secret-box {
  background: rgba(0,0,0,0.4);
  border: 2px solid var(--gold);
  border-radius: 16px;
  padding: 1.5rem;
  margin: 2rem 0;
}
.secret-box h2 {
  font-family: var(--display);
  color: var(--gold-bright);
  letter-spacing: 2px;
  margin-bottom: 1rem;
}
.secret-box p {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}
.secret-box strong { color: var(--gold-bright); }
.secret-img {
  width: 100%;
  max-width: 500px;
  margin: 1rem auto 0;
  aspect-ratio: 4 / 3;
  background-size: cover;
  background-position: center;
  border-radius: 10px;
  border: 2px solid var(--gold-soft);
}

.outro-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
  flex-wrap: wrap;
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: linear-gradient(180deg, #4a8b2c 0%, #2d5016 100%);
  color: var(--white);
  padding: 1.5rem 3rem;
  border-radius: 16px;
  border: 3px solid var(--gold-bright);
  font-family: var(--display);
  font-size: 2rem;
  letter-spacing: 2px;
  box-shadow: 0 0 60px rgba(212, 175, 55, 0.6), 0 20px 40px rgba(0,0,0,0.7);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ============ RESPONZIVITA ============ */

/* Tablet landscape & desktop už pokrýva default (4 stĺpce) */

@media (max-width: 1100px) {
  .gates { grid-template-columns: repeat(2, 1fr); gap: 1.2rem; }
  .gate { aspect-ratio: 4 / 5; }
}

@media (max-width: 700px) {
  body { font-size: 16px; }
  main { padding: 1rem 0.8rem 3rem; }
  #timer-bar {
    grid-template-columns: 1fr;
    gap: 0.4rem;
    text-align: center;
    padding: 0.6rem 1rem;
  }
  .timer-progress { justify-content: center; }
  .timer-clock { font-size: 2rem; }

  .title-main { letter-spacing: 2px; }
  .intro-container { margin: 1.5rem auto; }

  .gates { grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
  .gate { aspect-ratio: 3 / 4; }
  .gate-front-overlay h3 { font-size: 0.95rem; }
  .gate-front-overlay p { font-size: 0.8rem; }
  .btn-gate { padding: 0.7rem 1rem; font-size: 0.85rem; min-height: 44px; }

  .modal-window { padding: 1.2rem 0.8rem; }
  .modal-content h2 { font-size: 1.2rem; }

  .gate1-digit { width: 3rem; height: 4rem; font-size: 2rem; }
  .gate1-keypad { gap: 0.4rem; }
  .gate1-key { font-size: 1.2rem; min-height: 50px; }

  .crossword { grid-template-columns: repeat(11, minmax(22px, 32px)); }

  .hill-label { padding: 0.6rem 1rem; font-size: 0.9rem; }
}

@media (max-width: 420px) {
  .gates { grid-template-columns: 1fr; }
  .gate { aspect-ratio: 4 / 3; }
}

/* Tablet portrait optimization */
@media (min-width: 600px) and (max-width: 1100px) and (orientation: portrait) {
  .gates { grid-template-columns: repeat(2, 1fr); }
  .gate { aspect-ratio: 3 / 4; }
}

/* Tablet landscape – udržať 4 stĺpce */
@media (min-width: 900px) and (max-width: 1366px) and (orientation: landscape) {
  .gates { grid-template-columns: repeat(4, 1fr); }
  .gate { aspect-ratio: 3 / 4; }
}
