@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

/* ============ Design tokens ============ */
:root {
  --fairway-900: #0B3D2E;
  --fairway-800: #0F4D39;
  --fairway-700: #155C3F;
  --fairway-600: #1B7048;
  --fairway-500: #2C8C5E;
  --rough-100: #EAF2E7;
  --sand-400: #D8B96A;
  --sand-500: #C9A227;
  --cream-50: #F6F2E7;
  --cream-100: #EFE9D8;
  --ink-900: #16241D;
  --ink-700: #3A493F;
  --ink-500: #66766B;
  --flag-600: #B84332;
  --flag-700: #9B3527;
  --line: #D9D0B8;
  --line-dark: rgba(246, 242, 231, 0.18);
  --shadow: 0 10px 24px -12px rgba(11, 61, 46, 0.35);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--fairway-900);
  color: var(--ink-900);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ============ Phone shell ============ */
.phone-shell {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(140% 60% at 50% 0%, rgba(44,140,94,0.35) 0%, rgba(11,61,46,0) 60%),
    var(--fairway-900);
  position: relative;
}

/* subtle mown-fairway stripes in the header zone */
.phone-shell::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 210px;
  background: repeating-linear-gradient(
    100deg,
    rgba(255,255,255,0.035) 0px,
    rgba(255,255,255,0.035) 26px,
    rgba(0,0,0,0.03) 26px,
    rgba(0,0,0,0.03) 52px
  );
  pointer-events: none;
}

/* ============ Header ============ */
.app-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: max(22px, env(safe-area-inset-top)) 20px 18px;
  color: var(--cream-50);
}

.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sand-400);
  margin-bottom: 4px;
}

.app-header h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 30px;
  line-height: 1;
  margin: 0;
  letter-spacing: -0.01em;
}

.hcp-chip {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  color: var(--fairway-900);
  background: var(--sand-400);
  border-radius: 999px;
  padding: 8px 14px;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

/* ============ Content area ============ */
.content {
  position: relative;
  z-index: 1;
  flex: 1;
  background: var(--cream-50);
  border-radius: 26px 26px 0 0;
  padding: 22px 16px 28px;
  box-shadow: 0 -1px 0 rgba(0,0,0,0.05);
}

.screen { display: none; }
.screen.active { display: block; animation: rise 260ms ease; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ Hero / mini stats (home) ============ */
.hero-card {
  background: linear-gradient(160deg, var(--fairway-800), var(--fairway-600));
  color: var(--cream-50);
  border-radius: var(--radius-lg);
  padding: 20px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: "";
  position: absolute;
  right: -30px;
  bottom: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 1px dashed rgba(246,242,231,0.25);
}

.hero-card span {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sand-400);
}

.hero-card strong {
  font-family: var(--font-display);
  font-size: 46px;
  font-weight: 600;
  line-height: 1.15;
}

.hero-card small {
  color: rgba(246,242,231,0.75);
  font-size: 12.5px;
}

.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.mini-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini-card span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-500);
}

.mini-card strong {
  font-family: var(--font-display);
  font-size: 21px;
  color: var(--fairway-800);
}

/* ============ Cards ============ */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  margin-top: 14px;
}

.card h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--fairway-800);
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--flag-600);
  flex: none;
}

.muted {
  color: var(--ink-500);
  font-size: 13px;
  margin: 0 0 12px;
  line-height: 1.45;
}

/* ============ Form elements ============ */
label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-700);
  margin-top: 12px;
  margin-bottom: 6px;
}

label:first-of-type { margin-top: 8px; }

input, select, textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--cream-50);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  color: var(--ink-900);
  font-weight: 500;
  transition: border-color 120ms ease, background 120ms ease;
}

textarea { resize: vertical; font-family: var(--font-mono); font-size: 14px; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--fairway-600);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(44,140,94,0.18);
}

.three {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.three label { margin-top: 0; }

/* ============ Buttons ============ */
button {
  appearance: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  width: 100%;
  margin-top: 10px;
  transition: transform 80ms ease, opacity 120ms ease, background 120ms ease;
  background: var(--rough-100);
  color: var(--fairway-800);
}

button:first-of-type { margin-top: 12px; }

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

button:focus-visible {
  outline: 2px solid var(--fairway-600);
  outline-offset: 2px;
}

button.primary {
  background: var(--fairway-700);
  color: var(--cream-50);
  box-shadow: 0 8px 16px -8px rgba(21,92,63,0.6);
}

button.primary:active { background: var(--fairway-800); }

button.danger {
  background: #fff;
  color: var(--flag-700);
  border: 1.5px solid rgba(184,67,50,0.35);
}

.btn-stack {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.btn-stack button { margin-top: 10px; }
.btn-stack .primary { grid-column: 1 / -1; }

/* ============ Upload box ============ */
.upload-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--cream-50);
  margin-top: 8px;
  font-weight: 600;
  color: var(--ink-700);
  cursor: pointer;
  font-size: 13.5px;
}

.upload-box input[type="file"] {
  width: auto;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 12px;
  max-width: 55%;
}

.notice {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-500);
  background: var(--cream-100);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  line-height: 1.4;
}

.notice.ok { color: var(--fairway-800); background: var(--rough-100); }
.notice.error { color: var(--flag-700); background: #FBEAE6; }

/* ============ Results ============ */
.result {
  margin-top: 12px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--line);
  background: var(--cream-50);
  padding: 13px 14px;
  font-size: 13.5px;
  color: var(--ink-700);
  line-height: 1.55;
}

.result .big {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--fairway-800);
  display: block;
  margin-bottom: 2px;
}

.result .row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 3px 0;
  border-bottom: 1px dotted var(--line);
}
.result .row:last-child { border-bottom: none; }
.result .row b { color: var(--fairway-800); }

/* ============ Scorecard-style table ============ */
.tablewrap { margin-top: 12px; overflow-x: auto; }

table.scorecard {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
  min-width: 100%;
}

table.scorecard th {
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-500);
  border-bottom: 1.5px solid var(--fairway-700);
  padding: 6px 8px;
  white-space: nowrap;
}

table.scorecard td {
  padding: 7px 8px;
  border-bottom: 1px dotted var(--line);
  white-space: nowrap;
}

table.scorecard tr.best td {
  background: var(--rough-100);
  font-weight: 600;
  color: var(--fairway-800);
}

table.scorecard tr.best td:first-child {
  position: relative;
}

table.scorecard tr.best td:first-child::before {
  content: "⛳";
  margin-right: 4px;
  font-size: 10px;
}

/* ============ Courses list ============ */
.course-list { display: flex; flex-direction: column; gap: 8px; }

.course-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 13px;
  background: var(--cream-50);
}

.course-item .ci-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-900);
}

.course-item .ci-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-500);
  margin-top: 2px;
}

.course-item .ci-del {
  width: auto;
  margin: 0;
  background: none;
  color: var(--flag-700);
  font-size: 18px;
  padding: 4px 8px;
}

.empty-state {
  text-align: center;
  padding: 24px 10px;
  color: var(--ink-500);
  font-size: 13px;
}

/* ============ Bottom nav ============ */
.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(11,61,46,0.97);
  backdrop-filter: blur(6px);
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-dark);
}

.nav {
  background: none;
  border: none;
  color: rgba(246,242,231,0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  margin: 0;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: var(--radius-sm);
}

.nav svg { width: 20px; height: 20px; }
.nav svg * { stroke: currentColor; }

.nav.active {
  color: var(--sand-400);
}

.nav:active { transform: scale(0.96); }

/* ============ Scrollbar niceties ============ */
::-webkit-scrollbar { height: 6px; width: 6px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* ============ Small screens ============ */
@media (max-width: 360px) {
  .app-header h1 { font-size: 26px; }
  .hero-card strong { font-size: 38px; }
}
