:root {
  --bg: #f7f4ec;
  --bg-2: #efeadc;
  --card: #fffdf7;
  --ink: #26362f;
  --muted: #6c7a72;
  --primary: #1f5c4a;
  --primary-2: #2b7561;
  --gold: #b99a5b;
  --line: #e4dec9;
  --red: #b4574c;
  --yellow: #d4a63c;
  --green: #3f8a63;
  --blue: #3f6f9f;
  --radius: 18px;
  --shadow: 0 8px 28px rgba(38, 54, 47, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
  margin: 0;
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%23b99a5b' stroke-opacity='.13' stroke-width='1'%3E%3Cpath d='M40 6l9.9 24.1L74 40l-24.1 9.9L40 74l-9.9-24.1L6 40l24.1-9.9z'/%3E%3Ccircle cx='40' cy='40' r='9'/%3E%3C/g%3E%3C/svg%3E");
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; padding-top: 28px; padding-bottom: 48px; }
.wrap { width: min(1140px, 92%); margin: 0 auto; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-2); }
h1, h2, h3 { font-family: 'Amiri', Georgia, serif; color: var(--primary); line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: 1.7rem; }

/* ---------- header ---------- */
.site-header {
  background: linear-gradient(180deg, var(--primary) 0%, #19493b 100%);
  color: #f3eedb;
  border-bottom: 3px solid var(--gold);
  position: sticky; top: 0; z-index: 50;
}
.header-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.brand:hover { color: #fff; }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.1); color: var(--gold); border: 1px solid rgba(185,154,91,.5); }
.brand-text strong { display: block; font-family: 'Amiri', serif; font-size: 1.3rem; line-height: 1.1; }
.brand-text small { color: #cfe0d6; font-size: .8rem; }
.main-nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.main-nav a { color: #eaf1ec; padding: 7px 13px; border-radius: 999px; font-weight: 600; font-size: .92rem; transition: background .2s; }
.main-nav a:hover { background: rgba(255,255,255,.14); color: #fff; }
.main-nav .nav-admin { border: 1px solid rgba(185,154,91,.7); color: var(--gold); }
.nav-red::before, .nav-yellow::before, .nav-green::before, .nav-blue::before {
  content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: 1px;
}
.nav-red::before { background: var(--red); }
.nav-yellow::before { background: var(--yellow); }
.nav-green::before { background: #6cc08f; }
.nav-blue::before { background: #7aa7d6; }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 20px 0 8px; }
.bismillah { font-family: 'Amiri', serif; font-size: 1.9rem; color: var(--gold); margin-bottom: 4px; }
.hero p { color: var(--muted); margin: 0; font-size: 1.05rem; }
.year-chip { display: inline-block; margin-top: 12px; padding: 4px 16px; border: 1px solid var(--gold); border-radius: 999px; color: #8a6f36; font-size: .85rem; font-weight: 700; background: rgba(185,154,91,.1); }
.ornament { display: flex; align-items: center; justify-content: center; gap: 14px; color: var(--gold); margin: 22px 0 6px; }
.ornament span { height: 1px; width: min(180px, 25%); background: linear-gradient(90deg, transparent, var(--gold)); }
.ornament span:last-child { transform: scaleX(-1); }

/* ---------- house cards ---------- */
.house-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 22px; margin: 28px 0; }
.house-card {
  --hc: var(--primary);
  position: relative; display: block; text-align: center; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 18px 22px; box-shadow: var(--shadow); overflow: hidden;
  transition: transform .25s, box-shadow .25s;
}
.house-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 7px; background: var(--hc); }
.house-card::after {
  content: ''; position: absolute; right: -40px; bottom: -40px; width: 130px; height: 130px; border-radius: 50%;
  background: var(--hc); opacity: .07;
}
.house-card:hover { transform: translateY(-5px); box-shadow: 0 14px 34px rgba(38,54,47,.14); color: var(--ink); }
.house-red { --hc: var(--red); } .house-yellow { --hc: var(--yellow); }
.house-green { --hc: var(--green); } .house-blue { --hc: var(--blue); }
.leader-badge { position: absolute; top: 14px; right: 14px; background: var(--hc); color: #fff; font-size: .7rem; font-weight: 800; letter-spacing: .05em; padding: 3px 10px; border-radius: 999px; }
.ring-wrap { position: relative; width: 140px; height: 140px; margin: 6px auto 12px; }
.ring-wrap svg.ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--bg-2); stroke-width: 8; }
.ring-fg { fill: none; stroke: var(--hc); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 2.2s cubic-bezier(.22,.8,.3,1); }
.ring-symbol { position: absolute; inset: 0; display: grid; place-items: center; color: var(--hc); }
.house-card h3 { font-size: 1.45rem; margin-bottom: 2px; }
.points-num { font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 2.5rem; color: var(--hc); line-height: 1.1; font-variant-numeric: tabular-nums; }
.points-label { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .1em; }
.card-link { margin-top: 12px; font-weight: 700; font-size: .9rem; color: var(--hc); }

/* ---------- panels ---------- */
.grid-2 { display: grid; grid-template-columns: 1.1fr 1fr; gap: 22px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 22px; }
.panel h2 { display: flex; align-items: center; gap: 10px; }

.standings { list-style: none; padding: 0; margin: 0; }
.standings li { display: grid; grid-template-columns: 34px 1fr 90px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.standings li:last-child { border: 0; }
.pos { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-2); font-weight: 800; color: var(--primary); }
.standings li:first-child .pos { background: var(--gold); color: #fff; }
.bar-track { height: 10px; background: var(--bg-2); border-radius: 99px; overflow: hidden; margin-top: 5px; }
.bar-fill { height: 100%; border-radius: 99px; width: 0; transition: width 2.2s cubic-bezier(.22,.8,.3,1); }
.s-pts { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }

.recent { list-style: none; padding: 0; margin: 0; }
.recent li { padding: 10px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 12px; align-items: center; }
.recent li:last-child { border: 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.recent .who { font-weight: 700; }
.recent small { color: var(--muted); display: block; }
.recent .pts { margin-left: auto; font-weight: 800; color: var(--primary); white-space: nowrap; }

/* ---------- tables ---------- */
.table-tools { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table.grid { width: 100%; border-collapse: collapse; background: var(--card); min-width: 760px; }
table.grid th { background: var(--primary); color: #f3eedb; text-align: left; font-size: .82rem; letter-spacing: .06em; text-transform: uppercase; padding: 12px 14px; white-space: nowrap; }
table.grid td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tbody tr:nth-child(even) { background: #faf7ee; }
table.grid tbody tr:hover { background: #f0f5ef; }
.badge { display: inline-block; padding: 2px 11px; border-radius: 999px; font-size: .8rem; font-weight: 800; background: var(--bg-2); color: var(--primary); }
.rank-1 { background: #f3e3ae; color: #7a5a0c; }
.rank-2 { background: #e3e8e6; color: #44504b; }
.rank-3 { background: #efd6c2; color: #7b4a28; }
.type-team { background: #dcebe4; color: var(--primary); }
.type-individual { background: #e4e9f3; color: #35507c; }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.dash { color: #b3b9b5; }

/* ---------- house detail ---------- */
.house-hero { --hc: var(--primary); display: flex; align-items: center; gap: 26px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-top: 8px solid var(--hc); border-radius: var(--radius); padding: 24px 28px; box-shadow: var(--shadow); margin-bottom: 22px; }
.house-hero .ring-wrap { margin: 0; }
.house-hero h1 { color: var(--hc); margin: 0; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; margin-left: auto; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 10px 18px; text-align: center; min-width: 110px; }
.stat b { display: block; font-size: 1.5rem; color: var(--hc); font-variant-numeric: tabular-nums; }
.stat span { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* ---------- forms / buttons ---------- */
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #d5cfba; border-radius: 12px; padding: 10px 14px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,92,74,.25); border-color: var(--primary); }
.table-tools input, .table-tools select { width: auto; flex: 1 1 200px; }
label { font-weight: 700; font-size: .9rem; display: block; margin-bottom: 5px; }
.field { margin-bottom: 16px; }
.field small { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px; }
.btn { display: inline-block; font: inherit; font-weight: 700; cursor: pointer; border: 0; background: var(--primary); color: #fff; padding: 11px 24px; border-radius: 999px; transition: background .2s, transform .1s; }
.btn:hover { background: var(--primary-2); color: #fff; }
.btn:active { transform: scale(.98); }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); }
.btn-danger { background: #a94b44; }
.btn-danger:hover { background: #8e3c36; }
.btn-sm { padding: 5px 14px; font-size: .82rem; }
.flash { padding: 12px 18px; border-radius: 12px; margin-bottom: 18px; font-weight: 600; }
.flash-ok { background: #def0e5; color: #1c5a3b; border: 1px solid #b7dcc6; }
.flash-err { background: #f6dedb; color: #8a2f27; border: 1px solid #e8bab5; }

/* type chooser */
.type-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 22px; }
.type-choice label { position: relative; margin: 0; }
.type-choice input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.type-choice input:focus-visible + .type-card { outline: 2px solid var(--primary); outline-offset: 2px; }
.type-card { display: block; cursor: pointer; border: 2px solid var(--line); border-radius: 16px; padding: 18px 20px; background: #fff; transition: all .2s; }
.type-card b { display: block; font-family: 'Amiri', serif; font-size: 1.3rem; color: var(--primary); }
.type-card span { color: var(--muted); font-size: .88rem; }
.type-choice input:checked + .type-card { border-color: var(--primary); background: #eaf3ee; box-shadow: 0 0 0 3px rgba(31,92,74,.12); }
.points-preview { display: inline-block; background: #eaf3ee; border: 1px dashed var(--primary); color: var(--primary); font-weight: 800; padding: 8px 18px; border-radius: 12px; }

.login-box { max-width: 420px; margin: 40px auto; }
.dash-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.mini { --hc: var(--primary); background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--hc); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); }
.mini b { display: block; font-size: 1.9rem; color: var(--hc); font-variant-numeric: tabular-nums; }
.mini span { color: var(--muted); font-size: .85rem; }
.actions { display: flex; gap: 6px; }
.note { background: #fbf3dc; border: 1px solid #ecd9a0; color: #765b13; border-radius: 12px; padding: 12px 16px; margin-bottom: 18px; }

/* ---------- footer ---------- */
.site-footer { background: var(--bg-2); border-top: 1px solid var(--line); text-align: center; padding: 8px 0 26px; color: var(--muted); font-size: .9rem; }
.site-footer .ornament { margin-top: 14px; }
.site-footer p { margin: 0; }

@media (max-width: 640px) {
  .main-nav a { padding: 6px 10px; font-size: .85rem; }
  .stats { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ring-fg, .bar-fill { transition: none; }
}