/* =========================================================
   YAY — styles.css (Consolidated & Refactored)
   ========================================================= */

:root {
  --bg: #f8f6f2;
  --panel: #ffffff;
  --panel-elevated: #faf7f2;
  --panel-muted: #f0ede8;
  --text: #1a1918;
  --text-muted: #6b665e;

  --accent: #d9b894;
  --accent-light: #e7c9a9;
  --accent-dark: #b5906b;

  --success: #2d8a5a;
  --error: #c74a4a;

  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.12);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 10px 30px rgba(53, 44, 36, 0.08);
  --shadow-lg: 0 20px 50px rgba(53, 44, 36, 0.12);

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --header-height: 72px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Base --- */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  background-image: radial-gradient(circle at top right, var(--panel), transparent),
    radial-gradient(circle at bottom left, var(--panel-muted), transparent);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent-dark);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--text);
}

/* --- Layout --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.start-panel {
  max-width: 600px;
  margin: 2rem auto;
  text-align: center;
  padding: 3rem 2rem;
}

.start-panel h1 {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  color: var(--accent-dark);
  line-height: 1;
  font-weight: 900;
}

.start-panel p {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.start-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
}

.form-group {
  width: 100%;
  max-width: 320px;
  text-align: left;
}

.form-group label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.form-group input {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: var(--transition);
  background: var(--bg);
  font-weight: 600;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-dark);
  box-shadow: 0 0 0 4px rgba(181, 144, 107, 0.1);
}

.hidden {
  display: none !important;
}

/* --- Header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text);
}

.site-nav {
  display: flex;
  gap: 1rem;
}

.site-nav__link {
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
}

.site-nav__link:hover {
  color: var(--text);
  background: var(--panel-muted);
}

/* --- Components --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn--secondary {
  background: var(--panel-muted);
  color: var(--text);
}

.btn--primary {
  background: var(--accent-dark);
}

.btn--large {
  padding: 1rem 2rem;
  font-size: 1.1rem;
  border-radius: 999px;
}

.btn--sm {
  padding: 6px 12px;
  font-size: 0.875rem;
}

.sound-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

.sound-toggle .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.sound-toggle.muted .dot {
  background: var(--error);
}

/* --- HUD --- */
.hud {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.hud-item {
  background: var(--panel);
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.hud-item__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  display: block;
}

.hud-item__value {
  font-size: 1.25rem;
  font-weight: 700;
}

/* --- Game Board --- */
.timeline {
  display: flex;
  padding: 6rem 1rem;
  overflow-x: auto;
  min-height: 420px;
  align-items: center;
  background: var(--panel-muted);
  border-radius: var(--radius-md);
  position: relative;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.timeline::-webkit-scrollbar {
  display: none;
}

.timeline .axis {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-light);
  z-index: 1;
  pointer-events: none;
}

.timeline-item {
  display: flex;
  align-items: center;
  position: relative;
  z-index: 2;
  transition: transform 0.3s var(--transition);
}

.pos-top {
  transform: translateY(-40px);
}

.pos-bottom {
  transform: translateY(40px);
}

.gap {
  flex: 0 0 30px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 5;
  transition: var(--transition);
  margin: 0 2px;
}

.gap.active {
  background: rgba(217, 184, 148, 0.2);
  border-radius: var(--radius-sm);
}

.gap-line {
  width: 2px;
  height: 40px;
  background: var(--accent);
  opacity: 0;
}

.gap.active .gap-line {
  opacity: 1;
}

.hand {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  background: var(--panel-elevated);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--accent-light);
  min-height: 200px;
  flex-wrap: wrap;
  margin-top: 2rem;
}

/* --- Card --- */
.card {
  width: 180px;
  background: var(--panel);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform 0.2s var(--transition), box-shadow 0.2s var(--transition);
  cursor: grab;
  user-select: none;
}

.card img {
  width: 100%;
  height: auto;
  display: block;
}

.card__content {
  padding: 0.75rem;
  text-align: center;
}

.card__title {
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.card__date {
  font-size: 1.1rem;
  color: #fff;
  background: var(--accent-dark);
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 900;
  display: inline-block;
  margin-top: 0.25rem;
  letter-spacing: 0.5px;
  box-shadow: var(--shadow-sm);
}

.card.dragging {
  opacity: 0.9;
  transform: scale(1.05);
  cursor: grabbing;
  z-index: 1000;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}

.card.ghost {
  opacity: 0.2;
  border: 2px dashed var(--accent-dark);
  background: rgba(217, 184, 148, 0.1);
  border-radius: var(--radius-sm);
}

.hand-card {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), margin 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
  margin: 0 5px;
}

.hand-card:hover,
.hand-card:active {
  transform: translateY(-15px) rotate(-2deg);
  z-index: 200 !important;
  cursor: grab;
  box-shadow: var(--shadow-lg);
}

.hand:hover .hand-card:not(:hover):not(:active) {
  transform: translateY(5px);
  filter: brightness(0.9);
}

/* Globální hack proti pull-to-refresh na mobilu a usnadnění táhnutí */
body {
  touch-action: pan-x pan-y;
  overscroll-behavior-y: none;
}

/* --- Modals --- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1.5rem;
  overflow-y: auto;
}

.modal--open {
  display: flex !important;
}

.modal__panel {
  background: var(--panel);
  max-width: 800px;
  width: 100%;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  position: relative;
  animation: modal-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin: auto;
  /* Pomáhá při overflow na mobilu */
}

/* Insight Modal Specifics */
.modal__panel--insight {
  max-width: 720px;
}

.modal__banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: var(--border);
  z-index: 2;
}

.modal__close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 10;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-dark);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  font-size: 1.25rem;
  font-weight: 700;
}

.modal__close:hover {
  background: var(--text);
  transform: rotate(90deg);
}

.modal__content {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.modal__status {
  font-size: 1.25rem;
  font-weight: 800;
  text-align: center;
  margin-top: 2rem;
  padding: 1rem 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.modal__grid {
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: 2.5rem;
  padding: 1.5rem 2.5rem 3rem;
}

.modal__media {
  position: relative;
}

.modal__img {
  width: 100%;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  display: block;
}

.modal__date {
  position: absolute;
  bottom: -1rem;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  background: var(--accent-dark);
  color: #fff;
  padding: 8px 20px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 1.25rem;
  z-index: 10;
  border: 3px solid var(--panel);
  box-shadow: var(--shadow-sm);
}

.modal__info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.modal__title {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0 0 1rem;
  color: var(--text);
  line-height: 1.2;
}

.modal__subtitle {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
  display: none;
}

/* Hidden as per app.js */
.modal__description {
  margin: 0 0 2rem;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  opacity: 0.9;
}

.modal__cta {
  align-self: flex-start;
}

/* End Modal Specifics */
.modal__panel--end {
  max-width: 500px;
}

.modal__score {
  font-size: 1.5rem;
  margin: 1.5rem 0;
  color: var(--text);
}

.modal__actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.modal__share {
  margin-top: 1.5rem;
}

.modal__share-input {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-muted);
  font-family: monospace;
  font-size: 0.9rem;
}

@keyframes modal-enter {
  from {
    transform: scale(0.95) translateY(30px);
    opacity: 0;
  }

  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.75rem 1.5rem;
  background: var(--panel);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 3000;
  transition: transform 0.3s var(--transition);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.good {
  border-left: 4px solid var(--success);
}

.toast.bad { border-left: 4px solid var(--error); }

/* --- Social Shares --- */
.social-shares { display: flex; gap: 0.75rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.social-btn {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1rem;
  border-radius: var(--radius-sm); color: #fff; font-weight: 700; font-size: 0.85rem;
  transition: var(--transition); text-decoration: none;
}
.social-btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.social-btn--fb { background: #1877F2; }
.social-btn--x { background: #000; }
.social-btn--wa { background: #25D366; }

/* --- Leaderboard --- */
.lb-filters {
  display: flex;
  gap: 0.5rem;
  background: var(--panel-muted);
  padding: 0.5rem;
  border-radius: 999px;
  margin-bottom: 2rem;
  width: max-content;
  margin-left: auto;
  margin-right: auto;
}

.lb-btn {
  border: none;
  background: transparent;
  padding: 0.6rem 1.5rem;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  font-size: 0.9rem;
}

.lb-btn.active {
  background: var(--panel);
  color: var(--accent-dark);
  box-shadow: var(--shadow-sm);
}

.lb-btn:hover:not(.active) {
  color: var(--text);
}

.lb-container { width: 100%; overflow-x: hidden; }

.lb-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.75rem;
  margin-top: -0.75rem;
}

.lb-table th {
  text-align: left;
  padding: 0.5rem 1.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 800;
  letter-spacing: 1px;
}

.lb-table td {
  padding: 1.25rem;
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

.lb-table td:first-child {
  border-left: 1px solid var(--border);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  width: 70px;
  text-align: center;
}

.lb-table td:last-child {
  border-right: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.lb-table th:nth-child(3), .lb-table td:nth-child(3) { text-align: center; width: 100px; }
.lb-table th:nth-child(4), .lb-table td:nth-child(4) { text-align: right; width: 200px; }
.lb-table th:first-child { text-align: center; }
.lb-table th:last-child { text-align: right; }

.lb-row {
  transition: var(--transition);
}

.lb-row:hover td {
  background: var(--panel-elevated) !important;
  cursor: default;
}

.lb-row:hover td:first-child {
  border-left-color: var(--accent-dark);
}

.lb-rank {
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--text-muted);
}

.lb-player {
  font-weight: 700;
  color: var(--text);
}

.lb-score {
  display: inline-block;
  padding: 4px 12px;
  background: var(--panel-muted);
  border-radius: 999px;
  font-weight: 800;
  color: var(--text);
}

.lb-date {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Rank Specifics */
.lb-row--1 td {
  border-color: rgba(212, 175, 55, 0.2);
  background: linear-gradient(to right, rgba(212, 175, 55, 0.05), var(--panel));
}

.lb-row--1 .lb-rank {
  color: #d4af37;
}

.lb-row--1 .lb-score {
  background: #d4af37;
  color: #fff;
}

.lb-row--2 td {
  border-color: rgba(192, 192, 192, 0.2);
  background: linear-gradient(to right, rgba(192, 192, 192, 0.05), var(--panel));
}

.lb-row--2 .lb-rank {
  color: #aaa;
}

.lb-row--2 .lb-score {
  background: #aaa;
  color: #fff;
}

.lb-row--3 td {
  border-color: rgba(205, 127, 50, 0.2);
  background: linear-gradient(to right, rgba(205, 127, 50, 0.05), var(--panel));
}

.lb-row--3 .lb-rank {
  color: #cd7f32;
}

.lb-row--3 .lb-score {
  background: #cd7f32;
  color: #fff;
}

.medal {
  font-size: 1.25rem;
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* --- Responsiveness --- */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  .site-header__inner {
    padding: 0.75rem 1rem;
  }

  .brand {
    font-size: 1.1rem;
  }

  .start-panel {
    padding: 2rem 1.5rem;
    margin-top: 1rem;
  }

  .start-panel h1 {
    font-size: 2.5rem;
  }

  .hud {
    flex-direction: row;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }

  .hud-item {
    padding: 0.5rem 1rem;
  }

  .timeline {
    padding: 4rem 1rem;
    min-height: 320px;
    border-radius: var(--radius-sm);
  }

  .card {
    width: 115px;
  }

  .card__title {
    font-size: 0.7rem;
  }

  .card__date {
    font-size: 0.9rem;
    padding: 3px 8px;
  }

  .pos-top {
    transform: translateY(-35px);
  }

  .pos-bottom {
    transform: translateY(35px);
  }

  .gap {
    flex: 0 0 40px;
    margin: 0 2px;
  }

  .hand {
    gap: 0.75rem;
    padding: 1.5rem 0.5rem;
    margin-top: 1.5rem;
  }

  .hand-card {
    margin: 0 2px;
  }

  .hand-card:hover,
  .hand-card:active {
    transform: translateY(-10px);
  }

  /* Modal Mobile Fixes */
  .modal {
    padding: 1.5rem;
    align-items: center;
  }

  /* Center it to show backdrop */
  .modal__panel {
    border-radius: var(--radius-lg);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    width: 95%;
    max-width: 420px;
  }

  .modal__close {
    top: 0.75rem;
    right: 0.75rem;
    width: 36px;
    height: 36px;
  }

  .modal__content {
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
  }

  .modal__grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding: 1.25rem;
  }

  .modal__status {
    margin-top: 1.5rem;
    font-size: 1.1rem;
  }

  .modal__media {
    max-width: 240px;
    margin: 0 auto;
  }

  .modal__date {
    font-size: 1.1rem;
    padding: 6px 16px;
    border-width: 2px;
  }

  .modal__info {
    text-align: center;
  }

  .modal__title {
    font-size: 1.4rem;
    margin-bottom: 0.75rem;
  }

  .modal__description {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
  }

  .modal__cta {
    align-self: center;
    width: 100%;
  }

  .modal__panel--end {
    padding: 0;
  }

  .modal__panel--end .modal__content {
    padding: 2rem !important;
  }

  .modal__score {
    font-size: 1.25rem;
  }

  .modal__actions {
    flex-direction: column;
    width: 100%;
  }

  .modal__actions .btn {
    width: 100%;
  }

  /* LB Table Mobile */
  .lb-container { overflow-x: auto; }
  .lb-table { table-layout: auto; }
  .lb-table th:nth-child(4), .lb-table td:nth-child(4) { display: none; }
  .lb-table td { padding: 0.75rem; }
  .lb-table td:first-child { width: 40px; }
  .lb-rank { font-size: 0.9rem; }
  .lb-player { font-size: 0.95rem; }
  .lb-score { padding: 3px 8px; font-size: 0.9rem; }
}

@media (max-width: 480px) {
  .card {
    width: 100px;
  }

  .timeline {
    min-height: 260px;
  }

  .pos-top {
    transform: translateY(-30px);
  }

  .pos-bottom {
    transform: translateY(30px);
  }
}