:root {
  --bg: #f4f1e8;
  --card-bg: #ffffff;
  --ink: #2b2620;
  --muted: #7a7266;
  --accent: #b5432a;
  --accent-dark: #8f341f;
  --line: #e2dccc;
  --green: #3f7a4e;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: 2rem;
}

.hidden { display: none !important; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  background: var(--accent);
  color: #fff;
}

header h1 {
  font-size: 1.15rem;
  margin: 0;
}

.link-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.6);
  color: #fff;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-size: 0.85rem;
}

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 1rem;
}

#landing-view {
  text-align: center;
  padding: 3rem 1rem;
}

.intro {
  color: var(--muted);
  margin-bottom: 2rem;
  font-size: 1.05rem;
}

.primary-btn, .secondary-btn {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 0 auto 0.75rem;
  padding: 0.9rem 1rem;
  font-size: 1.05rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.secondary-btn {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.ad-slot {
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 1rem;
}

#landing-view .ad-slot {
  margin-top: 2rem;
  margin-bottom: 0;
}

.total-bar {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--ink);
  color: #fff;
  padding: 0.8rem 1rem;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  z-index: 5;
}

#complete-banner {
  background: #eaf3ec;
  border: 1px solid var(--green);
  color: var(--green);
  padding: 1rem;
  border-radius: 10px;
  text-align: center;
  margin-bottom: 1rem;
}

#complete-banner .primary-btn {
  margin-top: 0.75rem;
}

h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 1.5rem 0 0.5rem;
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tile {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tile:active {
  background: #faf8f2;
}

.tile-static {
  cursor: default;
}

.tile-static:active {
  background: var(--card-bg);
}

.tile-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tile-label {
  font-weight: 600;
}

.tile-desc {
  color: var(--muted);
  font-size: 0.85rem;
}

.tile-score {
  flex: none;
  font-size: 1.9rem;
  font-weight: 700;
  min-width: 2.2rem;
  text-align: right;
  color: var(--accent-dark);
}

.tile-score.empty {
  color: var(--line);
  font-weight: 400;
}

/* ---------- modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 38, 32, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
  padding: 0;
}

@media (min-width: 480px) {
  .modal-overlay {
    align-items: center;
    padding: 1rem;
  }
}

.modal {
  background: var(--card-bg);
  width: 100%;
  max-width: 420px;
  border-radius: 16px 16px 0 0;
  padding: 1.25rem 1.25rem 1.5rem;
}

@media (min-width: 480px) {
  .modal {
    border-radius: 16px;
  }
}

.modal-header {
  margin-bottom: 1rem;
}

.modal-header h3 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

.modal-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.score-input {
  width: 100%;
  padding: 0.9rem;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 1rem;
}

.save-btn, .accept-btn {
  flex: 1 1 auto;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

.zero-btn {
  flex: 1 1 auto;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

.clear-btn, .cancel-btn {
  flex: 1 1 auto;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

.subtotal-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0.2rem;
  color: var(--muted);
}

.subtotal-row.total {
  color: var(--ink);
  font-weight: 700;
  border-top: 1px solid var(--line);
  margin-top: 0.25rem;
  padding-top: 0.6rem;
}

.bonus-counter {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bonus-btn {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

#bonus-count {
  font-size: 1.2rem;
  font-weight: 700;
  min-width: 1.5rem;
  text-align: center;
}
