:root{
  --bg0: #efe5d6;
  --bg1: #e9ddcc;
  --card: rgba(255,255,255,.14);
  --card2: rgba(255,255,255,.10);
  --muted: rgba(0,0,0,.55);
  --accent: #2563EB;
  --danger: #d13b3b;

  --r: 14px;
  --shadow-out: 0 16px 40px rgba(0,0,0,.08);
  --shadow-in: inset 0 1px 0 rgba(255,255,255,.35), inset 0 -8px 18px rgba(0,0,0,.06);

  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

*{ box-sizing: border-box; }
html,body{ height: 100%; }

body{
  margin: 0;
  font-family: var(--sans);
  background: radial-gradient(1200px 600px at 50% 0%, rgba(255,255,255,.28), transparent 60%),
              linear-gradient(180deg, var(--bg0), var(--bg1));
  color: rgba(0,0,0,.88);
}

/* Header */
header{
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: rgba(255,255,255,.10);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0,0,0,.05);
}

.brand{
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.brand:active{ transform: translateY(1px); }

.logo{
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: rgba(0,0,0,.85);
  box-shadow: 0 0 0 6px rgba(0,0,0,.05);
}
.name{ font-weight: 900; }
.tag{ font-size: 12px; color: var(--muted); margin-top: 2px; }

.top-actions{
  display: flex;
  gap: 10px;
  align-items: center;
}

.navBtn, .pill{
  border: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  box-shadow: var(--shadow-in);
  cursor: pointer;
  font-weight: 800;
}
.navBtn:active, .pill:active{ transform: translateY(1px); }

/* Screens */
.screen{ display: none; }
.screen.active{ display: block; }

/* Layout container + cards */
.container{
  max-width: 980px;
  margin: 0 auto;
  padding: 26px 18px 48px;
}

.card{
  border-radius: 28px;
  background: var(--card);
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: var(--shadow-out), var(--shadow-in);
  padding: 22px;
}

.h1{
  margin: 0;
  font-size: 28px;
  font-weight: 950;
}
.sub{
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.note{
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.mono{ font-family: var(--mono); }

.divider{
  height: 1px;
  background: rgba(0,0,0,.08);
  margin: 16px 0;
}

/* Buttons */
.btn{
  border: 0;
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 850;
  cursor: pointer;
  background: rgba(255,255,255,.20);
  box-shadow: var(--shadow-out), var(--shadow-in);
  transition: transform .04s ease, opacity .2s ease;
}
.btn:active{ transform: translateY(1px); }
.btn.primary{
  background: rgba(37,99,235,.90);
  color: white;
  box-shadow: 0 10px 26px rgba(37,99,235,.25);
}
.btn.ghost{ background: rgba(255,255,255,.10); }
.btn.danger{
  background: rgba(209,59,59,.90);
  color: white;
  box-shadow: 0 10px 26px rgba(209,59,59,.22);
}
.btn:disabled{
  opacity: .55;
  cursor: not-allowed;
}

/* Forms */
input, select{
  width: 100%;
  border: 1px solid rgba(0,0,0,.08);
  background: rgba(255,255,255,.25);
  border-radius: 14px;
  padding: 12px;
  outline: none;
  box-shadow: var(--shadow-in);
  font-weight: 650;
  font-family: var(--sans);
}
label{
  display: block;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 850;
  color: var(--muted);
}

/* Small badges */
.badges{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.badge{
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  box-shadow: var(--shadow-in);
  font-weight: 850;
  font-size: 12px;
}
.badge.warn{ background: rgba(0,0,0,.08); }

/* Stats (generic) */
.stats{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
@media (max-width: 840px){
  .stats{ grid-template-columns: 1fr; }
}
.stat{
  border-radius: 18px;
  background: rgba(255,255,255,.14);
  box-shadow: var(--shadow-in);
  padding: 12px;
  border: 1px solid rgba(255,255,255,.14);
}
.statLabel{
  font-size: 12px;
  font-weight: 850;
  color: var(--muted);
}
.statValue{
  margin-top: 6px;
  font-size: 18px;
  font-weight: 920;
  font-family: var(--mono);
}

/* Progress bar */
.progress{
  margin-top: 12px;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  box-shadow: var(--shadow-in);
  overflow: hidden;
}
.progress #progressBar{
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: rgba(37,99,235,.85);
}

/* Hint */
.hint{
  margin-top: 12px;
  padding: 12px 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.12);
  box-shadow: var(--shadow-in);
  color: var(--muted);
  font-size: 13px;
}

/* Lists */
.list{
  margin-top: 10px;
  display: grid;
  gap: 10px;
}
.item{
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.12);
  box-shadow: var(--shadow-in);
  border: 1px solid rgba(255,255,255,.12);
}

/* ------------------------------
   LANDING
------------------------------ */
#screen-landing{
  min-height: 100vh;
}
.landing{
  position: relative;
  min-height: 100vh;
  padding: 24px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.landing-grid{
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 18px;
  pointer-events: none;
  overflow: hidden;
  opacity: .95;
}
.landing-center{
  position: relative;
  z-index: 2;
  border-radius: 34px;

  background: rgba(255,255,255,.20);
  border: 1px solid rgba(255,255,255,.28);
  box-shadow: 0 26px 70px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.25);

  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);

  padding: 26px;
  max-width: 720px;
  text-align: left;
}
/* each column */
#screen-landing .landing-col{
  position: relative;
  overflow: hidden;
}

/* track that moves */
#screen-landing .landing-track{
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  will-change: transform;
}
#screen-landing .landing-num{
  font-family: var(--mono);
  font-weight: 950;
  font-size: clamp(26px, 4.6vw, 54px);
  line-height: 1;

  color: rgba(0,0,0,.08);
  text-shadow:
    -1px -1px 0 rgba(255,255,255,.35), /* highlight */
     1px  1px 0 rgba(0,0,0,.10),       /* shadow */
     0 14px 30px rgba(0,0,0,.03);
}
.landing-title{
  margin: 0;
  font-size: clamp(26px, 4.2vw, 42px);
  font-weight: 950;
  letter-spacing: .2px;
}
.landing-sub{
  margin: 0;
  color: rgba(0,0,0,.55);
  line-height: 1.5;
  font-size: 14px;
  max-width: 560px;
}
.landing-actions{
  justify-content: center;
  margin-top: 16px;
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}
/* animations */
@keyframes colUp{
  from{ transform: translateY(0%); }
  to  { transform: translateY(-25%); } /* depends on COPIES=4 in JS */
}
@keyframes colDown{
  from{ transform: translateY(-25%); }
  to  { transform: translateY(0%); }
}

#screen-landing .landing-col.up   .landing-track{ animation: colUp   var(--t, 18s) linear infinite; }
#screen-landing .landing-col.down .landing-track{ animation: colDown var(--t, 18s) linear infinite; }

/* Motion-respect */
@media (prefers-reduced-motion: reduce){
  #screen-landing .landing-track { animation: none; }
}

/* Landing sign-in button: small reminder jump */
#btnLandingSignIn{
  animation: nudge 6.5s ease-in-out infinite;
  will-change: transform;
}

@keyframes nudge{
  0%, 82%   { transform: translateY(0); }
  86%       { transform: translateY(-4px); }
  90%       { transform: translateY(0); }
  94%       { transform: translateY(-3px); }
  100%      { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce){
  #btnLandingSignIn{ animation: none; }
}

body.is-landing .wrap { display: none; }

/* Auth / Profile / Contact / Results cards centered */
.auth.card{
  max-width: 980px;
  margin: 18px auto 0;
}

/* KV blocks (All data / Current run / Run target) */
.kv{
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.12);
  box-shadow: var(--shadow-in);
}
.val{
  font-size: 18px;
  font-weight: 920;
  font-family: var(--mono);
}

/* Toolbar */
.toolbar{
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* Stats grids used in profile/results/modal */
.stats-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 760px){
  .stats-grid{ grid-template-columns: 1fr; }
}
.stat .k{ font-size: 12px; font-weight: 850; color: var(--muted); }
.stat .v{ margin-top: 6px; font-size: 18px; font-weight: 920; }

/* Textarea in Contact */
textarea{
  width: 100%;
  min-height: 110px;
  resize: vertical;
  border: 1px solid rgba(0,0,0,.08);
  background: rgba(255,255,255,.25);
  border-radius: 14px;
  padding: 12px;
  outline: none;
  box-shadow: var(--shadow-in);
  font-weight: 650;
  font-family: var(--sans);
}

/* Modal (HTML uses .backdrop) */
.backdrop{
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0,0,0,.18);
  z-index: 60;
}
.backdrop.show{ display: flex; }

.modal{
  width: min(640px, 100%);
  border-radius: 26px;
  background: rgba(255,255,255,.22);
  box-shadow: var(--shadow-out), var(--shadow-in);
  padding: 18px;
  border: 1px solid rgba(255,255,255,.16);
}
.modal .head{
  display:flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.modal .head h3{ margin: 0; font-size: 18px; font-weight: 950; }
.modal .head p{ margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.modal .close{
  border: 0;
  background: rgba(255,255,255,.18);
  box-shadow: var(--shadow-in);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 900;
}
.modal .close:active{ transform: translateY(1px); }

/* ================================
   MAIN UI (scoped): fixed sidebar + huge digit buttons
   This is now ONLY applied on the main screen.
=============================== */

#screen-main .main{
  position: relative;
  display: block;
  margin-top: 16px;
}

/* Sidebar pinned top-left (below header) */
#screen-main .sidebar{
  position: fixed;
  left: 18px;
  top: 92px;
  width: min(340px, calc(50vw - 18px));
  max-height: calc(100vh - 110px);
  overflow: auto;
  padding-right: 6px;
}

/* Center content area */
#screen-main .content{
  margin-left: calc(min(340px, calc(50vw - 18px)) + 22px);
  min-height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Big keypad centered */
#screen-main .keypad{
  display: flex;
  gap: 18px;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  margin-top: 16px;
}

/* Huge digit buttons */
#screen-main .key{
  width: clamp(86px, 9vw, 120px);
  height: clamp(86px, 9vw, 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 24px;
  background: rgba(255,255,255,.18);
  box-shadow: var(--shadow-out), var(--shadow-in);
  border: 1px solid rgba(255,255,255,.18);
  font-family: var(--mono);
  font-weight: 950;
  font-size: clamp(24px, 3vw, 34px);
  cursor: pointer;
  user-select: none;
  transition: transform .08s ease, background .12s ease;
}
#screen-main .key:hover{
  background: rgba(255,255,255,.22);
}
#screen-main .key:active{
  transform: translateY(1px) scale(.99);
}
#screen-main .key:focus{
  outline: 2px solid rgba(37,99,235,.55);
  outline-offset: 3px;
}

/* Responsive */
@media (max-width: 920px){
  #screen-main .sidebar{
    position: relative;
    left: auto;
    top: auto;
    width: auto;
    max-height: none;
    padding-right: 0;
  }

  #screen-main .content{
    margin-left: 0;
    min-height: auto;
    justify-content: flex-start;
  }

  #screen-main .keypad{
    flex-wrap: wrap;
  }

  #screen-main .key{
    width: clamp(78px, 22vw, 120px);
    height: clamp(78px, 22vw, 120px);
  }
}

