:root {
  --bg: #F7F6F2;
  --card: #FFFFFF;
  --border: #E1DFD6;
  --text-primary: #1E1E1C;
  --text-secondary: #5F5E5A;
  --text-muted: #888780;
  --accent: #0F6E56;
  --accent-bg: #E1F5EE;
  --accent-text: #085041;
  --danger: #A32D2D;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 1.75rem 1.25rem 0.75rem;
}

header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}

main {
  flex: 1;
  padding: 0.5rem 1.25rem 1rem;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 1.25rem;
}

label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: -6px;
}

input {
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 0 12px;
  font-size: 16px;
  color: var(--text-primary);
  width: 100%;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

button {
  height: 46px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

button:active { transform: scale(0.98); }

button.ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  height: 34px;
  font-size: 13px;
  font-weight: 500;
  padding: 0 12px;
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin: -4px 0 0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 13px;
  color: var(--text-secondary);
}

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

.ad-slot {
  margin-top: 1.25rem;
  min-height: 50px;
}

.leaderboard {
  background: var(--accent-bg);
  color: var(--accent-text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 0.75rem;
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 0.75rem;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filters-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.75rem;
}

.search-input {
  margin-bottom: 0.75rem;
}

.fav-toggle {
  flex: 0 0 auto;
}

.fav-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-chip {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.card-store {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent-bg);
  border-radius: 6px;
  padding: 1px 6px;
  margin-right: 6px;
}

.fav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  height: auto;
  padding: 0 6px 0 0;
  line-height: 1;
}

.fav-btn.active {
  color: #C9A227;
}

.sparkline {
  display: block;
  width: 100%;
  height: 32px;
  margin: 8px 0 2px;
}

.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.action-btn {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
}

.action-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent-text);
}

.kommentit-panel, .hinta-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.kommentti-item {
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.kommentti-item:last-child {
  border-bottom: none;
}

.kommentti-pvm {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.kommentti-form, .hinta-form {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.kommentti-form input, .hinta-form input {
  flex: 1;
  height: 36px;
  font-size: 14px;
}

.kommentti-form button, .hinta-form button {
  height: 36px;
  font-size: 13px;
  padding: 0 12px;
  white-space: nowrap;
}

.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 2rem 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  position: relative;
}

.card.best {
  border: 2px solid var(--accent);
}

.badge {
  position: absolute;
  top: -10px;
  left: 12px;
  background: var(--accent-bg);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 8px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.card-name {
  font-weight: 600;
  font-size: 15px;
}

.remove-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.card-details {
  font-size: 12px;
  color: var(--text-secondary);
}

.card-score {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.bar-track {
  height: 6px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}

footer {
  padding: 0.5rem 1.25rem 1.5rem;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

footer p {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.link-btn {
  display: block;
  margin: 0.5rem auto 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  text-decoration: underline;
  height: auto;
  font-weight: 400;
  padding: 4px;
}

.admin-form {
  max-width: 280px;
  margin: 0.5rem auto 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-form input {
  height: 38px;
}

.admin-form button[type="submit"] {
  height: 38px;
  font-size: 14px;
}
