@import url("https://fonts.googleapis.com/css2?family=Newsreader:wght@400;500;600&family=Sora:wght@400;500;600&display=swap");

:root {
  --bg: #f6f3ee;
  --bg-2: #efe9e3;
  --card: #fbfaf8;
  --ink: #2b2b2a;
  --muted: #6c6a66;
  --accent: #58695f;
  --accent-soft: #e1e7e3;
  --accent-2: #c6b8a5;
  --line: #e6dfd7;
  --shadow: 0 20px 50px rgba(42, 36, 30, 0.08);
  --shadow-soft: 0 12px 30px rgba(42, 36, 30, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Sora", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 520px at 12% -10%, #e6e0d8 0%, transparent 62%),
    radial-gradient(780px 380px at 88% 6%, #ebe4db 0%, transparent 58%),
    var(--bg);
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 36px 26px 64px;
  animation: fadeUp 0.8s ease;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(145deg, #efe7dd, #d8d0c3);
  box-shadow: var(--shadow-soft);
  padding: 6px;
  object-fit: contain;
}

h1 {
  font-family: "Newsreader", serif;
  font-size: 26px;
  margin: 0 0 4px;
}

p {
  margin: 0;
  color: var(--muted);
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 8px;
  min-width: 240px;
}

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

.result-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
  color: var(--muted);
}

.result-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.result-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.result-chip {
  min-width: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #3f4b44;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.result-empty {
  font-size: 12px;
  color: var(--muted);
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 22px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow-soft);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head h3 {
  margin: 0;
  font-family: "Newsreader", serif;
  font-size: 18px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 999px;
  padding: 3px;
  gap: 4px;
}

.segmented-btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.segmented-btn.is-active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(60, 55, 45, 0.12);
}

.card.hero {
  padding: 20px;
  border-radius: 20px;
  background: linear-gradient(145deg, #ffffff, #f6f1ea);
  border: 1px solid var(--line);
}

.hero-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
  color: var(--muted);
}

.value {
  font-size: 16px;
  margin-top: 6px;
}

.numbers {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin: 18px 0 20px;
}

.numbers.count-7 {
  grid-template-columns: repeat(7, 1fr);
}

.numbers.count-6 {
  grid-template-columns: repeat(6, 1fr);
}

.numbers.count-8 {
  grid-template-columns: repeat(8, 1fr);
}

.chip {
  display: grid;
  place-items: center;
  background: #f7f3ee;
  border: 1px solid var(--line);
  border-radius: 14px;
  height: 46px;
  font-weight: 600;
  font-family: "Sora", sans-serif;
}

.chip-mas {
  background: #f8f5f1;
  border-color: var(--line);
  color: #6b6b63;
  border-style: dashed;
}

.chip-super {
  background: #f8f5f1;
  border-color: var(--line);
  color: #6b6b63;
  border-style: dashed;
}

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

.btn {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 11px 20px;
  border-radius: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 20px rgba(91, 102, 90, 0.2);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.subtle {
  background: #e9e3da;
  color: var(--ink);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.action-group {
  display: flex;
  gap: 8px;
}

.action-group.is-hidden {
  display: none;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: none;
  background: var(--accent-soft);
  font-weight: 600;
  cursor: pointer;
}

.icon-btn.ghost {
  background: #f1e6e2;
}

.hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}

.history {
  display: grid;
  gap: 10px;
}


.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}


.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  animation: fadeUp 0.4s ease;
}


.history-info {
  display: grid;
  gap: 6px;
}

.history-title {
  font-weight: 600;
}

.history-meta {
  font-size: 12px;
  color: var(--muted);
}

.history-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  background: #f3f0eb;
  color: #3b3b3b;
}

.history-chip.hit {
  background: #e7f1e7;
  border-color: #c7d8c7;
  color: #2f4a34;
}

.history-chip.miss {
  background: #f4e9e6;
  border-color: #e1c9c2;
  color: #5a3b35;
}

.history-chip.pending {
  background: #f1efe9;
  border-color: #e2ddd3;
  color: #6b6b63;
}

.history-chip.mas {
  border-style: dashed;
}

.history-chip.extra {
  background: #f1efe9;
  border-color: #e2ddd3;
  color: #6b6b63;
}

.history-chip.super {
  border-style: dashed;
}

.history-date {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.delete-btn {
  border: none;
  background: #f1e6e2;
  color: #6b4a3e;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 30px 0;
  font-size: 13px;
}

.inline-loader {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.inline-loader.is-active {
  opacity: 1;
  transform: translateY(0);
}

.inline-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
}

.inline-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.3;
  animation: dotPulse 1s ease-in-out infinite;
}

.inline-dots .dot:nth-child(2) {
  animation-delay: 0.15s;
}

.inline-dots .dot:nth-child(3) {
  animation-delay: 0.3s;
}

.inline-text {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

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

@keyframes dotPulse {

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

  50% {
    transform: translateY(-4px);
    opacity: 0.9;
  }
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
  }

  .result-card {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .numbers {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* --- Mobile / PWA Enhancements --- */

/* Safe area (notch support) */
.page {
  padding-top: max(36px, env(safe-area-inset-top));
  padding-bottom: max(64px, env(safe-area-inset-bottom));
  padding-left: max(26px, env(safe-area-inset-left));
  padding-right: max(26px, env(safe-area-inset-right));
}

/* Better touch targets & removal of tap highlight */
button,
.segmented-btn,
.chip,
.history-chip {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* App-like feel: disable text selection on UI elements */
.panel-head h3,
.brand h1,
.brand p,
.result-label,
.result-date,
.label,
.value,
.hint,
.chip,
.history-title,
.history-meta,
.history-date {
  user-select: none;
  -webkit-user-select: none;
}

/* Active state physical feedback */
.btn:active,
.segmented-btn:active,
.chip:active {
  transform: scale(0.96);
}

/* Small screens tweaks */
@media (max-width: 480px) {
  .page {
    padding: 24px 16px 80px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  h1 {
    font-size: 22px;
  }

  .topbar {
    gap: 12px;
  }

  .chip {
    height: 44px;
    font-size: 14px;
  }

  .history-item {
    padding: 12px;
    gap: 12px;
  }

  .result-card {
    min-width: 100%;
  }
}

/* --- PWA Install Prompt --- */
.pwa-prompt {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.pwa-prompt.pwa-show {
  opacity: 1;
}

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

.pwa-modal {
  position: relative;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 32px 24px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  border: 1px solid var(--line);
  border-bottom: none;
}

.pwa-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 20px;
  background: linear-gradient(145deg, #efe7dd, #d8d0c3);
  padding: 12px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwa-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.pwa-title {
  font-family: "Newsreader", serif;
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 12px;
  text-align: center;
  color: var(--ink);
}

.pwa-description {
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
  margin: 0 0 28px;
}

.pwa-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pwa-btn {
  border: none;
  padding: 14px 24px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: "Sora", sans-serif;
}

.pwa-btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(88, 105, 95, 0.3);
}

.pwa-btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 5px 15px rgba(88, 105, 95, 0.3);
}

.pwa-btn-secondary {
  background: var(--bg-2);
  color: var(--muted);
  box-shadow: none;
}

.pwa-btn-secondary:active {
  transform: scale(0.98);
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

/* PWA prompt on larger screens (centered modal) */
@media (min-width: 640px) {
  .pwa-prompt {
    align-items: center;
    justify-content: center;
  }

  .pwa-modal {
    border-radius: 24px;
    border: 1px solid var(--line);
    max-width: 420px;
    animation: fadeIn 0.3s ease;
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: scale(0.95);
    }

    to {
      opacity: 1;
      transform: scale(1);
    }
  }
}