/* ============================================================
   IZBACISLO13 — PWA Escape Game
   Estetika: Lesnícka, organická, tmavá s mosadzou
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,500;0,700;1,500&family=DM+Sans:wght@300;400;500&display=swap');

/* ---- RESET & ROOT ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #0e1109;
  --bg2: #151c0e;
  --bg3: #1d2716;
  --surface: #1a2212;
  --border: #2d3d1e;
  --gold: #c9a84c;
  --gold-dim: #8a6e2f;
  --green: #5a8a3c;
  --green-dim: #3a5a28;
  --text: #dde8cc;
  --text-dim: #7a9060;
  --text-muted: #4a5a38;
  --error: #c0392b;
  --success: #27ae60;
  --radius: 12px;
  --radius-lg: 20px;
  --font-head: 'Playfair Display', serif;
  --font-body: 'DM Sans', sans-serif;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---- BACKGROUND TEXTURE ---- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(90, 138, 60, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(201, 168, 76, 0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ---- SCREENS ---- */
.screen {
  display: none;
  min-height: 100dvh;
  padding: 0 0 48px;
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ---- GAME HEADER (chapters + end) ---- */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo-mark {
  font-family: var(--font-head);
  font-size: 13px;
  color: var(--gold-dim);
  letter-spacing: 0.08em;
}

.timer-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.timer-icon {
  font-size: 14px;
}

.penalty-badge {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 28px;
  text-align: right;
}

.penalty-badge.has-penalty {
  color: var(--error);
}

/* ---- PROGRESS BAR ---- */
.progress-bar {
  height: 3px;
  background: var(--bg3);
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green) 0%, var(--gold) 100%);
  transition: width 0.6s ease;
}

/* ============================================================
   SCREEN: CODE (enter order code)
   ============================================================ */
#screen-code {
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.code-screen-inner {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.brand-hero {
  text-align: center;
}

.brand-icon {
  font-size: 72px;
  line-height: 1;
  display: block;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 24px rgba(90, 138, 60, 0.4));
}

.brand-name {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 6px;
}

.code-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
  display: block;
}

.code-input-wrap {
  position: relative;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.12em;
  padding: 16px 20px;
  outline: none;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  -webkit-appearance: none;
}

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

input::placeholder {
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.error-msg {
  font-size: 13px;
  color: var(--error);
  min-height: 18px;
  text-align: center;
}

/* ---- BUTTONS ---- */
.btn-primary {
  width: 100%;
  padding: 18px;
  background: var(--gold);
  color: #0e1109;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  -webkit-appearance: none;
}

.btn-primary:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-secondary {
  width: 100%;
  padding: 16px;
  background: transparent;
  color: var(--text-dim);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-secondary:active {
  border-color: var(--gold-dim);
  color: var(--text);
}

.demo-codes {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.8;
}

.demo-codes strong {
  color: var(--gold-dim);
  letter-spacing: 0.1em;
}

/* ============================================================
   SCREEN: WELCOME
   ============================================================ */
.welcome-hero {
  background: var(--bg2);
  padding: 48px 24px 40px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.welcome-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 80% at 50% 0%, rgba(90, 138, 60, 0.12) 0%, transparent 70%);
}

.welcome-emoji {
  font-size: 80px;
  display: block;
  margin-bottom: 20px;
  position: relative;
  filter: drop-shadow(0 4px 24px rgba(90, 138, 60, 0.5));
}

.welcome-title {
  font-family: var(--font-head);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  position: relative;
}

.welcome-subtitle {
  font-size: 12px;
  color: var(--gold-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 6px;
  position: relative;
}

.welcome-body {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  flex: 1;
}

.welcome-desc {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-dim);
}

.section-title {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 12px;
}

.instructions-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.instructions-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
}

.instructions-list li::before {
  content: '▸';
  color: var(--green);
  flex-shrink: 0;
  margin-top: 1px;
}

.info-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-dim);
}

.info-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.welcome-actions {
  padding: 0 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============================================================
   SCREEN: CHAPTER
   ============================================================ */
.chapter-header {
  padding: 28px 24px 24px;
}

.chapter-meta {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.chapter-emoji {
  font-size: 40px;
  display: block;
  margin-bottom: 12px;
}

.chapter-title {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 12px;
}

.chapter-desc {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-dim);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 0 24px;
}

/* Hints section */
.hints-section {
  padding: 24px 24px 16px;
}

.hints-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

#hints-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hint-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  animation: slide-in 0.3s ease;
}

.hint-item.code-revealed {
  border-color: var(--gold-dim);
  background: rgba(201, 168, 76, 0.06);
}

.hint-num {
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
  min-width: 20px;
}

.hint-item span:last-child {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
}

.hint-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--bg3);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-dim);
  transition: border-color 0.2s, color 0.2s;
}

.hint-btn:active {
  border-color: var(--gold-dim);
  color: var(--text);
}

.hint-btn.reveal-btn {
  border-color: rgba(192, 57, 43, 0.3);
}

.hint-btn.reveal-btn:active {
  border-color: var(--error);
}

.hint-cost {
  font-size: 12px;
  color: var(--error);
  font-weight: 500;
}

/* Code input section */
.code-section {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
}

.code-section label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-dim);
}

#code-input {
  font-size: 28px;
  letter-spacing: 0.3em;
  font-weight: 700;
  padding: 20px;
}

/* ============================================================
   SCREEN: END
   ============================================================ */
.end-hero {
  background: var(--bg2);
  padding: 48px 24px 40px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.end-icon {
  font-size: 72px;
  display: block;
  margin-bottom: 16px;
}

.end-title {
  font-family: var(--font-head);
  font-size: 32px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 6px;
}

.end-sub {
  font-size: 14px;
  color: var(--text-dim);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 28px 24px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
}

.stat-value {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  display: block;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
  display: block;
}

.score-box {
  border-color: var(--gold-dim);
}

.score-box .stat-value {
  color: var(--gold);
}

.leaderboard-form {
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.leaderboard-title {
  font-family: var(--font-head);
  font-size: 18px;
  color: var(--text);
}

.leaderboard-desc {
  font-size: 13px;
  color: var(--text-dim);
}

#thank-you-msg {
  display: none;
  font-size: 15px;
  color: var(--green);
  text-align: center;
  padding: 16px;
  background: rgba(90, 138, 60, 0.1);
  border-radius: var(--radius);
  border: 1px solid rgba(90, 138, 60, 0.3);
}

.end-actions {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-8px);
  }

  40% {
    transform: translateX(8px);
  }

  60% {
    transform: translateX(-6px);
  }

  80% {
    transform: translateX(6px);
  }
}

@keyframes success-flash {
  0% {
    border-color: var(--border);
    background: var(--surface);
  }

  40% {
    border-color: var(--success);
    background: rgba(39, 174, 96, 0.12);
  }

  100% {
    border-color: var(--border);
    background: var(--surface);
  }
}

.shake {
  animation: shake 0.5s ease;
}

.success-flash {
  animation: success-flash 0.7s ease;
}

/* Screen fade-in */
.screen.active {
  animation: fade-in 0.3s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ============================================================
   PWA INSTALL BANNERS
   ============================================================ */

.pwa-hidden {
  display: none !important;
}

/* Spoločný základ — Android + iOS-other */
.pwa-banner {
  position: fixed;
  bottom: 16px;
  left: 12px;
  right: 12px;
  background: var(--surface);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  z-index: 200;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.65);
  animation: slide-in 0.35s ease;

  display: flex;
  align-items: center;
  gap: 12px;
}

/* iOS Safari variant — vertikálny layout */
.pwa-banner--ios {
  flex-direction: column;
  padding: 20px 16px 14px;
  gap: 0;
}

.pwa-banner-icon {
  font-size: 26px;
  flex-shrink: 0;
  line-height: 1;
}

.pwa-banner-text {
  flex: 1;
}

.pwa-banner-text strong {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}

.pwa-banner-text span {
  font-size: 12px;
  color: var(--text-muted);
}

/* Tlačidlo Inštalovať */
.pwa-btn-install {
  background: var(--gold);
  color: #0e1109;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.pwa-btn-install:active {
  opacity: 0.85;
}

/* Zavrieť × */
.pwa-btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
}

/* Absolútne umiestnenie × pre iOS banner */
.pwa-btn-close--abs {
  position: absolute;
  top: 10px;
  right: 12px;
}

/* iOS Safari — vnútro */
.pwa-ios-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  width: 100%;
}

.pwa-ios-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.pwa-ios-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  text-align: left;
  counter-reset: steps;
  margin-top: 4px;
}

.pwa-ios-steps li {
  counter-increment: steps;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
}

.pwa-ios-steps li::before {
  content: counter(steps);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green-dim);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Ikona zdieľania */
.pwa-share-glyph {
  font-size: 14px;
  vertical-align: middle;
  color: var(--text);
}

/* Pulzujúca šípka dole — ukazuje na Safari toolbar */
.pwa-ios-arrow {
  text-align: center;
  color: var(--gold-dim);
  font-size: 16px;
  margin-top: 10px;
  animation: pwa-bounce 1.6s ease infinite;
}

@keyframes pwa-bounce {

  0%,
  100% {
    transform: translateY(0);
    opacity: 0.7;
  }

  50% {
    transform: translateY(5px);
    opacity: 1;
  }
}

/* Safe area — notched phones (iPhone X+) */
@supports (padding: max(0px)) {
  .pwa-banner {
    bottom: max(16px, calc(env(safe-area-inset-bottom) + 10px));
  }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden {
  display: none !important;
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
  .game-header {
    padding-top: max(16px, env(safe-area-inset-top));
  }

  #screen-code {
    padding-top: max(32px, env(safe-area-inset-top));
  }
}

/* ============================================================
   HELP DIALOG
   ============================================================ */

.game-header--welcome {
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.help-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg3);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

.help-btn:active {
  border-color: var(--gold-dim);
  color: var(--text);
}

.help-hidden {
  display: none !important;
}

.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  padding: 16px;
  animation: fade-in 0.2s ease;
}

.help-dialog {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: slide-in 0.25s ease;
}

.help-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.help-dialog-title {
  font-family: var(--font-head);
  font-size: 18px;
  color: var(--text);
}

.help-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}

.help-dialog-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.help-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.help-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.help-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

.help-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.help-support-title {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.help-phone {
  display: block;
  text-align: center;
  padding: 14px;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--gold);
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.2s;
}

.help-phone:active {
  border-color: var(--gold-dim);
}

@supports (padding: max(0px)) {
  .help-overlay {
    padding-bottom: max(16px, calc(env(safe-area-inset-bottom) + 12px));
  }
}