/* ============================================================
   Torneig Barracot CUP — full d'estils
   Identitat basada en el cartell de les festes: taronja vibrant,
   marró fosc, blancs càlids, formes ben arrodonides i to festiu.
   Responsive (mobile-first).
   ============================================================ */

:root {
    --bg:        #fbf3ea;   /* crema càlid de fons */
    --bg-2:      #f5e9da;   /* panell càlid suau */
    --surface:   #ffffff;   /* targetes */
    --surface-2: #fdf2e7;   /* tessel·les / xips de marcador */
    --border:    #efe1d0;
    --text:      #2e2823;   /* marró fosc del cartell */
    --muted:     #93826f;
    --primary:   #e8642a;   /* taronja Barracot */
    --primary-d: #cb5318;
    --accent:    #c9531a;   /* enllaços sobre blanc */
    --dark:      #2e2823;   /* marró fosc (barra superior, badges) */
    --danger:    #d6453f;
    --warning:   #e0962a;
    --radius:    20px;
    --radius-sm: 12px;
    --shadow:    0 8px 26px rgba(46,40,35,.10);
    --shadow-sm: 0 3px 12px rgba(46,40,35,.08);
    --font:      'Nunito', system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-display: 'Fredoka', 'Nunito', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }

h1, h2, h3 { line-height: 1.2; font-family: var(--font-display); font-weight: 600; letter-spacing: .01em; }
h2 { font-size: 1.25rem; margin: 0 0 14px; }
.page-title { font-size: 1.7rem; margin: 22px 0 16px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.al { text-align: left !important; }

/* ---------- Barra superior / navegació ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    background: var(--dark);
    border-bottom: 3px solid var(--primary);
}
.admin-topbar { background: var(--dark); }
.topbar-inner { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.brand {
    display: flex; align-items: center; gap: 9px; font-family: var(--font-display);
    font-weight: 700; color: #fff; font-size: 1.15rem; letter-spacing: .01em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    font-size: 1.1rem; background: var(--primary); width: 34px; height: 34px;
    border-radius: 50%; display: grid; place-items: center; flex: 0 0 34px;
}
.mainnav { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.mainnav a {
    color: rgba(255,255,255,.82); padding: 8px 13px; border-radius: 999px; font-size: .95rem; font-weight: 600;
}
.mainnav a:hover { color: #fff; background: rgba(255,255,255,.12); text-decoration: none; }
.mainnav a.is-active { color: #fff; background: var(--primary); }
.nav-admin { color: #ffb98f !important; }
.nav-toggle {
    display: none; margin-left: auto; background: rgba(255,255,255,.12); color: #fff;
    border: 0; border-radius: 10px; font-size: 1.2rem; padding: 7px 13px; cursor: pointer;
}

/* ---------- Hero / capçaleres ---------- */
.hero {
    background: var(--primary);
    border-radius: 24px;
    padding: 28px 24px; margin: 22px 0; box-shadow: var(--shadow);
    color: #fff; position: relative; overflow: hidden;
}
.hero::after {
    content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px;
    background: rgba(255,255,255,.10); border-radius: 50%;
}
.hero h1 { margin: 0; font-size: 2.1rem; font-weight: 700; color: #fff; }
.hero-sub { color: rgba(255,255,255,.9); margin: 4px 0 0; font-weight: 600; }

.stat-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; position: relative; z-index: 1; }
.stat {
    flex: 1 1 90px; background: rgba(255,255,255,.16); border: 0;
    border-radius: 16px; padding: 13px; text-align: center; display: flex; flex-direction: column; gap: 2px;
}
.stat-num { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; color: #fff; }
.stat span:last-child { font-size: .76rem; color: rgba(255,255,255,.88); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }

/* Estadístiques a l'admin (sobre fons crema) */
.admin-stats .stat { background: var(--surface); border: 1px solid var(--border); }
.admin-stats .stat-num { color: var(--primary); }
.admin-stats .stat span:last-child { color: var(--muted); }

/* ---------- Targetes ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.card-head h2 { margin: 0; }
.link { font-size: .92rem; font-weight: 700; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-form { display: grid; grid-template-columns: 360px 1fr; gap: 18px; align-items: start; }

/* ---------- Taules ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th, .table td { padding: 10px 8px; text-align: center; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.table tbody tr:hover { background: var(--bg-2); }
.table .pos { color: var(--muted); font-weight: 700; width: 30px; }
.table .pts { font-weight: 800; color: var(--primary); }
.table-standings tbody tr:first-child .pos {
    color: #fff; background: var(--primary); border-radius: 50%;
}
.legend { font-size: .78rem; margin-top: 10px; }

/* ---------- Llistes de partits / golejadors ---------- */
.match-row {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
    padding: 11px 0; border-bottom: 1px solid var(--border);
}
.match-row:last-child { border-bottom: 0; }
.m-team { font-weight: 700; }
.m-home { text-align: right; }
.m-away { text-align: left; }
.m-score { font-family: var(--font-display); font-weight: 700; background: var(--dark); color: #fff; padding: 3px 11px; border-radius: 999px; }
.m-mid { color: var(--muted); font-size: .82rem; text-align: center; font-weight: 600; }

.scorer-list { list-style: none; counter-reset: s; margin: 0; padding: 0; }
.scorer-list li {
    counter-increment: s; display: flex; align-items: center; gap: 10px;
    padding: 10px 0; border-bottom: 1px solid var(--border);
}
.scorer-list li:last-child { border-bottom: 0; }
.scorer-list li::before {
    content: counter(s); width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%;
    background: var(--surface-2); color: var(--primary); font-size: .8rem; font-weight: 800;
    display: grid; place-items: center; border: 1px solid var(--border);
}
.scorer-list li:first-child::before { background: var(--primary); color: #fff; border-color: var(--primary); }
.sc-name { font-weight: 700; }
.sc-goals { margin-left: auto; font-family: var(--font-display); font-weight: 700; color: var(--primary); }

/* ---------- Graella de partits (calendari / resultats) ---------- */
.match-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.match-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 15px; position: relative; box-shadow: var(--shadow-sm);
}
.mc-teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; margin: 8px 0; }
.mc-team { font-weight: 700; text-align: center; font-size: .95rem; }
.mc-team.winner { color: var(--primary); }
.mc-score { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; }
.mc-vs { color: var(--muted); font-size: .85rem; font-weight: 700; }
.mc-meta { font-size: .82rem; display: flex; gap: 8px; justify-content: center; align-items: center; font-weight: 600; }
.group-title { margin: 24px 0 10px; color: var(--primary); font-size: 1.15rem; }

/* ---------- Equips ---------- */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.team-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 12px; display: flex; flex-direction: column; align-items: center; gap: 9px; color: var(--text);
    transition: transform .12s, box-shadow .12s; box-shadow: var(--shadow-sm);
}
.team-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); text-decoration: none; }
.team-badge {
    width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
    background: var(--primary); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 1.5rem;
}
.team-badge.big { width: 74px; height: 74px; font-size: 2rem; }
.team-name { font-weight: 700; text-align: center; }
.team-header { display: flex; align-items: center; gap: 16px; margin: 16px 0 20px; }
.team-header h1 { margin: 0; }

/* ---------- Etiquetes / badges ---------- */
.tag {
    display: inline-block; background: var(--surface-2); color: var(--primary-d);
    font-size: .72rem; padding: 3px 10px; border-radius: 999px; font-weight: 700; border: 1px solid var(--border);
}
.badge { display: inline-block; font-size: .72rem; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 700; }
.badge-done { background: var(--primary); color: #fff; }

/* ---------- Botons ---------- */
.btn {
    display: inline-block; cursor: pointer; border: 1.5px solid var(--border);
    background: var(--surface); color: var(--text); padding: 10px 18px;
    border-radius: 12px; font-size: .94rem; font-weight: 700; font-family: var(--font);
    text-align: center; transition: transform .1s, filter .12s, background .12s;
}
.btn:hover { filter: brightness(.98); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); filter: none; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .82rem; border-radius: 9px; border-width: 1.5px; }
.btn-lg { padding: 15px 30px; font-size: 1.1rem; border-radius: 14px; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Formularis ---------- */
label { display: block; font-size: .88rem; font-weight: 700; margin-bottom: 12px; color: var(--text); }
input, select, textarea {
    width: 100%; margin-top: 5px; padding: 11px 13px; font-size: 1rem; font-family: var(--font); font-weight: 600;
    background: var(--bg); color: var(--text); border: 1.5px solid var(--border); border-radius: 12px;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(232,100,42,.25); border-color: var(--primary); background: #fff; }
.check { display: flex; align-items: center; gap: 9px; }
.check input { width: auto; margin: 0; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.filterbar { margin: 0 0 18px; }
.filter-form { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.filter-form label { margin-bottom: 0; }

/* ---------- Flash ---------- */
.flash { padding: 13px 17px; border-radius: 12px; margin: 14px 0; font-weight: 700; border: 1.5px solid; }
.flash-success { background: #fdf2e7; border-color: var(--primary); color: var(--primary-d); }
.flash-error { background: #fbeae9; border-color: var(--danger); color: #a8302b; }

/* ---------- Estats buits ---------- */
.empty {
    background: var(--surface); border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 34px 22px; text-align: center; color: var(--muted); margin: 22px 0;
    display: flex; flex-direction: column; gap: 14px; align-items: center; font-weight: 600;
}

/* ---------- Accés (login) ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: var(--primary); }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 32px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.login-box h1 { font-size: 1.4rem; margin: 6px 0 18px; }
.login-brand { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; display: flex; align-items: center; gap: 8px; }

/* ---------- Tauler (dashboard) ---------- */
.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.action-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text); font-weight: 700;
    box-shadow: var(--shadow-sm); transition: transform .12s, box-shadow .12s;
}
.action-card span { font-size: 1.9rem; }
.action-card:hover { box-shadow: var(--shadow); text-decoration: none; transform: translateY(-2px); }

/* ---------- Resultat de partit ---------- */
.result-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; text-align: center; gap: 10px; background: var(--dark); color: #fff; border-color: var(--dark); }
.result-head .rh-team { color: #fff; }
.rh-team { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.rh-score { font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.rh-vs .muted { color: rgba(255,255,255,.7); }
.score-inputs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: end; max-width: 460px; }
.score-sep { font-size: 1.6rem; font-weight: 800; padding-bottom: 10px; font-family: var(--font-display); }
.goal-row { display: grid; grid-template-columns: 1fr 84px; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-weight: 600; }
.goal-row:last-child { border-bottom: 0; }
.goal-row input { margin: 0; text-align: center; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 45%); padding: 16px 0; }
.reset-form { margin-top: 8px; }
.back { display: inline-block; margin: 6px 0 14px; color: var(--muted); font-weight: 700; }

/* ---------- Peu ---------- */
.sitefooter { border-top: 1px solid var(--border); margin-top: 40px; padding: 24px 0; text-align: center; background: var(--bg-2); }
.sitefooter p { margin: 2px 0; font-size: .88rem; font-weight: 600; }

/* ---------- Premis ---------- */
.award-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin: 6px 0 18px; }
.award-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px 16px; text-align: center; box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.award-card:first-child { border-color: var(--primary); }
.award-icon { font-size: 2.4rem; line-height: 1; margin-bottom: 4px; }
.award-label { font-family: var(--font-display); font-weight: 600; color: var(--muted); text-transform: uppercase; font-size: .8rem; letter-spacing: .04em; }
.award-name { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; }
.award-extra { margin-top: 6px; background: var(--primary); color: #fff; font-weight: 700; font-size: .82rem; padding: 3px 12px; border-radius: 999px; }

/* ---------- Eliminatòries (quadre) ---------- */
.ko-rounds { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; align-items: start; }
.ko-round {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow-sm);
}
.ko-round.is-final { border-color: var(--primary); border-width: 2px; }
.ko-title { margin: 0 0 12px; font-size: 1.05rem; color: var(--primary); }
.ko-match {
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 12px; margin-bottom: 12px;
}
.ko-match:last-child { margin-bottom: 0; }
.ko-side { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; }
.ko-side + .ko-side { border-top: 1px dashed var(--border); }
.ko-team { font-weight: 700; }
.ko-side.winner .ko-team { color: var(--primary); }
.ko-sc { font-family: var(--font-display); font-weight: 700; min-width: 22px; text-align: center; }
.ko-side.winner .ko-sc { background: var(--primary); color: #fff; border-radius: 6px; }
.ko-meta { margin-top: 8px; font-size: .8rem; display: flex; gap: 8px; align-items: center; justify-content: space-between; font-weight: 600; }

/* ============================================================
   RESPONSIVE — mòbil i tauleta
   ============================================================ */
@media (max-width: 860px) {
    .grid-2, .grid-form { grid-template-columns: 1fr; }
    .nav-toggle { display: block; }
    .mainnav {
        display: none; width: 100%; flex-direction: column; align-items: stretch;
        gap: 2px; padding: 10px 0; order: 3;
    }
    body.nav-open .mainnav { display: flex; }
    .topbar-inner { flex-wrap: wrap; }
    .mainnav a { padding: 13px; border-radius: 12px; }
}

@media (max-width: 560px) {
    .hero h1 { font-size: 1.6rem; }
    .page-title { font-size: 1.45rem; }
    .form-row-3 { grid-template-columns: 1fr; }
    .stat-num { font-size: 1.45rem; }
    .actions { justify-content: flex-start; }
    .btn { padding: 12px 18px; }
    .table th, .table td { padding: 9px 6px; font-size: .88rem; }
    .m-team, .mc-team { font-size: .92rem; }
}
