:root{
    --bg-1:#082024;
    --bg-2:#0c3436;
    --panel:#0f3d3e;
    --panel-edge:#155052;
    --gold:#e8b54d;
    --gold-dim:#b9903a;
    --cream:#f6efe0;
    --muted:#9fc0bc;
    --danger:#e4572e;
    --ok:#5fb98a;
    --digit-h: clamp(46px, 14vw, 108px);
    --digit-w: clamp(34px, 10vw, 78px);
    font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  }
  *{box-sizing:border-box;}
  html,body{
    margin:0; min-height:100vh;
    background:
      radial-gradient(1200px 600px at 50% -10%, rgba(232,181,77,0.10), transparent 60%),
      linear-gradient(180deg, var(--bg-1), var(--bg-2));
    color:var(--cream);
  }
  body{
    display:flex; flex-direction:column; align-items:center;
    padding: 28px 16px 60px;
    min-height:100vh;
  }
  .eyebrow{
    color:var(--gold);
    font-weight:600;
    letter-spacing:0.02em;
    font-size:13px;
    margin-bottom:6px;
  }
  h1{
    font-size: clamp(22px, 5vw, 34px);
    margin: 0 0 6px;
    font-weight:800;
    letter-spacing:-0.01em;
    text-align:center;
  }
  .subtitle{
    color:var(--muted);
    font-size:14px;
    text-align:center;
    max-width:420px;
    margin-bottom:34px;
    line-height:1.5;
  }

  /* ---- TICKET ---- */
  .ticket{
    position:relative;
    background:linear-gradient(160deg, var(--panel), #0a2f30);
    border:1px solid var(--panel-edge);
    border-radius:20px;
    padding: 26px clamp(20px,6vw,44px) 30px;
    box-shadow: 0 30px 60px -20px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.04);
    display:flex; flex-direction:column; align-items:center;
    gap:16px;
    min-width: min(92vw, 420px);
  }
  .ticket::before, .ticket::after{
    content:"";
    position:absolute;
    width:28px; height:28px;
    background:var(--bg-1);
    border-radius:50%;
    top:50%; transform:translateY(-50%);
    box-shadow: inset 0 0 0 1px var(--panel-edge);
  }
  .ticket::before{ left:-14px; }
  .ticket::after{ right:-14px; }
  .ticket-label{
    font-size:12px;
    letter-spacing:0.14em;
    color:var(--gold);
    font-weight:700;
  }
  .divider{
    width:100%;
    border-top:2px dashed var(--panel-edge);
  }

  .reel-row{
    display:flex;
    gap:6px;
    background:#06181a;
    padding:10px;
    border-radius:12px;
    border:1px solid rgba(232,181,77,0.25);
  }
  .reel-col{
    width:var(--digit-w);
    height:var(--digit-h);
    overflow:hidden;
    position:relative;
    background:linear-gradient(180deg,#081f21,#0c2b2d);
    border-radius:6px;
  }
  .reel-col::after{
    content:"";
    position:absolute; inset:0;
    background:linear-gradient(180deg, rgba(0,0,0,0.55), transparent 30%, transparent 70%, rgba(0,0,0,0.55));
    pointer-events:none;
  }
  .reel-strip{
    display:flex;
    flex-direction:column;
    will-change:transform;
  }
  .reel-digit{
    height:var(--digit-h);
    display:flex; align-items:center; justify-content:center;
    font-variant-numeric: tabular-nums;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-weight:700;
    font-size: calc(var(--digit-h) * 0.56);
    color:var(--cream);
  }

  .draw-count{
    font-size:12px;
    color:var(--muted);
  }
  .draw-count b{ color:var(--gold); }

  .max-setting{
    display:flex;
    align-items:center;
    gap:8px;
    margin-top:18px;
    background:rgba(159,192,188,0.06);
    border:1px solid var(--panel-edge);
    padding:8px 10px 8px 14px;
    border-radius:10px;
  }
  .max-setting label{
    font-size:12px;
    color:var(--muted);
    white-space:nowrap;
  }
  .max-setting input{
    width:64px;
    background:#06181a;
    border:1px solid var(--panel-edge);
    color:var(--cream);
    padding:7px 8px;
    border-radius:6px;
    font-size:14px;
    text-align:center;
  }
  .max-setting button{
    background:var(--gold);
    color:#241a05;
    font-weight:700;
    font-size:12px;
    padding:8px 12px;
    border-radius:6px;
  }

  #resetBtn{
    margin-top:10px;
    background:transparent;
    border:1px solid var(--panel-edge);
    color:var(--muted);
    font-size:13px;
    padding:10px 18px;
    border-radius:10px;
    transition: color .12s ease, border-color .12s ease;
  }
  #resetBtn:hover{
    color:var(--danger);
    border-color:var(--danger);
  }
  #resetBtn:disabled{
    opacity:0.5;
    cursor:not-allowed;
  }

  button{
    font:inherit;
    cursor:pointer;
    border:none;
  }
  #drawBtn{
    margin-top:28px;
    background:linear-gradient(180deg, var(--gold), var(--gold-dim));
    color:#241a05;
    font-weight:800;
    font-size:16px;
    padding:16px 40px;
    border-radius:14px;
    letter-spacing:0.01em;
    box-shadow: 0 12px 24px -10px rgba(232,181,77,0.5);
    transition: transform .12s ease, box-shadow .12s ease;
  }
  #drawBtn:hover{ transform:translateY(-1px); }
  #drawBtn:active{ transform:translateY(1px); }
  #drawBtn:disabled{
    opacity:0.5;
    cursor:not-allowed;
    box-shadow:none;
  }
  #statusMsg{
    margin-top:14px;
    font-size:13px;
    color:var(--muted);
    min-height:18px;
    text-align:center;
  }

  .history{
    margin-top:40px;
    width:min(92vw, 460px);
  }
  .history h2{
    font-size:12px;
    letter-spacing:0.1em;
    color:var(--muted);
    font-weight:700;
    margin:0 0 10px;
  }
  .history ul{
    list-style:none; margin:0; padding:0;
    display:flex; flex-wrap:wrap; gap:8px;
  }
  .history li{
    background:rgba(232,181,77,0.10);
    border:1px solid rgba(232,181,77,0.25);
    color:var(--gold);
    font-family: monospace;
    font-weight:700;
    padding:6px 10px;
    border-radius:8px;
    font-size:14px;
  }

  footer{
    margin-top:56px;
    display:flex; flex-direction:column; align-items:center; gap:4px;
  }
  footer p{
    color:rgba(159,192,188,0.4);
    font-size:11px;
    margin:0;
  }
  #secretDot{
    width:10px; height:10px;
    border-radius:50%;
    background:rgba(159,192,188,0.18);
    cursor:default;
    user-select:none;
  }

  /* ---- MODALS ---- */
  .overlay{
    position:fixed; inset:0;
    background:rgba(3,10,11,0.72);
    backdrop-filter: blur(3px);
    display:none;
    align-items:center; justify-content:center;
    padding:20px;
    z-index:50;
  }
  .overlay.show{ display:flex; }
  .modal{
    background:#0d3435;
    border:1px solid var(--panel-edge);
    border-radius:16px;
    padding:26px;
    width:100%;
    max-width:380px;
    box-shadow:0 30px 70px -20px rgba(0,0,0,0.7);
  }
  .modal h3{
    margin:0 0 4px;
    font-size:17px;
  }
  .modal p.hint{
    margin:0 0 16px;
    color:var(--muted);
    font-size:13px;
  }
  .modal input[type=text], .modal input[type=password], .modal input[type=number]{
    width:100%;
    background:#06181a;
    border:1px solid var(--panel-edge);
    color:var(--cream);
    padding:11px 12px;
    border-radius:8px;
    font-size:15px;
    margin-bottom:10px;
  }
  .modal .row{ display:flex; gap:8px; }
  .modal .row button{ flex:1; }
  .btn-primary{
    background:var(--gold);
    color:#241a05;
    font-weight:700;
    padding:11px 14px;
    border-radius:8px;
  }
  .btn-ghost{
    background:transparent;
    border:1px solid var(--panel-edge) !important;
    color:var(--muted);
    padding:11px 14px;
    border-radius:8px;
  }
  .btn-danger{
    background:var(--danger);
    color:#fff;
    font-weight:700;
    padding:9px 12px;
    border-radius:8px;
    font-size:13px;
  }
  #pinError{
    color:var(--danger);
    font-size:12px;
    min-height:16px;
    margin:-4px 0 8px;
  }

  /* Admin modal specifics */
  #adminOverlay .modal{ max-width:460px; max-height:88vh; overflow-y:auto; }
  .admin-section{
    border-top:1px solid var(--panel-edge);
    padding-top:14px;
    margin-top:14px;
  }
  .admin-section h4{
    margin:0 0 8px;
    font-size:12px;
    letter-spacing:0.08em;
    color:var(--gold);
    text-transform:uppercase;
  }
  .pool-grid{
    display:flex; flex-wrap:wrap; gap:6px;
    max-height:110px;
    overflow-y:auto;
    padding:8px;
    background:#06181a;
    border-radius:8px;
    border:1px solid var(--panel-edge);
  }
  .pool-chip{
    font-family:monospace;
    font-size:12px;
    padding:4px 7px;
    border-radius:6px;
    background:rgba(159,192,188,0.10);
    color:var(--muted);
  }
  .queue-item{
    display:flex; align-items:center; justify-content:space-between;
    background:#06181a;
    border:1px solid var(--panel-edge);
    padding:7px 10px;
    border-radius:8px;
    margin-bottom:6px;
    font-family:monospace;
    font-size:13px;
  }
  .queue-item span.pos{ color:var(--muted); margin-right:8px; }
  .queue-item button{
    background:none;
    color:var(--danger);
    font-size:12px;
    cursor:pointer;
  }
  .small-note{
    font-size:11px;
    color:var(--muted);
    line-height:1.5;
    margin-top:4px;
  }
  #closeAdminBtn{
    margin-top:18px;
    width:100%;
  }
  .modal textarea{
    width:100%;
    background:#06181a;
    border:1px solid var(--panel-edge);
    color:var(--cream);
    padding:10px 12px;
    border-radius:8px;
    font-size:14px;
    font-family:inherit;
    resize:vertical;
    margin-bottom:6px;
  }
  .confetti-piece{
    position:fixed;
    top:-10px;
    width:8px; height:14px;
    z-index:60;
    pointer-events:none;
    border-radius:2px;
  }
  @keyframes fall{
    to{ transform: translateY(110vh) rotate(var(--rot)); opacity:0.9; }
  }

  /* ---- MODE TABS ---- */
  .mode-tabs{
    display:flex; gap:8px;
    margin-bottom:34px;
    background:rgba(159,192,188,0.06);
    border:1px solid var(--panel-edge);
    border-radius:12px;
    padding:6px;
  }
  .mode-tab{
    background:transparent;
    color:var(--muted);
    font-size:13px;
    font-weight:700;
    padding:9px 16px;
    border-radius:8px;
    transition: background .12s ease, color .12s ease;
  }
  .mode-tab:hover{ color:var(--cream); }
  .mode-tab.active{
    background:var(--gold);
    color:#241a05;
  }
  .mode{ display:none; }
  .mode.active{ display:block; }

  /* ---- MODE 2 ---- */
  .mode2-panel{
    width:min(92vw, 460px);
    background:linear-gradient(160deg, var(--panel), #0a2f30);
    border:1px solid var(--panel-edge);
    border-radius:16px;
    padding:18px;
    margin-bottom:16px;
  }
  .mode2-panel h3{
    margin:0 0 4px;
    font-size:15px;
    color:var(--gold);
  }
  .mode2-panel textarea{
    width:100%;
    background:#06181a;
    border:1px solid var(--panel-edge);
    color:var(--cream);
    padding:10px 12px;
    border-radius:8px;
    font-size:14px;
    font-family: inherit;
    resize:vertical;
    margin-bottom:10px;
  }
  .chip-list{
    display:flex; flex-wrap:wrap; gap:6px;
    margin-top:10px;
  }
  .chip-list .chip{
    background:rgba(159,192,188,0.10);
    border:1px solid var(--panel-edge);
    color:var(--muted);
    font-size:12px;
    padding:4px 9px;
    border-radius:6px;
  }
  #drawGroupBtn{
    margin-top:22px;
    background:linear-gradient(180deg, var(--gold), var(--gold-dim));
    color:#241a05;
    font-weight:800;
    font-size:16px;
    padding:16px 40px;
    border-radius:14px;
    box-shadow: 0 12px 24px -10px rgba(232,181,77,0.5);
    transition: transform .12s ease, box-shadow .12s ease;
  }
  #drawGroupBtn:hover{ transform:translateY(-1px); }
  #drawGroupBtn:active{ transform:translateY(1px); }
  #drawGroupBtn:disabled{
    opacity:0.5;
    cursor:not-allowed;
    box-shadow:none;
  }
  #groupStatusMsg{
    margin-top:14px;
    font-size:13px;
    color:var(--muted);
    min-height:18px;
    text-align:center;
  }
  .group-result{
    display:none;
    width:min(92vw, 460px);
    margin-top:18px;
    background:linear-gradient(160deg, #123c3d, #0a2f30);
    border:1px solid rgba(232,181,77,0.45);
    border-radius:18px;
    padding:24px;
    text-align:center;
    box-shadow: 0 20px 50px -18px rgba(0,0,0,0.6);
  }
  .group-result.show{ display:block; }
  .group-result .grp-name{
    font-size:clamp(22px,5vw,30px);
    font-weight:800;
    color:var(--gold);
    margin-bottom:14px;
  }
  .grp-order{
    font-size:12px;
    letter-spacing:0.08em;
    color:var(--ok);
    font-weight:700;
    text-transform:uppercase;
    margin-bottom:6px;
  }
  .hist-group .hg-order{
    color:var(--muted);
    font-size:11px;
    letter-spacing:0.06em;
    text-transform:uppercase;
    margin-bottom:2px;
  }
  .group-result ul{
    list-style:none; margin:0; padding:0;
    display:flex; flex-wrap:wrap; gap:8px;
    justify-content:center;
  }
  .group-result li{
    background:rgba(232,181,77,0.10);
    border:1px solid rgba(232,181,77,0.25);
    color:var(--cream);
    font-weight:600;
    padding:7px 14px;
    border-radius:8px;
    font-size:15px;
  }
  .group-result .empty-note{
    color:var(--muted);
    font-size:13px;
  }
  #groupHistory .hist-group{
    display:flex; flex-direction:column; gap:4px;
    background:rgba(159,192,188,0.06);
    border:1px solid var(--panel-edge);
    padding:10px 12px;
    border-radius:10px;
    margin-bottom:8px;
  }
  #groupHistory .hist-group .hg-name{
    color:var(--gold);
    font-weight:700;
    font-size:13px;
  }
  #groupHistory .hist-group .hg-members{
    color:var(--muted);
    font-size:12px;
    line-height:1.5;
  }

  /* ---- ADMIN: atur peserta per grup ---- */
  .group-admin{
    background:#06181a;
    border:1px solid var(--panel-edge);
    border-radius:10px;
    padding:12px;
    margin-bottom:10px;
  }
  .group-admin .ga-head{
    display:flex; align-items:center; justify-content:space-between;
    margin-bottom:8px;
  }
  .group-admin .ga-head b{ color:var(--gold); font-size:13px; }
  .group-admin .ga-head span{ color:var(--muted); font-size:11px; }
  .group-admin .ga-members{
    display:flex; flex-wrap:wrap; gap:8px;
    max-height:140px; overflow-y:auto;
    padding:4px 2px;
  }
  .group-admin label{
    display:flex; align-items:center; gap:6px;
    font-size:12px;
    color:var(--muted);
    background:rgba(159,192,188,0.06);
    border:1px solid var(--panel-edge);
    border-radius:6px;
    padding:4px 8px;
    cursor:pointer;
  }
  .group-admin label input{ accent-color:var(--gold); }
  .group-admin .ga-empty{ color:var(--muted); font-size:12px; }