* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; background: #1d4a26; color: #20242e;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none; }
#wrap { position: fixed; inset: 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: absolute; top: 0; left: 0; right: 0; z-index: 5; pointer-events: none;
  padding-top: calc(8px + env(safe-area-inset-top)); }
#topRow { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 14px; }
#homeBtn { pointer-events: auto; width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.92);
  color: #20242e; font-size: 22px; font-weight: 800; display: flex; align-items: center; justify-content: center;
  text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
#holeLabel { background: rgba(255,255,255,.92); border-radius: 999px; padding: 8px 18px;
  font-weight: 800; font-size: 15px; letter-spacing: 1px; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
#modeTag { background: #20242e; color: #fff; border-radius: 999px; padding: 8px 12px;
  font-weight: 800; font-size: 11px; letter-spacing: 1px; }
#modeTag.prac { background: #b45309; }
#scoreStrip { display: flex; gap: 5px; justify-content: center; margin: 8px 14px 0; }
.scell { flex: 1; max-width: 52px; background: rgba(255,255,255,.92); border-radius: 10px; padding: 5px 2px;
  text-align: center; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.scell .n { font-size: 10px; font-weight: 700; color: #6b6f7a; }
.scell .p { font-size: 9px; font-weight: 700; color: #6b6f7a; letter-spacing: .5px; }
.scell .s { font-size: 16px; font-weight: 900; color: #20242e; }
.scell.cur { outline: 3px solid #fbbf24; }

/* ---------- bottom panel ---------- */
#panel { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96); border-radius: 22px 22px 0 0;
  box-shadow: 0 -4px 18px rgba(0,0,0,.25); text-align: center; }
#phaseHint { font-size: 15px; font-weight: 600; color: #374151; margin-bottom: 10px; min-height: 20px; }
/* 7-second aim clock: clean pill above the instructions, red when low */
#aimTimer { display: inline-block; min-width: 46px; padding: 4px 14px; margin-bottom: 8px;
  background: #20242e; color: #fff; border-radius: 999px; font-size: 16px; font-weight: 900;
  font-variant-numeric: tabular-nums; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
#aimTimer.low { background: #b91c1c; }
#phaseBtn { background: #15803d; color: #fff; border: none; border-radius: 14px; padding: 14px 34px;
  font-size: 17px; font-weight: 800; letter-spacing: .5px; box-shadow: 0 4px 0 #14532d; }
#phaseBtn:active { transform: translateY(2px); box-shadow: 0 2px 0 #14532d; }
#resultLine { font-size: 18px; font-weight: 800; min-height: 24px; margin-top: 10px; }

/* ---------- the needle (horizontal timing bar) ---------- */
#needleBar { position: absolute; left: 14px; right: 14px; bottom: 162px; z-index: 7;
  touch-action: none; user-select: none; -webkit-user-select: none; }
#needleTrack { position: relative; height: 48px; border-radius: 14px; overflow: hidden;
  background: #1f2937; border: 3px solid rgba(255,255,255,.92);
  box-shadow: 0 4px 14px rgba(0,0,0,.35); }
#pureBand { position: absolute; top: 0; bottom: 0; left: 82%; width: 5%;
  background: #fbbf24; box-shadow: 0 0 12px #fbbf24; }
#overZone { position: absolute; top: 0; bottom: 0; left: 87%; width: 13%;
  background: repeating-linear-gradient(45deg,#ef4444,#ef4444 8px,#b91c1c 8px,#b91c1c 16px); }
#needle { position: absolute; top: -4px; bottom: -4px; left: 0; width: 11px;
  background: #fff; border: 2px solid #111827; border-radius: 3px;
  box-shadow: 0 0 14px rgba(255,255,255,.95), 0 0 4px rgba(255,255,255,1); }
#needleNums { position: relative; height: 20px; margin-top: 4px; }
.nn0,.nnpure,.nnover,.nn100 { position: absolute; font-size: 11px; font-weight: 900;
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.nn0 { left: 2px; } .nn100 { right: 2px; }
/* distance calibration ticks: expected carry at 25/50/75% of pure power */
#tickLayer { position: absolute; inset: 0; pointer-events: none; }
.tick { position: absolute; top: 5px; bottom: 5px; width: 2px;
  background: rgba(255,255,255,.55); border-radius: 1px; }
#tickLabels { position: relative; height: 15px; margin-top: 3px; }
.tickLab { position: absolute; transform: translateX(-50%); font-size: 10px; font-weight: 800;
  color: #e5e7eb; text-shadow: 0 1px 2px rgba(0,0,0,.8); white-space: nowrap; }
.nnpure { left: 84.5%; transform: translateX(-50%); color: #fde68a; font-size: 9px; }
.nnover { left: 93.5%; transform: translateX(-50%); color: #fca5a5; font-size: 9px; }
#needleCap { text-align: center; font-size: 12px; font-weight: 700; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.7); margin-top: 2px; }

/* ---------- scorecard vs par ---------- */
.scell.under { background: #15803d; }
.scell.under .n, .scell.under .p, .scell.under .s { color: #fff; }
.scell.over { background: #fee2e2; }
.scell.over .s { color: #b91c1c; }
.scell.even .s { color: #374151; }

/* ---------- action button states ---------- */
#phaseBtn.stop { background: #b91c1c; box-shadow: 0 4px 0 #7f1d1d; color: #fff; }
#phaseBtn.stop:active { transform: translateY(2px); box-shadow: 0 2px 0 #7f1d1d; }

/* ---------- result grades ---------- */
#resultLine .grade { display: inline-block; padding: 4px 14px; border-radius: 999px; color: #fff; font-size: 15px; margin-right: 8px; }
.g-pure { background: #15803d; } .g-over { background: #b91c1c; } .g-ease { background: #6b7280; }

/* ---------- overlays ---------- */
.overlay { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column;
  align-items: center; justify-content: center; background: rgba(20,40,24,.94);
  backdrop-filter: blur(6px); padding: 24px; text-align: center; overflow-y: auto; }
.title { font-size: 44px; font-weight: 900; margin: 0; color: #fff; letter-spacing: 1px; }
.title2 { font-size: 30px; font-weight: 900; margin: 0 0 6px; color: #fff; }
.subtitle { margin: 12px 0 18px; font-size: 16px; color: #d1e7d4; line-height: 1.5; }
.big { background: #22c55e; color: #062b14; border: none; border-radius: 16px; padding: 15px 40px;
  font-size: 18px; font-weight: 900; margin: 6px; box-shadow: 0 4px 0 #14532d; }
.big:active { transform: translateY(2px); box-shadow: 0 2px 0 #14532d; }
.ghost { background: transparent; color: #d1e7d4; border: 2px solid #5b7a60; border-radius: 16px;
  padding: 12px 26px; font-size: 15px; font-weight: 700; margin: 6px; }
.small { font-size: 13px; padding: 13px 18px; border-radius: 12px; }
.row { display: flex; gap: 4px; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
#nameInput, #phraseInput { width: 260px; max-width: 80vw; padding: 13px 16px; font-size: 17px;
  border-radius: 12px; border: 2px solid #5b7a60; background: #fff; margin: 6px; text-align: center; }
.msg { color: #fca5a5; font-size: 14px; min-height: 20px; margin: 4px 0; }
#lockBox { background: #fff; border-radius: 16px; padding: 16px 26px; margin: 6px 0 12px; color: #20242e; }
#lockTime { font-size: 32px; font-weight: 900; margin-top: 4px; font-variant-numeric: tabular-nums; }
#lockScore { font-size: 17px; font-weight: 800; color: #15803d; margin-top: 6px; }
.secTitle { color: #fff; font-weight: 800; font-size: 14px; letter-spacing: 1px;
  text-transform: uppercase; margin: 16px 0 8px; }
.list { width: 320px; max-width: 88vw; max-height: 30vh; overflow-y: auto; background: rgba(255,255,255,.08);
  border-radius: 12px; padding: 8px; }
.lbRow { display: flex; justify-content: space-between; padding: 7px 10px; color: #fff;
  font-size: 14px; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,.08); }
.lbRow.me { background: rgba(34,197,94,.25); border-radius: 8px; }
.resScore { font-size: 52px; font-weight: 900; color: #fff; }
.resScore small { font-size: 18px; color: #d1e7d4; font-weight: 700; }
