/* TEE & SORCERY — storybook UI: parchment panels, gold trim, chunky friendly buttons. */
:root {
    --ink: #2a1a2a; --ink2: #4a3446; --parch: #fff5df; --parch2: #f5e2b8; --gold: #ffcf4a; --gold2: #e89a1a;
    --plum: #2a1a40; --plum2: #4a2a6a; --sky: #6ab8f0; --green: #5ac85a; --red: #e8504a; --mp: #6ab0ff;
    --body: 'Fredoka', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
    --title: 'Cinzel Decorative', 'Georgia', 'Times New Roman', serif;
    --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--plum); color: var(--ink); font-family: var(--body); user-select: none; -webkit-user-select: none; touch-action: none; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

#back-link {
    position: fixed; top: calc(8px + var(--safe-t)); left: calc(8px + var(--safe-l)); z-index: 99999; font-family: Arial, Helvetica, sans-serif; font-size: 13px;
    color: #fff; background: rgba(0, 0, 0, 0.55); padding: 6px 12px; border-radius: 6px; text-decoration: none; border: 1px solid rgba(255, 255, 255, 0.25);
}
#back-link:hover { background: rgba(0, 0, 0, 0.8); }
body.in-hole #back-link { display: none; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------------------------------------------------------------- shared pieces */
.panel {
    background: linear-gradient(180deg, var(--parch) 0%, var(--parch2) 100%);
    border: 3px solid var(--ink); border-radius: 18px;
    box-shadow: 0 0 0 3px var(--gold), 0 0 0 6px var(--ink), 0 10px 30px rgba(20, 0, 30, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.8);
    padding: 18px 20px;
}
.panel.slim { padding: 6px 12px; border-radius: 12px; border-width: 2px; box-shadow: 0 0 0 2px var(--gold), 0 0 0 4px var(--ink), 0 4px 12px rgba(20, 0, 30, 0.35); }
h2 { font-family: var(--title); font-size: 22px; color: var(--plum2); letter-spacing: 0.5px; }
.btn {
    font-size: 17px; font-weight: 600; color: var(--ink); background: linear-gradient(180deg, #ffffff, #e8dcc4);
    border: 3px solid var(--ink); border-radius: 14px; padding: 9px 18px; min-height: 44px; min-width: 44px;
    box-shadow: 0 4px 0 var(--ink), 0 6px 10px rgba(0, 0, 0, 0.25); transition: transform 0.06s, box-shadow 0.06s, filter 0.1s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active, .btn.down { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink), 0 2px 4px rgba(0, 0, 0, 0.25); }
.btn.gold { background: linear-gradient(180deg, #fff1a8, var(--gold) 45%, var(--gold2)); }
.btn.ghost { background: rgba(255, 250, 235, 0.86); }
.btn.small { font-size: 14px; padding: 6px 12px; }
.btn.round { border-radius: 50%; padding: 0; width: 46px; height: 46px; font-size: 18px; }
.btn.round.small { width: 44px; height: 44px; font-size: 14px; }
.btn:disabled { filter: grayscale(0.8) brightness(0.9); opacity: 0.6; cursor: default; }
.btn.on { background: linear-gradient(180deg, #fff1a8, var(--gold)); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip { min-width: 46px; min-height: 46px; border-radius: 12px; border: 3px solid var(--ink); background: #fff; font-weight: 600; font-size: 14px; padding: 4px 10px; box-shadow: 0 3px 0 var(--ink); }
.chip.on { outline: 4px solid var(--gold); outline-offset: 1px; }
.chip.swatch { width: 46px; padding: 0; }

/* ---------------------------------------------------------------- screens */
.screen { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.screen > * { pointer-events: auto; }
.overlay { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(30, 10, 50, 0.45); backdrop-filter: blur(2px); padding: 16px; }

/* title */
#title { display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 16px; padding: calc(5vh + var(--safe-t)) 20px calc(4vh + var(--safe-b)); }
.title-low { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.logo { text-align: center; pointer-events: none; filter: drop-shadow(0 6px 0 var(--ink)) drop-shadow(0 12px 20px rgba(20, 0, 40, 0.5)); animation: float 4s ease-in-out infinite; }
.logo-top, .logo-main {
    font-family: var(--title); font-weight: 900; line-height: 0.95; letter-spacing: 2px;
    background: linear-gradient(180deg, #fffbe0 0%, #ffe070 35%, #f0a020 65%, #c86a10 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
    -webkit-text-stroke: 2px var(--ink);
}
.logo-top { font-size: clamp(30px, 7vw, 64px); }
.logo-top span { font-size: 0.8em; }
.logo-main { font-size: clamp(46px, 12vw, 120px); }
.logo-sub { font-family: var(--body); font-weight: 600; font-size: clamp(14px, 2.6vw, 22px); color: #fff; text-shadow: 0 2px 0 var(--ink), 0 0 12px rgba(120, 60, 200, 0.8); letter-spacing: 4px; text-transform: uppercase; margin-top: 8px; }
.menu { display: flex; flex-direction: column; gap: 12px; min-width: 240px; }
.menu .btn { font-size: 20px; }
.menu .btn.sel { outline: 4px solid #fff; outline-offset: 2px; }
.title-foot { color: #fff; font-size: 14px; text-shadow: 0 2px 0 var(--ink); opacity: 0.85; }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-8px) rotate(1deg); } }

/* creator */
#creator { display: flex; align-items: center; justify-content: flex-end; padding: 20px 5vw; }
.creator-panel { width: min(440px, 100%); display: flex; flex-direction: column; gap: 14px; }
.field { font-weight: 600; font-size: 15px; display: block; }
.field input { display: block; width: 100%; margin-top: 6px; font: 600 20px var(--body); padding: 8px 12px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; user-select: text; -webkit-user-select: text; }
.row-buttons { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* dialogue */
#dialogue { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 0 16px calc(16px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.dlg-title { font-family: var(--title); color: #fff; font-size: 20px; text-shadow: 0 3px 0 var(--ink); margin-bottom: 8px; }
.dlg-box {
    position: relative; width: min(860px, 100%); min-height: 132px; display: flex; gap: 14px; align-items: flex-start;
    background: linear-gradient(180deg, var(--parch), var(--parch2)); border: 3px solid var(--ink); border-radius: 18px;
    box-shadow: 0 0 0 3px var(--gold), 0 0 0 6px var(--ink), 0 10px 30px rgba(0, 0, 0, 0.4); padding: 14px 18px 14px 14px;
}
#dlg-portrait { width: 104px; height: 104px; border-radius: 14px; border: 3px solid var(--ink); background: radial-gradient(circle at 50% 40%, #fff8e0, #f0c870); flex: none; object-fit: cover; }
.dlg-body { flex: 1; min-width: 0; }
.dlg-name { display: inline-block; font-weight: 700; font-size: 17px; color: #fff; background: var(--plum2); border: 2px solid var(--ink); border-radius: 10px; padding: 2px 12px; margin-bottom: 6px; }
.dlg-text { font-size: 19px; line-height: 1.38; font-weight: 500; min-height: 3.6em; }
.dlg-next { position: absolute; right: 16px; bottom: 8px; font-size: 14px; color: var(--plum2); animation: bob 0.8s ease-in-out infinite; }
.dlg-skip { align-self: flex-end; margin: 0 max(0px, calc((100% - 860px) / 2)) 8px 0; order: -1; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(4px); } }

/* map */
.map-top { position: fixed; top: calc(10px + var(--safe-t)); left: calc(100px + var(--safe-l)); right: calc(12px + var(--safe-r)); display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.hero-badge { background: rgba(255, 245, 223, 0.95); border: 3px solid var(--ink); border-radius: 14px; padding: 4px 12px; font-weight: 600; font-size: 14px; box-shadow: 0 3px 0 var(--ink); }
.hero-badge b { color: var(--plum2); }
.shards { display: flex; gap: 4px; }
.shard { width: 26px; height: 32px; clip-path: polygon(50% 0, 100% 35%, 80% 100%, 20% 100%, 0 35%); background: rgba(40, 20, 60, 0.5); border: 0; }
.shard.got { background: linear-gradient(180deg, #fff6b0, var(--gold) 50%, var(--gold2)); filter: drop-shadow(0 0 6px #ffd84a); }
.map-card { position: fixed; left: calc(16px + var(--safe-l)); bottom: calc(86px + var(--safe-b)); width: min(360px, calc(100% - 32px)); }
.map-card h3 { font-family: var(--title); font-size: 18px; color: var(--plum2); }
.map-card .meta { font-size: 14px; font-weight: 600; color: var(--ink2); margin: 2px 0 6px; }
.map-card p { font-size: 15px; line-height: 1.35; }
.stars { color: var(--gold2); font-size: 20px; letter-spacing: 2px; text-shadow: 0 1px 0 var(--ink); }
.stars .off { color: rgba(40, 20, 60, 0.25); text-shadow: none; }
.map-nav { position: fixed; bottom: calc(16px + var(--safe-b)); left: 50%; transform: translateX(-50%); display: flex; gap: 14px; align-items: center; }
.map-nav .gold { min-width: 150px; font-size: 20px; }

/* clubhouse */
#clubhouse { display: flex; align-items: center; justify-content: center; padding: 56px 16px 16px; }
.club-panel { width: min(900px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 12px; }
.club-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.club-head h2 { flex: 1; }
.gold-chip { font-weight: 700; font-size: 18px; background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 4px 12px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { font: 600 15px var(--body); padding: 8px 14px; min-height: 44px; border: 3px solid var(--ink); border-radius: 12px 12px 4px 4px; background: #efe0c0; }
.tabs button.on { background: var(--gold); }
.club-body { overflow-y: auto; touch-action: pan-y; padding: 4px; min-height: 200px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.card { background: #fffaf0; border: 3px solid var(--ink); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; box-shadow: 0 3px 0 rgba(42, 26, 42, 0.5); }
.card .nm { font-weight: 700; font-size: 16px; }
.card .ds { font-size: 13px; color: var(--ink2); line-height: 1.3; flex: 1; }
.card .ft { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; }
.card .cat { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--plum2); font-weight: 700; }
.card.equipped { outline: 4px solid var(--green); }
.stat-row { display: grid; grid-template-columns: 120px 1fr 60px 56px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 2px dashed rgba(42, 26, 42, 0.2); }
.stat-row .bar { height: 16px; border: 2px solid var(--ink); border-radius: 8px; background: #fff; overflow: hidden; }
.stat-row .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold2)); }
.stat-row .val { font-weight: 700; font-size: 18px; text-align: right; }
.xpbar { height: 18px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; overflow: hidden; margin: 6px 0 12px; }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, #8ad8ff, #4a8aff); }
.records table { width: 100%; border-collapse: collapse; font-size: 14px; }
.records td, .records th { padding: 5px 6px; border-bottom: 1px solid rgba(42, 26, 42, 0.15); text-align: left; }

/* ---------------------------------------------------------------- HUD */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-tl { position: absolute; top: calc(10px + var(--safe-t)); left: calc(12px + var(--safe-l)); font-size: 14px; font-weight: 600; max-width: 46vw; }
.hud-tl .hn { font-family: var(--title); font-size: 16px; color: var(--plum2); }
.hud-tl .pips { display: flex; gap: 3px; margin-top: 4px; flex-wrap: wrap; }
.hud-tl .pip { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); background: #fff; }
.hud-tl .pip.used { background: var(--plum2); }
.hud-tl .pip.par { box-shadow: 0 0 0 2px var(--gold); }
.hud-tl .pip.over { background: var(--red); }
.hud-boss { position: absolute; top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%); width: min(420px, 42vw); text-align: center; pointer-events: none !important; }
.boss-name { font-family: var(--title); color: #fff; font-size: 16px; text-shadow: 0 2px 0 var(--ink), 0 0 8px #a040ff; }
.boss-bar { height: 16px; border: 3px solid var(--ink); border-radius: 10px; background: rgba(20, 0, 30, 0.6); overflow: hidden; margin-top: 4px; box-shadow: 0 0 12px rgba(160, 60, 255, 0.6); }
.boss-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff4a8a, #c040ff); transition: width 0.3s; }
.hud-tr { position: absolute; top: calc(10px + var(--safe-t)); right: calc(66px + var(--safe-r)); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none !important; }
.wind { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.wind-arrow { font-size: 22px; color: #3a8aff; transition: transform 0.2s; }
.mp { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.mp-bar { width: 90px; height: 12px; border: 2px solid var(--ink); border-radius: 8px; overflow: hidden; background: #fff; }
.mp-bar i { display: block; height: 100%; background: linear-gradient(90deg, #8ad8ff, var(--mp)); transition: width 0.2s; }
.coins { font-weight: 700; font-size: 14px; }
#minimap { position: absolute; left: calc(12px + var(--safe-l)); top: calc(92px + var(--safe-t)); width: 150px; height: 210px; border: 3px solid var(--ink); border-radius: 12px; box-shadow: 0 0 0 2px var(--gold), 0 4px 10px rgba(0, 0, 0, 0.3); background: #2a3a2a; pointer-events: none !important; }
.hud-lie { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(132px + var(--safe-b)); font-size: 14px; font-weight: 600; white-space: nowrap; pointer-events: none !important; }
.hud-lie b { color: var(--plum2); }
.hud-bl { position: absolute; left: calc(12px + var(--safe-l)); bottom: calc(14px + var(--safe-b)); display: grid; grid-template-columns: repeat(3, 52px); gap: 8px; }
.spell { position: relative; width: 52px; height: 52px; border-radius: 14px; border: 3px solid var(--ink); background: radial-gradient(circle at 40% 35%, #fff, var(--c, #ccc)); font-size: 22px; box-shadow: 0 3px 0 var(--ink); display: flex; align-items: center; justify-content: center; }
.spell .k { position: absolute; top: -6px; left: -6px; font-size: 11px; font-weight: 700; background: var(--ink); color: #fff; border-radius: 6px; padding: 0 4px; }
.spell .c { position: absolute; bottom: -6px; right: -6px; font-size: 11px; font-weight: 700; background: var(--mp); color: var(--ink); border: 2px solid var(--ink); border-radius: 8px; padding: 0 4px; }
.spell.armed { outline: 4px solid #fff; box-shadow: 0 0 18px var(--c), 0 3px 0 var(--ink); animation: pulse 0.8s ease-in-out infinite; }
.spell:disabled { filter: grayscale(1); opacity: 0.5; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.hud-bc { position: absolute; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(440px, 50vw); }
.club-sel { display: flex; align-items: center; gap: 8px; }
.club-name { min-width: 120px; text-align: center; font-weight: 700; font-size: 18px; background: var(--parch); border: 3px solid var(--ink); border-radius: 12px; padding: 6px 10px; box-shadow: 0 3px 0 var(--ink); }
.meter { width: 100%; }
.meter-track { position: relative; height: 28px; border: 3px solid var(--ink); border-radius: 14px; overflow: hidden; background: linear-gradient(90deg, #fff 0%, #ffe9a0 50%, #ff9a5a 100%); box-shadow: 0 3px 0 var(--ink); }
.meter-fill { position: absolute; left: 8%; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, rgba(90, 200, 255, 0.6), rgba(160, 80, 255, 0.7)); }
.meter-zone { position: absolute; top: 0; bottom: 0; left: 6%; width: 4%; background: repeating-linear-gradient(45deg, #5ac85a 0 6px, #8ae88a 6px 12px); box-shadow: 0 0 10px #5ac85a; }
.meter-power { position: absolute; top: -2px; bottom: -2px; width: 4px; background: var(--red); display: none; }
.meter-mark { position: absolute; top: -3px; bottom: -3px; width: 6px; margin-left: -3px; background: var(--ink); border-radius: 3px; left: 8%; box-shadow: 0 0 0 2px #fff; }
.meter-ticks { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 0 var(--ink), 0 0 4px var(--ink); padding: 2px 6px 0 2%; }
.hud-br { position: absolute; right: calc(14px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); display: flex; gap: 10px; align-items: flex-end; }
.btn.swing { width: 108px; height: 108px; border-radius: 50%; font-size: 20px; font-weight: 700; background: radial-gradient(circle at 40% 35%, #fff6c0, var(--gold) 55%, var(--gold2)); box-shadow: 0 6px 0 var(--ink), 0 0 24px rgba(255, 200, 60, 0.6); }
.btn.swing:disabled { box-shadow: 0 6px 0 var(--ink); }
.pause-btn { position: absolute; top: calc(10px + var(--safe-t)); right: calc(12px + var(--safe-r)); }
.aim-pad { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(178px + var(--safe-b)); padding: 6px 14px; border-radius: 12px; background: rgba(255, 255, 255, 0.25); color: #fff; font-weight: 600; font-size: 13px; text-shadow: 0 1px 0 var(--ink); pointer-events: none !important; display: none; }
body.touch .aim-pad { display: block; }
.toast-wrap { position: absolute; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(560px, 92vw); pointer-events: none !important; }
.toast { display: flex; align-items: center; gap: 10px; background: rgba(255, 245, 223, 0.97); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 12px 6px 6px; font-weight: 600; font-size: 15px; box-shadow: 0 4px 0 var(--ink); animation: toastIn 0.25s ease-out; }
.toast img { width: 40px; height: 40px; border-radius: 10px; border: 2px solid var(--ink); background: #f0c870; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all 0.4s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px) scale(0.95); } }
.big-banner { position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%); font-family: var(--title); font-weight: 900; font-size: clamp(36px, 8vw, 84px); white-space: nowrap; pointer-events: none !important;
    background: linear-gradient(180deg, #fffbe0, #ffe070 40%, #f0a020); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 2px var(--ink);
    filter: drop-shadow(0 5px 0 var(--ink)) drop-shadow(0 0 20px rgba(255, 200, 60, 0.6)); animation: bannerIn 0.5s cubic-bezier(.2, 1.6, .5, 1); }
.big-banner.sad { background: linear-gradient(180deg, #e0f0ff, #8ab0ff 50%, #4a6ac8); -webkit-background-clip: text; background-clip: text; }
.big-banner small { display: block; font-size: 0.35em; text-align: center; -webkit-text-stroke: 1px var(--ink); }
@keyframes bannerIn { from { transform: translate(-50%, -50%) scale(0.2) rotate(-8deg); opacity: 0; } }
.hole-card { position: absolute; top: 18%; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none !important; animation: bannerIn 0.6s cubic-bezier(.2, 1.4, .5, 1); }
.hole-card .realm { font-family: var(--body); font-weight: 700; letter-spacing: 4px; text-transform: uppercase; color: #fff; text-shadow: 0 2px 0 var(--ink); font-size: 15px; }
.hole-card .nm { font-family: var(--title); font-weight: 900; font-size: clamp(30px, 6vw, 56px); color: #fff; -webkit-text-stroke: 2px var(--ink); text-shadow: 0 5px 0 var(--ink); }
.hole-card .par { display: inline-block; margin-top: 8px; background: var(--parch); border: 3px solid var(--ink); border-radius: 12px; padding: 4px 14px; font-weight: 700; font-size: 17px; box-shadow: 0 3px 0 var(--ink); }
.hole-card .blurb { margin: 10px auto 0; max-width: 520px; color: #fff; font-weight: 600; text-shadow: 0 2px 0 var(--ink), 0 0 8px var(--ink); font-size: 16px; }
.hole-card .skip { margin-top: 12px; color: #fff; font-size: 13px; opacity: 0.85; text-shadow: 0 1px 0 var(--ink); }
.dmg { position: fixed; z-index: 25; font-family: var(--title); font-weight: 900; font-size: 30px; color: #fff; -webkit-text-stroke: 2px var(--ink); pointer-events: none; animation: dmgUp 1.1s ease-out forwards; }
@keyframes dmgUp { to { transform: translateY(-60px); opacity: 0; } }

/* results, pause, settings */
.result-panel { width: min(460px, 100%); text-align: center; display: flex; flex-direction: column; gap: 10px; max-height: 100%; overflow-y: auto; }
.result-panel .score-name { font-family: var(--title); font-weight: 900; font-size: 36px; color: var(--plum2); }
.result-panel .strokes { font-size: 18px; font-weight: 600; }
.result-panel .stars { font-size: 44px; }
.rewards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; font-weight: 600; font-size: 15px; }
.rewards div { background: #fffaf0; border: 2px solid var(--ink); border-radius: 10px; padding: 6px 10px; }
.levelup { font-family: var(--title); font-weight: 900; font-size: 22px; color: #fff; background: linear-gradient(90deg, #4a8aff, #c040ff); border: 3px solid var(--ink); border-radius: 12px; padding: 6px; animation: pulse 0.9s ease-in-out infinite; }
.pause-panel, .settings-panel, .confirm-panel { width: min(380px, 100%); display: flex; flex-direction: column; gap: 10px; max-height: 100%; overflow-y: auto; }
.pause-panel h2, .settings-panel h2, .confirm-panel h2 { text-align: center; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; }
.set-row .btn { min-width: 110px; }

/* credits */
#credits { background: radial-gradient(ellipse at 50% 30%, rgba(80, 40, 140, 0.4), rgba(20, 0, 40, 0.75)); display: flex; justify-content: center; overflow: hidden; }
.credits-roll { position: absolute; top: 100%; width: min(640px, 92vw); text-align: center; color: #fff; text-shadow: 0 2px 0 var(--ink); animation: roll 48s linear forwards; }
.credits-roll h1 { font-family: var(--title); font-size: 44px; margin: 30px 0 10px; color: var(--gold); -webkit-text-stroke: 1px var(--ink); }
.credits-roll h3 { font-family: var(--title); font-size: 22px; margin-top: 36px; color: var(--gold); }
.credits-roll p { font-size: 18px; margin: 6px 0; }
@keyframes roll { to { transform: translateY(calc(-100% - 100vh)); } }

/* fade + loading */
.fade { position: fixed; inset: 0; z-index: 90; background: #1a0a2a; opacity: 0; pointer-events: none; transition: opacity 0.35s; }
.fade.on { opacity: 1; }
.loading { position: fixed; inset: 0; z-index: 95; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 40%, #4a2a6a, #1a0a2a); color: #fff; font-weight: 600; transition: opacity 0.4s; }
.loading.done { opacity: 0; pointer-events: none; }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 6px solid rgba(255, 255, 255, 0.2); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.noscript { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; }

/* ---------------------------------------------------------------- phones */
/* portrait phones: 390 px wide budget → minimap off, lie line above the meter, swing button bottom-right */
@media (max-width: 700px) {
    .panel { padding: 14px; }
    h2 { font-size: 19px; }
    #minimap { width: 96px; height: 134px; top: calc(118px + var(--safe-t)); }
    .hud-tl { font-size: 12px; max-width: 52vw; padding: 4px 8px; }
    .hud-tl .hn { font-size: 13px; }
    .hud-tr { right: calc(64px + var(--safe-r)); gap: 6px; }
    .mp-bar { width: 56px; }
    .hud-boss { top: calc(64px + var(--safe-t)); width: 64vw; }
    .hud-bc { left: calc(12px + var(--safe-l)); right: calc(132px + var(--safe-r)); width: auto; transform: none; bottom: calc(14px + var(--safe-b)); }
    .hud-bl { bottom: calc(146px + var(--safe-b)); grid-template-columns: repeat(3, 48px); gap: 6px; }
    .spell { width: 48px; height: 48px; font-size: 20px; }
    .hud-lie { bottom: calc(108px + var(--safe-b)); left: calc(12px + var(--safe-l)); transform: none; font-size: 12px; white-space: normal; max-width: calc(100% - 150px); }
    .hud-br { flex-direction: column-reverse; align-items: center; }
    .btn.swing { width: 96px; height: 96px; }
    .club-name { min-width: 90px; font-size: 15px; }
    .dlg-box { min-height: 112px; padding: 10px; gap: 10px; }
    #dlg-portrait { width: 72px; height: 72px; }
    .dlg-text { font-size: 16px; }
    .map-top { left: calc(12px + var(--safe-l)); top: calc(50px + var(--safe-t)); }
    .map-card { bottom: calc(80px + var(--safe-b)); }
    .stat-row { grid-template-columns: 90px 1fr 40px 50px; }
    .aim-pad { bottom: calc(210px + var(--safe-b)); }
    #creator { justify-content: center; align-items: flex-end; }
    .toast-wrap { top: calc(262px + var(--safe-t)); }
    .toast { font-size: 14px; }
    .btn.swing { font-size: 17px; }
}
/* landscape phones: short screens */
@media (max-height: 500px) {
    #minimap { display: none; }
    .hud-bc { width: min(360px, 44vw); bottom: calc(8px + var(--safe-b)); }
    .hud-lie { bottom: calc(108px + var(--safe-b)); }
    .hud-bl { bottom: calc(8px + var(--safe-b)); grid-template-columns: repeat(3, 46px); }
    .spell { width: 46px; height: 46px; }
    .btn.swing { width: 92px; height: 92px; }
    .hud-br { bottom: calc(8px + var(--safe-b)); }
    .logo-main { font-size: 56px; } .logo-top { font-size: 30px; }
    #title { gap: 12px; flex-direction: row; flex-wrap: wrap; }
    .dlg-box { min-height: 96px; } #dlg-portrait { width: 64px; height: 64px; } .dlg-text { font-size: 15px; min-height: 2.6em; }
    .map-card { bottom: calc(70px + var(--safe-b)); max-height: 44vh; overflow: auto; }
    .club-panel { padding: 10px; }
    #clubhouse { padding-top: 44px; }
    .aim-pad { display: none !important; }
    .hole-card { top: 8%; }
    .toast-wrap { top: calc(64px + var(--safe-t)); width: min(520px, calc(100vw - 460px)); left: calc(50% - 40px); }
    .toast { font-size: 13px; }
    .btn.swing { font-size: 16px; }
}
