/* Golf Korner: the game box (#kg) and everything drawn over the 3D view. */
.kg {
  --ink: #1d3a2a; --ink2: #4f6b5a; --green: #2fae4e; --green2: #1d8a3a; --sky: #3d8fe8; --coral: #ff7a45; --coral2: #e2502a; --gold: #ffc531;
  --card: rgba(255, 255, 255, 0.95); --line: rgba(29, 58, 42, 0.12);
  position: relative; width: 100%; height: 100%; overflow: hidden; user-select: none; -webkit-user-select: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; background: #86c4ff;
  font-family: 'Fredoka', 'Nunito', 'Segoe UI', system-ui, sans-serif; color: var(--ink); contain: layout paint; container-type: size;
}
.kg:focus { outline: none; }
.kg.kg-aiming { touch-action: none; cursor: crosshair; }
.kg[data-mode=roll], .kg[data-mode=wait], .kg[data-mode=intro], .kg[data-mode=result] { touch-action: none; }
.kg-canvas { position: absolute; inset: 0; display: block; z-index: 0; }
.kg button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.kg svg { width: 1em; height: 1em; fill: currentColor; display: block; }

/* ---------------------------------------------------------------- loading */
.kg-loading { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(120% 90% at 50% 10%, #c8ecff 0%, #79c3ff 50%, #3d8fe8 100%); transition: opacity .6s; color: #fff; }
.kg-loading.out { opacity: 0; pointer-events: none; }
.kg-loading p { margin: 0; font-weight: 600; font-size: 15px; opacity: .92; max-width: 80%; text-align: center; }
.kg-loadbar { width: 160px; height: 8px; border-radius: 6px; background: rgba(255, 255, 255, .35); overflow: hidden; }
.kg-loadbar i { display: block; height: 100%; width: 40%; border-radius: 6px; background: #fff; animation: kgLoad 1.1s ease-in-out infinite; }
@keyframes kgLoad { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

/* ---------------------------------------------------------------- the logo */
.kg-logo { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: .18em; font-family: 'Fredoka', 'Fredoka One', sans-serif; font-weight: 700;
  font-size: clamp(40px, 12cqw, 88px); line-height: .95; transform: rotate(-3deg); }
.kg-logo span { color: #fff; -webkit-text-stroke: .085em #1f7a3a; paint-order: stroke fill; text-shadow: 0 .09em 0 #145a28, 0 .16em .25em rgba(10, 50, 20, .35); }
.kg-logo .b { color: #ffd84a; -webkit-text-stroke-color: #d9531f; text-shadow: 0 .09em 0 #a83a12, 0 .16em .25em rgba(80, 20, 0, .35); }
.kg-logo.small { font-size: 46px; }

/* ---------------------------------------------------------------- round buttons */
.kg-round { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; color: var(--ink) !important;
  background: rgba(255, 255, 255, .9) !important; box-shadow: 0 3px 0 rgba(29, 58, 42, .2), 0 6px 16px rgba(10, 40, 20, .2); transition: transform .12s; touch-action: none; }
.kg-round:hover { transform: translateY(-1px) scale(1.04); }
.kg-round:active { transform: translateY(1px) scale(.95); }
.kg-round.off { color: #9fb0a6 !important; }
.kg-corner { position: absolute; right: 12px; top: 12px; z-index: 12; display: none; gap: 8px; }
.kg-corner.on { display: flex; }

/* ---------------------------------------------------------------- HUD */
.kg-hud { position: absolute; left: 0; right: 0; top: 0; z-index: 8; display: none; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 12px 12px; pointer-events: none; }
.kg-hud.on { display: flex; }
.kg-hud > button { pointer-events: auto; }
.kg-holetag { display: flex; flex-direction: column; gap: 1px; padding: 7px 14px 8px; border-radius: 16px; background: rgba(255, 255, 255, .9); box-shadow: 0 3px 0 rgba(29, 58, 42, .15); min-width: 0; }
.kg-holetag b { font-weight: 700; font-size: 19px; line-height: 1.1; color: var(--green2); }
.kg-holetag b small { font-size: 14px; color: var(--ink2); font-weight: 600; }
.kg-holetag span { font-weight: 600; font-size: 13px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kg-turn { display: flex; align-items: baseline; gap: 6px; padding: 6px 16px 7px; border-radius: 16px; background: rgba(255, 255, 255, .9); box-shadow: 0 3px 0 rgba(29, 58, 42, .15); margin-left: auto; }
.kg-turn .n { font-weight: 700; font-size: 26px; line-height: 1; }
.kg-turn .l { font-weight: 600; font-size: 13px; color: var(--ink2); }
.kg-turn .who { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 15px; margin-right: 4px; align-self: center; }
.kg-turn .who i, .kg-players .balls i, .kg-score .who i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18), 0 0 0 1.5px rgba(29, 58, 42, .35); }
.kg-cambar { position: absolute; right: 12px; bottom: 12px; z-index: 8; display: none; gap: 8px; }
.kg-cambar.on { display: flex; }
.kg-meter { position: absolute; left: 14px; top: 50%; z-index: 8; width: 16px; height: 34%; transform: translateY(-50%); border-radius: 10px; background: rgba(255, 255, 255, .6);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .2), 0 2px 0 rgba(255, 255, 255, .5); display: none; }
.kg-meter.on { display: block; }
.kg-meter i { position: absolute; left: 2px; right: 2px; bottom: 2px; border-radius: 8px; max-height: calc(100% - 4px); }
.kg-meter b { position: absolute; left: 50%; top: -24px; transform: translateX(-50%); font-weight: 700; font-size: 14px; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .4); }

/* ---------------------------------------------------------------- hints, toasts and banners */
.kg-hint { position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); z-index: 7; display: none; align-items: center; gap: 10px; padding: 9px 18px; border-radius: 22px;
  background: rgba(255, 255, 255, .92); font-weight: 600; font-size: 16px; box-shadow: 0 4px 0 rgba(29, 58, 42, .15); pointer-events: none; white-space: nowrap; max-width: 92cqw; }
.kg-hint.on { display: flex; }
.kg-hint .hand { font-size: 24px; animation: kgDrag 1.6s ease-in-out infinite; }
@keyframes kgDrag { 0%, 100% { transform: translateY(-6px); } 50% { transform: translateY(10px); } }
.kg-toast { position: absolute; left: 50%; top: 74px; transform: translate(-50%, -10px); z-index: 9; padding: 9px 20px; border-radius: 22px; background: rgba(255, 255, 255, .95);
  font-weight: 700; font-size: 18px; color: var(--coral2); box-shadow: 0 4px 0 rgba(29, 58, 42, .15); opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; white-space: nowrap; }
.kg-toast.on { opacity: 1; transform: translate(-50%, 0); }
.kg-banner { position: absolute; left: 50%; top: 24%; z-index: 9; transform: translate(-50%, -8px) scale(.9); display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 28px 16px; border-radius: 26px; background: rgba(255, 255, 255, .95); box-shadow: 0 6px 0 rgba(29, 58, 42, .14), 0 18px 40px rgba(10, 40, 20, .25);
  font-weight: 700; font-size: 30px; color: var(--green2); text-align: center; opacity: 0; pointer-events: none; transition: opacity .25s, transform .3s cubic-bezier(.2, 1.4, .4, 1); }
.kg-banner.on { opacity: 1; transform: translate(-50%, 0) scale(1); }
.kg-banner small { font-size: 15px; font-weight: 600; color: var(--ink2); }
.kg-banner .who { font-size: 16px; padding: 3px 12px; border-radius: 12px; background: color-mix(in srgb, var(--c) 30%, white); color: var(--ink); margin-bottom: 4px; }
.kg-banner .big { font-size: clamp(32px, 7cqw, 52px); line-height: 1.05; color: var(--green2); }
.kg-banner .big.good { color: #e2502a; text-shadow: 0 3px 0 #ffd84a; }
.kg-banner .big.meh { color: var(--ink2); }
.kg-banner .stars { display: flex; gap: 8px; margin-top: 6px; }
.kg-banner .stars i { font-size: 34px; color: #dfe7e1; display: block; }
.kg-banner .stars i.got { color: var(--gold); filter: drop-shadow(0 2px 0 #c27a00); animation: kgStar .5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes kgStar { from { transform: scale(0) rotate(-40deg); } to { transform: scale(1) rotate(0); } }
.kg-banner.intro { top: 18%; }

/* ---------------------------------------------------------------- screens */
.kg-screen { position: absolute; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center; padding: 64px 14px 16px; overflow-y: auto; }
.kg-screen.on { display: flex; animation: kgFade .25s ease-out; }
.kg-screen.dim { background: rgba(10, 30, 20, .34); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.kg-screen.title { background: linear-gradient(180deg, rgba(10, 40, 30, .2) 0%, rgba(10, 40, 30, 0) 35%, rgba(10, 40, 30, 0) 60%, rgba(10, 40, 30, .28) 100%); }
.kg-screen.menu { background: rgba(10, 30, 20, .28); align-items: flex-start; }
@keyframes kgFade { from { opacity: 0; } to { opacity: 1; } }
.kg-title { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; margin-top: -4%; }
.kg-sub { margin: 4px 0 6px; font-weight: 600; font-size: clamp(14px, 3.4cqw, 19px); color: #fff; text-shadow: 0 2px 0 rgba(10, 40, 20, .5); }
.kg-title-btns { display: flex; flex-direction: column; gap: 12px; width: min(320px, 82cqw); }
.kg-total { margin: 4px 0 0; display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 15px; color: #fff; text-shadow: 0 2px 0 rgba(10, 40, 20, .5); }
.kg-total .st { color: var(--gold); font-size: 18px; }

.kg-btn { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 10px 22px; border-radius: 16px;
  font-weight: 700 !important; font-size: 18px; color: var(--green2) !important; background: #fff !important;
  box-shadow: 0 4px 0 #bcd6c3, 0 8px 18px rgba(10, 40, 20, .18); transition: transform .1s, box-shadow .1s; }
.kg-btn:hover { transform: translateY(-1px); }
.kg-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #bcd6c3, 0 3px 8px rgba(10, 40, 20, .18); }
.kg-btn:focus-visible, .kg-course:focus-visible, .kg-chip:focus-visible { outline: 3px solid #ffd84a; outline-offset: 3px; }
.kg-btn .ic { font-size: 22px; }
.kg-btn.big { min-height: 58px; font-size: 22px; border-radius: 20px; }
.kg-btn.primary { color: #fff !important; background: linear-gradient(180deg, #ff9a5c, var(--coral)) !important; box-shadow: 0 5px 0 var(--coral2), 0 10px 22px rgba(200, 70, 20, .3); text-shadow: 0 2px 0 rgba(160, 50, 10, .35); }
.kg-btn.primary:active { box-shadow: 0 2px 0 var(--coral2), 0 4px 10px rgba(200, 70, 20, .3); }
.kg-btn.danger { color: #d23b3b !important; box-shadow: 0 4px 0 #f0c4c4, 0 8px 18px rgba(10, 40, 20, .12); }
.kg-btn.small { min-height: 40px; font-size: 15px; }
.kg-btn.icon { width: 44px; min-height: 44px; padding: 0; border-radius: 50%; }
.kg-btn.ghost { background: rgba(255, 255, 255, .88) !important; }

/* ---------------------------------------------------------------- choosing a course */
.kg-courses { width: min(760px, 100%); display: flex; flex-direction: column; gap: 12px; }
.kg-head { display: flex; align-items: center; gap: 12px; }
.kg-head h2 { margin: 0; font-weight: 700; font-size: 26px; color: #fff; text-shadow: 0 2px 0 rgba(10, 40, 20, .5); }
.kg-players { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kg-players .lab { font-weight: 700; font-size: 16px; color: #fff; text-shadow: 0 2px 0 rgba(10, 40, 20, .5); margin-right: 2px; }
.kg-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 14px; background: rgba(255, 255, 255, .78) !important; font-weight: 700 !important; font-size: 16px;
  box-shadow: 0 3px 0 rgba(29, 58, 42, .18); }
.kg-chip .balls { display: inline-flex; gap: 2px; }
.kg-chip.on { background: #fff !important; color: var(--green2) !important; box-shadow: 0 3px 0 var(--green), 0 0 0 2px var(--green); }
.kg-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@container (max-width: 560px) { .kg-grid { grid-template-columns: 1fr; } }
.kg-course { position: relative; display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "em nm st" "em bl bl" "em meta meta"; column-gap: 12px; row-gap: 2px;
  align-items: center; text-align: left; padding: 14px 16px; border-radius: 20px; background: var(--card) !important; box-shadow: 0 5px 0 rgba(29, 58, 42, .16), 0 12px 26px rgba(10, 40, 20, .2);
  transition: transform .12s; }
.kg-course:hover { transform: translateY(-2px); }
.kg-course .em { grid-area: em; font-size: 34px; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; background: #e8f5ea; }
.kg-course.c1 .em { background: #fff0db; } .kg-course.c2 .em { background: #e4eefc; } .kg-course.full .em { background: #fff6cc; }
.kg-course .lk { grid-area: em; justify-self: center; font-size: 26px; color: #9fb0a6; }
.kg-course .nm { grid-area: nm; font-weight: 700; font-size: 20px; color: var(--green2); }
.kg-course.c1 .nm { color: #d9661f; } .kg-course.c2 .nm { color: #2f6fd0; } .kg-course.full .nm { color: #b07a00; }
.kg-course .bl { grid-area: bl; font-weight: 500; font-size: 14px; color: var(--ink2); }
.kg-course .meta { grid-area: meta; font-weight: 600; font-size: 13px; color: var(--ink2); }
.kg-course .meta b { color: var(--ink); }
.kg-course .stars { grid-area: st; display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 15px; }
.kg-course .stars i { color: var(--gold); font-size: 18px; }
.kg-course.locked { opacity: .72; }
.kg-course.locked .nm { color: #7f9187; }
.kg-course.nope, .kg-chip.nope { animation: kgNope .35s; }
@keyframes kgNope { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------------------------------------------------------------- cards */
.kg-card { width: min(380px, 100%); padding: 22px 22px 18px; border-radius: 26px; background: var(--card); box-shadow: 0 8px 0 rgba(29, 58, 42, .12), 0 24px 60px rgba(10, 40, 20, .3);
  text-align: center; animation: kgPopIn .3s cubic-bezier(.2, 1.4, .4, 1); margin: auto; }
.kg-card.card { width: min(720px, 100%); }
@keyframes kgPopIn { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.kg-card h2 { margin: 0 0 6px; font-weight: 700; font-size: 30px; color: var(--green2); }
.kg-line { margin: 4px 0 10px; font-weight: 600; font-size: 16px; color: var(--ink2); }
.kg-col { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.kg-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
.kg-ribbon { margin: 10px auto 0; max-width: 360px; padding: 8px 12px; border-radius: 14px; background: linear-gradient(90deg, #ffe58a, #ffd04a); color: #7a4a00; font-weight: 700; font-size: 16px; }
.kg-win { margin: 12px 0 0; font-weight: 700; font-size: 22px; color: var(--coral2); }
.kg-scroll { overflow-x: auto; margin: 8px -6px 0; padding: 0 6px 4px; }
.kg-score { border-collapse: separate; border-spacing: 0; margin: 0 auto; font-weight: 600; font-size: 15px; }
.kg-score th, .kg-score td { padding: 6px 7px; text-align: center; min-width: 26px; }
.kg-score th { color: var(--ink2); font-size: 13px; font-weight: 700; }
.kg-score th.cur { color: var(--coral2); }
.kg-score tr.par td { color: var(--ink2); font-size: 13px; border-bottom: 2px solid var(--line); }
.kg-score td.who { text-align: left; white-space: nowrap; font-weight: 700; }
.kg-score td.who i { margin-right: 5px; vertical-align: -1px; }
.kg-score td.under { color: #e2502a; }
.kg-score td.ace { color: #fff; background: #e2502a; border-radius: 50%; }
.kg-score td.over { color: #6f8478; }
.kg-score td.tot { font-weight: 700; white-space: nowrap; }
.kg-score td.tot small { color: var(--ink2); font-size: 12px; }
.kg-score.wide { font-size: 13px; }
.kg-score.wide th, .kg-score.wide td { padding: 5px 4px; min-width: 20px; }

/* settings */
.kg-sets { display: flex; flex-direction: column; gap: 4px; margin: 10px 0 0; text-align: left; }
.kg-sets.compact { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--line); }
.kg-set { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 4px; font-weight: 600; font-size: 16px; color: var(--ink); }
.kg-set input[type=range] { width: 52%; accent-color: var(--green); }
.kg-toggle { position: relative; width: 52px; height: 30px; border-radius: 16px; background: #cfdcd3 !important; transition: background .2s; flex: none; }
.kg-toggle i { position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s; }
.kg-toggle.on { background: var(--green) !important; }
.kg-toggle.on i { transform: translateX(22px); }
.kg-seg { display: inline-flex; border-radius: 12px; background: #e3ece6; padding: 3px; gap: 2px; }
.kg-seg button { padding: 5px 10px; border-radius: 9px; font-weight: 700 !important; font-size: 14px; color: var(--ink2) !important; }
.kg-seg button.on { background: #fff !important; color: var(--green2) !important; box-shadow: 0 2px 0 rgba(29, 58, 42, .15); }

/* small boxes */
.kg[data-small] .kg-holetag b { font-size: 16px; }
.kg[data-small] .kg-banner { font-size: 24px; padding: 10px 20px 12px; }
.kg[data-small] .kg-round { width: 40px; height: 40px; font-size: 20px; }
.kg[data-tall] .kg-banner { top: 20%; }
