:root {
  --bg: #f3f6fb;
  --bg2: #e8eef7;
  --card: #ffffff;
  --card-border: #dde5f0;
  --text: #0f2240;
  --muted: #5b6b85;
  --navy: #0f2a4a;
  --green: #0f9d58;
  --green-2: #22c55e;
  --red: #e5484d;
  --gold: #d4a017;
  --gold-2: #f2c94c;
  --accent: #1d6fe0;
  --danger: #e5484d;
  --ok: #0f9d58;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(15, 42, 74, 0.08);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Tajawal', Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.6;
  overflow-x: hidden;
  display: flex; flex-direction: column; min-height: 100vh;
}
/* خلفية فوركس: شبكة رسم بياني + شموع خفيفة */
.sky {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(900px 500px at 90% -10%, rgba(29, 111, 224, 0.10), transparent 60%),
    radial-gradient(800px 500px at 0% 110%, rgba(15, 157, 88, 0.10), transparent 60%),
    linear-gradient(180deg, #f7f9fd 0%, #eef3fa 100%);
}
.sky::before {
  content: ''; position: absolute; inset: 0; opacity: 0.55;
  background-image:
    linear-gradient(rgba(15, 42, 74, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 42, 74, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
}
.sky::after {
  content: ''; position: absolute; inset: 0; opacity: 0.22;
  background-repeat: no-repeat; background-position: bottom left; background-size: 100% auto;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1400 320' preserveAspectRatio='none'%3E%3Cpolyline fill='none' stroke='%230f9d58' stroke-width='3' points='0,260 120,230 220,245 330,190 430,205 540,150 640,170 750,120 860,135 970,90 1080,105 1190,60 1300,75 1400,30'/%3E%3Cpolygon fill='%230f9d58' fill-opacity='0.08' points='0,260 120,230 220,245 330,190 430,205 540,150 640,170 750,120 860,135 970,90 1080,105 1190,60 1300,75 1400,30 1400,320 0,320'/%3E%3Cg stroke-width='2'%3E%3Cg stroke='%230f9d58' fill='%230f9d58'%3E%3Crect x='300' y='200' width='12' height='40'/%3E%3Cline x1='306' y1='185' x2='306' y2='255'/%3E%3Crect x='700' y='130' width='12' height='45'/%3E%3Cline x1='706' y1='115' x2='706' y2='190'/%3E%3Crect x='1150' y='65' width='12' height='40'/%3E%3Cline x1='1156' y1='50' x2='1156' y2='120'/%3E%3C/g%3E%3Cg stroke='%23e5484d' fill='%23e5484d'%3E%3Crect x='500' y='150' width='12' height='35'/%3E%3Cline x1='506' y1='140' x2='506' y2='200'/%3E%3Crect x='900' y='95' width='12' height='38'/%3E%3Cline x1='906' y1='85' x2='906' y2='150'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; max-width: 1280px; margin: 0 auto; width: 100%;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy); text-decoration: none; font-weight: 900; font-size: 26px; }
.brand .star { font-size: 24px; color: var(--gold); filter: drop-shadow(0 0 8px rgba(212, 160, 23, 0.5)); animation: pulse 2.6s ease-in-out infinite; }
.brand .handle { font-size: 14px; font-weight: 500; color: var(--muted); direction: ltr; }
@keyframes pulse { 50% { transform: scale(1.18) rotate(12deg); } }
.top-right { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 15px; }

.app { max-width: 1280px; margin: 0 auto; padding: 8px 16px 40px; width: 100%; flex: 1; }

.card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.card h2 { margin: 0 0 6px; font-size: 24px; color: var(--navy); }
.card h3 { margin: 0 0 10px; font-size: 18px; color: var(--navy); }
.sub { color: var(--muted); margin: 0 0 16px; font-size: 15px; }

/* ---------- forms ---------- */
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: #fff; border: 1px solid #cfd9e6;
  border-radius: 12px; padding: 11px 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(15, 157, 88, 0.15); }
textarea { min-height: 110px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; cursor: pointer; border: none;
  border-radius: 12px; padding: 11px 18px; color: #fff;
  background: linear-gradient(135deg, var(--green), var(--green-2));
  box-shadow: 0 6px 18px rgba(15, 157, 88, 0.25); transition: transform .12s, filter .12s;
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--navy); box-shadow: none; border: 1px solid #cfd9e6; }
.btn.danger { background: #fff1f2; color: var(--red); box-shadow: none; border: 1px solid #fecdd3; }
.btn.sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.link { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

/* ---------- auth ---------- */
.auth-wrap { display: grid; place-items: center; min-height: 70vh; }
.auth { width: 100%; max-width: 440px; }
.auth .logo { text-align: center; font-size: 56px; color: var(--gold); filter: drop-shadow(0 0 16px rgba(212, 160, 23, 0.45)); margin-bottom: 0; line-height: 1.2; }
.auth .acct { text-align: center; margin: 0 0 4px; }
.auth .acct b { font-size: 34px; color: var(--navy); font-weight: 900; }
.auth .acct a { display: block; color: var(--muted); text-decoration: none; font-size: 15px; direction: ltr; }
.auth .acct a:hover { color: var(--accent); }
.tabs { display: flex; background: var(--bg2); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.tabs button { flex: 1; font: inherit; font-weight: 700; color: var(--muted); background: none; border: none; padding: 9px; border-radius: 9px; cursor: pointer; }
.tabs button.active { background: var(--navy); color: #fff; }
.otp-input { text-align: center; font-size: 30px; letter-spacing: 12px; font-weight: 800; direction: ltr; }
.hint { font-size: 14px; color: var(--muted); margin-top: 10px; }
.dev-otp { margin-top: 10px; padding: 10px; border-radius: 10px; background: #ecfdf5; border: 1px dashed #6ee7b7; color: #047857; font-size: 14px; }

/* ---------- cycles list ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 10px 0 18px; }
.page-head h1 { margin: 0; font-size: 30px; color: var(--navy); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.cycle-card { cursor: pointer; transition: transform .15s, border-color .15s; position: relative; }
.cycle-card:hover { transform: translateY(-3px); border-color: var(--green); }
.cycle-card .name { font-size: 22px; font-weight: 800; margin: 0 0 4px; color: var(--navy); }
.cycle-card .meta { color: var(--muted); font-size: 14px; }
.cycle-card .stats { display: flex; gap: 14px; margin-top: 12px; }
.stat { background: var(--bg); border-radius: 10px; padding: 8px 12px; flex: 1; text-align: center; }
.stat b { display: block; font-size: 22px; color: var(--green); line-height: 1.2; }
.stat span { font-size: 12px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty .big { font-size: 60px; }

/* ---------- cycle page ---------- */
.cycle-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.cycle-head h1 { margin: 0; font-size: 30px; color: var(--navy); }
.cycle-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-block; font-size: 13px; padding: 3px 10px; border-radius: 999px; background: #e8f0fe; color: #1a56c4; border: 1px solid #c7d8fb; }
.badge.gold { background: #fdf5dc; color: #946b00; border-color: #f2dd9a; }
.badge.ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }

.layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.9fr); gap: 18px; align-items: start; }
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }

.days { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.day {
  flex: 1; min-width: 110px; text-align: center; border-radius: 12px; padding: 8px 6px;
  background: #fff; border: 1px solid var(--card-border); font-size: 14px;
}
.day.today { border-color: var(--green); box-shadow: 0 0 0 2px rgba(15, 157, 88, 0.15); }
.day.done { background: #ecfdf5; border-color: #a7f3d0; }
.day b { display: block; font-size: 15px; color: var(--navy); }
.day small { color: var(--muted); }
.day .names { display: block; font-size: 13px; color: var(--green); font-weight: 700; margin-top: 3px; line-height: 1.4; }

.wheel-wrap { position: relative; display: grid; place-items: center; padding: 10px 0 4px; }
.wheel-wrap canvas { width: min(100%, 560px); height: auto; aspect-ratio: 1; display: block; filter: drop-shadow(0 16px 30px rgba(15, 42, 74, 0.25)); }
.pointer {
  position: absolute; top: 2px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 18px solid transparent; border-right: 18px solid transparent;
  border-top: 36px solid var(--red); filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3)); z-index: 2;
}
.wheel-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; }

.controls { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; margin-top: 10px; }
@media (max-width: 560px) { .controls { grid-template-columns: 1fr; } }
.spin-btn { font-size: 22px; padding: 16px 34px; border-radius: 16px; font-weight: 900; letter-spacing: 1px; }
.spin-btn.spinning { animation: glow 0.6s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 30px rgba(15, 157, 88, 0.6); } }

.level { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 15px; color: var(--muted); flex-wrap: wrap; }
.level .bar { flex: 1; min-width: 140px; height: 10px; border-radius: 999px; background: var(--bg2); overflow: hidden; }
.level .bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--green)); transition: width .4s; }
.level b { color: var(--green); }

.side > .card { margin-bottom: 16px; }
.add-row { display: flex; gap: 8px; align-items: flex-start; }
.add-row textarea { min-height: 72px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 260px; overflow: auto; padding: 4px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 14px; padding: 5px 10px;
  border-radius: 999px; background: var(--bg); border: 1px solid var(--card-border);
}
.chip.won { background: #fdf5dc; border-color: #f2dd9a; color: #946b00; text-decoration: line-through; }
.chip button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 0 2px; line-height: 1; }
.chip button:hover { color: var(--danger); }
.counts { display: flex; gap: 10px; font-size: 14px; color: var(--muted); margin: 8px 0 6px; }
.counts b { color: var(--text); }

table.winners { width: 100%; border-collapse: collapse; font-size: 15px; }
table.winners th, table.winners td { padding: 8px 6px; border-bottom: 1px solid var(--card-border); text-align: right; }
table.winners th { color: var(--muted); font-weight: 500; font-size: 13px; }
table.winners td.name { font-weight: 700; color: var(--green); }
table.winners tr.pending td { color: var(--muted); font-style: italic; }
table.winners .x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; }
table.winners .x:hover { color: var(--danger); }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 34, 64, 0.5); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 520px; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } }
.winner-modal { text-align: center; padding: 34px 26px; border-color: var(--gold-2); }
.winner-modal .crown { font-size: 64px; }
.winner-modal .wname { font-size: 44px; font-weight: 900; color: var(--green); margin: 6px 0 2px; word-break: break-word; }
.winner-modal .wmeta { color: var(--muted); font-size: 16px; }
.winner-modal .hold { margin: 16px auto 20px; display: inline-block; padding: 8px 16px; border-radius: 12px; background: #fdf5dc; border: 1px solid #f2dd9a; color: #946b00; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 30px); opacity: 0; transition: .25s; background: var(--navy); color: #fff; border-radius: 12px; padding: 10px 18px; z-index: 60; max-width: 90vw; font-size: 15px; box-shadow: var(--shadow); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; }

.history-round { margin-bottom: 14px; }
.history-round h4 { margin: 0 0 6px; color: var(--navy); font-size: 16px; }

/* ---------- footer ---------- */
.footer {
  border-top: 1px solid var(--card-border); background: rgba(255, 255, 255, 0.7);
  padding: 16px 24px; text-align: center; color: var(--muted); font-size: 14px;
}
.footer a { color: var(--navy); font-weight: 700; text-decoration: none; }
.footer a:hover { color: var(--green); text-decoration: underline; }
.footer .tt { display: inline-flex; align-items: center; gap: 6px; margin-inline-start: 14px; direction: ltr; }
