/* ============================================
   GROUP SCORE — compact side panel + winners screen
   ============================================ */

/* Panel: docks top-right, the canvas stays visible and usable */
.gs-panel {
    position: fixed; top: 64px; right: 14px; z-index: 2147483638;
    width: var(--gs-w, 440px); max-width: calc(100vw - 28px); max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px);
    display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px; box-sizing: border-box;
    background: var(--bg-surface-solid, #1e293b);
    border: 1px solid var(--border-strong, rgba(255,255,255,.14)); border-radius: 20px;
    box-shadow: var(--shadow-main, 0 18px 50px rgba(0,0,0,.45)); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    font-family: 'Outfit', 'Cairo', 'Inter', sans-serif; color: var(--text-main, #fff);
    transform: translateX(calc(100% + 30px)); opacity: 0; pointer-events: none;
    transition: transform .35s cubic-bezier(.2,.9,.3,1), opacity .25s ease;
}
.gs-panel.show { transform: translateX(0); opacity: 1; pointer-events: all; }

.gs-handle {
    position: fixed; top: 74px; right: 0; z-index: 2147483638; width: 44px; height: 52px; border: none;
    border-radius: 14px 0 0 14px; background: var(--primary, #f59e0b); color: var(--text-on-accent, #fff); font-size: 1.2rem; cursor: pointer;
    box-shadow: -4px 6px 18px rgba(0,0,0,.35); transform: translateX(110%); transition: transform .3s ease; pointer-events: none;
}
.gs-handle.show { transform: translateX(0); pointer-events: all; }
.gs-handle:hover { width: 50px; }

.gs-header { display: flex; align-items: center; gap: 5px; }
.gs-trophy-ico { color: var(--primary, #facc15); font-size: 1.1rem; margin-right: 2px; }
.gs-header input {
    flex: 1; min-width: 0; background: transparent; border: none; border-bottom: 1px dashed var(--border-strong);
    color: var(--text-main); font: 700 1rem 'Outfit', 'Cairo', sans-serif; padding: 3px 2px; outline: none;
}
.gs-header input:focus { border-bottom-color: var(--primary); }
.gs-icon-btn {
    width: 30px; height: 30px; flex: none; border-radius: 9px; border: none; background: var(--bg-item);
    color: var(--text-main); font-size: .8rem; cursor: pointer; transition: background .15s;
}
.gs-icon-btn:hover:not(:disabled) { background: var(--bg-item-hover); }
.gs-icon-btn:disabled { opacity: .3; cursor: default; }

/* Category editor */
.gs-cat-editor { display: none; flex-direction: column; gap: 5px; background: var(--bg-item); border: 1px solid var(--border-glass); border-radius: 12px; padding: 8px; }
.gs-cat-editor.show { display: flex; }
.gs-cat-row { display: flex; gap: 5px; align-items: center; }
.gs-cat-row input { background: var(--bg-surface-solid); border: 1px solid var(--border-strong); color: var(--text-main); border-radius: 8px; padding: 5px 7px; font: 500 .85rem 'Outfit', 'Cairo', sans-serif; min-width: 0; }
.gs-ce-icon { width: 42px; text-align: center; }
.gs-ce-name { flex: 1; }
.gs-ce-pts { width: 58px; }
.gs-ce-del { background: none; border: none; color: #f87171; cursor: pointer; padding: 4px 6px; }
.gs-ce-add { background: var(--bg-item); border: 1px dashed var(--primary); color: var(--text-main); border-radius: 9px; padding: 6px; cursor: pointer; font: 600 .8rem 'Outfit', 'Cairo', sans-serif; }

/* Matrix: rows = groups, columns = categories, each cell has its own − / + */
.gs-body { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 0; padding-right: 2px; touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.gs-head { position: sticky; top: 0; z-index: 2; background: var(--bg-surface-solid); border-radius: 10px; padding-top: 2px; padding-bottom: 4px; }
.gs-row { position: relative; display: grid; grid-template-columns: 138px 1fr; gap: 8px; align-items: center; }
.gs-row[data-i] {
    padding: 6px 8px; border-radius: 14px; border: 1.5px solid color-mix(in srgb, var(--gc) 65%, transparent);
    background: linear-gradient(160deg, color-mix(in srgb, var(--gc) 26%, var(--bg-surface-solid)) 0%, var(--bg-item) 100%);
}
.gs-cells { display: grid; grid-template-columns: repeat(var(--gs-ncat, 5), 1fr); gap: 5px; }
.gs-head { padding: 0 8px; }
.gs-chead { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; }
.gs-chead-icon { font-size: 1.25rem; line-height: 1.1; }
.gs-chead-name { font-size: .6rem; opacity: .75; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-chead-pts { font-size: .65rem; font-weight: 800; background: var(--primary, #facc15); color: var(--text-on-accent, #1e293b); border-radius: 999px; padding: 0 6px; }

.gs-info { display: flex; align-items: center; gap: 6px; min-width: 0; }
.gs-avatar { font-size: 1.5rem; }
.gs-info-txt { min-width: 0; display: flex; flex-direction: column; }
.gs-name { width: 100%; background: transparent; border: none; color: var(--text-main); font: 700 .9rem 'Outfit', 'Cairo', sans-serif; padding: 0; outline: none; border-bottom: 1px dashed transparent; }
.gs-name:hover, .gs-name:focus { border-bottom-color: var(--border-strong); }
.gs-score { font: 800 1.7rem/1 'Outfit', 'Cairo', sans-serif; display: inline-block; transform-origin: left center; }
.gs-crown { font-size: 1rem; display: inline-block; animation: gsCrown 1.6s ease-in-out infinite; }

.gs-cell { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.gs-cell-lbl { display: none; }
.gs-cell button { height: 38px; padding: 0; border: none; border-radius: 9px; color: #fff; font: 800 1.15rem 'Outfit', 'Cairo', sans-serif; cursor: pointer; transition: transform .08s, filter .12s; }
.gs-cell button:active { transform: scale(.9); }
.gs-cell button:hover { filter: brightness(1.2); }
.gs-p { background: linear-gradient(135deg, #10b981, #059669); }
.gs-m { background: linear-gradient(135deg, #f87171, #dc2626); }

/* Feedback */
.gs-bump { animation: gsBump .55s cubic-bezier(.2,1.6,.4,1); color: #86efac; }
.gs-drop { animation: gsDrop .5s ease; color: #fca5a5; }
.gs-happy { animation: gsGlow .7s ease; }
.gs-sad { animation: gsShake .45s ease; }
@keyframes gsBump { 0% { transform: scale(1); } 40% { transform: scale(1.4) rotate(-3deg); } 100% { transform: scale(1); } }
@keyframes gsDrop { 0% { transform: translateY(0); } 40% { transform: translateY(8px) scale(.85); } 100% { transform: translateY(0); } }
@keyframes gsGlow { 0% { box-shadow: 0 0 0 0 rgba(250,204,21,.85); } 100% { box-shadow: 0 0 0 20px rgba(250,204,21,0); } }
@keyframes gsShake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes gsCrown { 0%,100% { transform: rotate(-10deg); } 50% { transform: rotate(10deg) translateY(-2px); } }

.gs-float { position: absolute; left: 50%; top: 0; display: flex; align-items: center; gap: 8px; pointer-events: none; z-index: 5; white-space: nowrap;
    padding: 4px 12px 4px 8px; border-radius: 999px; background: var(--bg-surface-solid); border: 1px solid var(--border-strong); color: var(--text-main); box-shadow: 0 6px 20px rgba(0,0,0,.4); font-size: .85rem; }
.gs-float-emoji { font-size: 2.1rem; line-height: 1; }
.gs-float b { font-size: 1.1rem; }
.gs-float-up { animation: gsUp 1.3s ease-out forwards; color: #16a34a; }
.gs-float-down { animation: gsDown 1.3s ease-in forwards; color: #dc2626; }
@keyframes gsUp { 0% { opacity: 0; transform: translate(-50%, 0) scale(.5); } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -170%) scale(1); } }
@keyframes gsDown { 0% { opacity: 0; transform: translate(-50%, -140%) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -110%) scale(1); } 100% { opacity: 0; transform: translate(-50%, 20%) scale(.9); } }

.gs-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gs-count { display: flex; align-items: center; gap: 6px; background: var(--bg-item); border-radius: 12px; padding: 4px 8px; font-size: .8rem; font-weight: 600; }
.gs-count span { opacity: .7; }
.gs-count b { min-width: 18px; text-align: center; font-size: 1rem; }
.gs-step { width: 26px; height: 26px; border-radius: 8px; border: none; background: var(--primary); color: var(--text-on-accent, #fff); font-size: 1rem; font-weight: 700; cursor: pointer; }
.gs-step:hover { background: var(--primary-hover); }
.gs-finish { background: var(--primary); border: none; color: var(--text-on-accent, #fff); padding: 9px 14px; border-radius: 12px; font: 700 .85rem 'Outfit', 'Cairo', sans-serif; cursor: pointer; box-shadow: 0 6px 18px rgba(245,158,11,.3); }
.gs-finish:hover { filter: brightness(1.1); }

/* Winners screen (full screen for the big moment) */
.gs-results { position: fixed; inset: 0; height: 100vh; height: 100dvh; display: none; z-index: 2147483639; background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--primary) 28%, var(--bg-app)) 0%, var(--bg-app) 70%);  color: var(--text-main); font-family: 'Outfit', 'Cairo', 'Inter', sans-serif;  }
.gs-results.show { display: block; }
.gs-res-scroll { height: 100%; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; align-items: center; padding: 24px 16px 32px; gap: 18px; box-sizing: border-box; }
.gs-res-card {
    width: min(640px, 100%); box-sizing: border-box; text-align: center; padding: 30px 28px 22px; border-radius: 28px;
    background: var(--bg-surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow-main, 0 20px 60px rgba(0,0,0,.5));
}
.gs-res-activity { font: 600 1.1rem 'Outfit', 'Cairo', sans-serif; opacity: .85; letter-spacing: .5px; }
.gs-res-trophy { font-size: 5rem; line-height: 1.1; animation: gsTrophy 1.8s ease-in-out infinite; }
.gs-res-label { font: 700 1rem 'Outfit', 'Cairo', sans-serif; text-transform: uppercase; letter-spacing: 4px; color: var(--primary); }
.gs-res-winner { font: 800 clamp(2rem, 6vw, 3.4rem)/1.1 'Outfit', 'Cairo', sans-serif; margin: 6px 0; text-shadow: 0 4px 18px rgba(0,0,0,.35); }
.gs-res-score { font: 600 1.3rem 'Outfit', 'Cairo', sans-serif; color: var(--primary); margin-bottom: 8px; }
.gs-res-skills { font: 500 .95rem 'Outfit', 'Cairo', sans-serif; background: var(--bg-item); border-radius: 999px; display: inline-block; padding: 6px 16px; margin-bottom: 16px; }
.gs-res-skills b { color: var(--primary); }
.gs-res-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.gs-res-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 14px; background: var(--bg-item); border-left: 6px solid var(--gc); text-align: left; }
.gs-res-row.first { background: color-mix(in srgb, var(--primary) 24%, var(--bg-item)); }
.gs-res-rank { font-size: 1.9rem; line-height: 1; min-width: 40px; text-align: center; font-weight: 700; }
.gs-res-name { flex: 1; font: 700 1.15rem 'Outfit', 'Cairo', sans-serif; display: flex; flex-direction: column; }
.gs-res-name small { font: 500 .78rem 'Outfit', 'Cairo', sans-serif; opacity: .75; }
.gs-res-pts { font: 800 1.6rem 'Outfit', 'Cairo', sans-serif; }
.gs-res-date { margin-top: 16px; opacity: .6; font-size: .8rem; }
.gs-res-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.gs-res-btn { padding: 13px 24px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--bg-item); color: var(--text-main); font: 600 1rem 'Outfit', 'Cairo', sans-serif; cursor: pointer; }
.gs-res-btn.primary { background: var(--primary); color: var(--text-on-accent, #fff); border: none; }
.gs-res-btn:hover { filter: brightness(1.15); }
@keyframes gsTrophy { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }

@media (max-width: 640px) {
    .gs-panel { top: 8px; right: 6px; left: 6px; width: auto; max-width: none; max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
    .gs-header { flex-wrap: wrap; row-gap: 8px; }
    .gs-header input { flex: 1 1 100%; order: -1; font-size: 1.1rem; }
    .gs-trophy-ico { order: -2; }
    .gs-header .gs-icon-btn { flex: 1; }
    .gs-head { display: none; }
    .gs-row[data-i] { grid-template-columns: 1fr; gap: 6px; }
    .gs-cells { grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; }
    .gs-cell { grid-template-columns: 1fr 1fr; gap: 4px; }
    .gs-cell-lbl { display: block; grid-column: 1 / -1; font-size: .72rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
    .gs-cell-lbl b { background: var(--primary); color: var(--text-on-accent, #1e293b); border-radius: 999px; padding: 0 6px; margin-left: 2px; }
    .gs-info { justify-content: space-between; }
    .gs-info-txt { flex: 1; flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
    .gs-name { flex: 1; font-size: 1rem; }
    .gs-footer { flex-wrap: wrap; }
}

/* Touch friendliness: no tap flash/selection, no double-tap zoom delay, larger targets on coarse pointers */
.gs-panel button, .gs-handle, .gs-results button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.gs-cat-editor { touch-action: pan-y; overscroll-behavior: contain; overflow-y: auto; max-height: 40vh; }
@media (pointer: coarse) {
    .gs-panel { gap: 10px; padding: 12px 14px 14px; }
    .gs-icon-btn { width: 42px; height: 42px; font-size: 1rem; }
    .gs-cell button { height: 52px; font-size: 1.4rem; border-radius: 12px; }
    .gs-cells, .gs-cell { gap: 6px; }
    .gs-step { width: 42px; height: 42px; font-size: 1.3rem; }
    .gs-finish { padding: 14px 18px; font-size: 1rem; border-radius: 14px; }
    .gs-handle { width: 54px; height: 64px; }
    .gs-res-btn { padding: 16px 28px; font-size: 1.1rem; min-height: 54px; }
    .gs-cat-row input, .gs-header input, .gs-name { font-size: 16px; }
    .gs-ce-del { padding: 10px 12px; }
    .gs-ce-add { padding: 12px; }
    .gs-chead-name { font-size: .7rem; }
}

/* Contrast: names + numbers always use the theme text colour (theme overrides can force white on these) */
.gs-results, .gs-res-card, .gs-res-activity, .gs-res-winner, .gs-res-rank,
.gs-res-name, .gs-res-pts, .gs-res-date, .gs-res-skills, .gs-res-name small {
    color: var(--text-main, #1e293b) !important; -webkit-text-fill-color: var(--text-main, #1e293b) !important;
}
.gs-res-label, .gs-res-score, .gs-res-skills b {
    color: var(--primary-hover, var(--primary)) !important; -webkit-text-fill-color: var(--primary-hover, var(--primary)) !important;
}
.gs-res-winner { text-shadow: none !important; }
.gs-res-name small, .gs-res-date, .gs-res-activity { opacity: .8; }
.gs-res-btn { color: var(--text-main) !important; -webkit-text-fill-color: var(--text-main) !important; }
.gs-res-btn.primary { color: var(--text-on-accent, #fff) !important; -webkit-text-fill-color: var(--text-on-accent, #fff) !important; }
.gs-panel, .gs-header input, .gs-name, .gs-score, .gs-chead-name, .gs-cell-lbl, .gs-count, .gs-cat-row input, .gs-ce-name, .gs-ce-pts, .gs-ce-icon {
    color: var(--text-main) !important; -webkit-text-fill-color: var(--text-main) !important;
}
.gs-cell button, .gs-chead-pts, .gs-step, .gs-finish { -webkit-text-fill-color: currentColor !important; }
.gs-cell button { color: #fff !important; }
.gs-chead-pts, .gs-cell-lbl b { color: var(--text-on-accent, #1e293b) !important; -webkit-text-fill-color: var(--text-on-accent, #1e293b) !important; }
.gs-step, .gs-finish { color: var(--text-on-accent, #fff) !important; }
