/* style.css (merged)
   - Duplex print support (front: rotated art, back: results)
   - Mobile-first adjustments so phone UI matches desktop quality
*/

/* =======================
   Inline print helpers (FIRST)
======================= */
@media print{
  .printItem{
    display:flex;
    align-items:center;
    gap:10px;
    margin:0 0 6px 0;
    break-inside:avoid;
  }
  .printThumb{
    width:1in;
    height:auto;
    object-fit:contain;
    flex:0 0 auto;
  }
  .printTxt{ line-height:1.2; }
}

/* =======================
   DUPLEX PRINT
======================= */
.duplexPrint{ display:none; }

@media print{
  body *{ visibility:hidden !important; }
  #duplexPrint, #duplexPrint *{ visibility:visible !important; }

  #duplexPrint{
    display:block !important;
    position:absolute;
    inset:0;
    background:#fff;
    color:#000;
  }

.printPage{
  page-break-after:always;
  break-after:page;
  width:100%;
  min-height:auto;              /* was 100vh */
  padding:8mm;                  /* was 12mm */
  box-sizing:border-box;
}

  .printPage:last-child{
    page-break-after:auto;
    break-after:auto;
  }

  .printArtPage{
    display:flex;
    flex-direction:column;
    justify-content:center;
    align-items:center;
  }
  .printArtFrame{
  width:170mm;                  /* was 180mm */
  height:230mm;  
    display:flex;
    justify-content:center;
    align-items:center;
    overflow:hidden;
  }
  /* NOTE: your HTML should use #dpAwardImg, not #printNoteImg */
  #dpAwardImg{
  max-width:225mm;              /* was 240mm */
  max-height:165mm;             /* was 180mm */
  transform:rotate(90deg) scale(0.92); 
    transform-origin:center center;
    display:block;
  }
  .printHint{
  margin-top:4mm;               /* was 6mm */
  font-size:9pt;   
    color:#111;
  }

  /* Page 2: RESULTS (ONE-PAGE FIT) */
  .printResultsPage{
    page-break-inside: avoid;
    break-inside: avoid;
    display:flex;
    flex-direction:column;
  }

  .printResultsPage .printTitle{
  font-size:12pt;               /* was 13pt */
  margin:0 0 2mm 0;             /* was 3mm */
}

.printMeta{
  gap:2mm 6mm;                  /* was 2.5mm 7mm */
  font-size:9pt;                /* was 9.5pt */
  margin:0 0 2mm 0;             /* was 3mm */
}

.printCols{
  gap:5mm;                      /* was 6mm */
}

.printCols h4{
  margin:0 0 1.5mm 0;           /* was 2mm */
  font-size:10pt;               /* was 10.5pt */
}

.printCols ul{
  font-size:8.5pt;              /* was 9pt */
  line-height:1.12;             /* was 1.15 */
}

.printCols li{ padding:1px 0; } /* was 1.2px */



  @page{ margin:6mm; }
  
/* FORCE results to stay on one page */
.printResultsPage{
  page-break-inside: avoid;
  break-inside: avoid;
  height: 100vh;
  display:flex;
  flex-direction:column;
}

/* allow list to shrink instead of overflow */
.printCols{
  flex:1;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:6mm;
  overflow:hidden;
}

/* shrink text automatically if needed */
.printResultsPage{
  font-size: clamp(9pt, 1.8vw, 11pt);
}

.printCols ul{
  font-size: clamp(8pt, 1.7vw, 10pt);
  line-height:1.2;
}

}

/* =======================
   Theme (base)
======================= */
:root{
  --bg:#10162a;                 /* brighter base */
  --panel:rgba(255,255,255,.07);
  --text:#e9edf7;
  --muted:#d0d6ea;
  --accent:#4e8cff;
  --good:#19c37d;
  --bad:#ff4d4d;
  --border:rgba(255,255,255,.14);
  --shadow:0 10px 30px rgba(0,0,0,.35);
  --radius:18px;

  /* Note button colors */
  --noteBtnBg:#fff3a6;
  --noteBtnText:#0b2a6f;
  --noteBtnBorder:#e6d873;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
html{ -webkit-text-size-adjust:100%; }
button{ font:inherit; }

/* =======================
   Base layout (desktop default)
======================= */
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
  background:
    radial-gradient(900px 500px at 30% -10%, rgba(78,140,255,.25), transparent 60%),
    radial-gradient(700px 420px at 90% 10%, rgba(25,195,125,.18), transparent 60%),
    var(--bg);
  color:var(--text);
  font-size:16px;
}

.app{
  min-height:100%;
  display:flex;
  align-items:stretch;
  justify-content:center;
  padding:12px;
}
.shell{
  width:min(980px, 100%);
  display:flex;
  flex-direction:column;
  gap:12px;
}

/* =======================
   Header
======================= */
.header{
  background:rgba(18,23,38,.62);
  border:1px solid rgba(255,255,255,.12);
  box-shadow:var(--shadow);
  border-radius:var(--radius);
  padding:10px 12px;
  display:grid;
  grid-template-columns:44px 1fr 44px;
  align-items:center;
  position:sticky;
  top:calc(env(safe-area-inset-top, 0px) + 12px);
  z-index:10;
  backdrop-filter:blur(6px);
}
.title{
  text-align:center;
  font-weight:800;
  letter-spacing:.3px;
}
.iconBtn{
  width:40px;height:40px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.06);
  color:var(--text);
  display:grid;
  place-items:center;
  cursor:pointer;
}
.iconBtn:active{ transform:translateY(1px); }
.iconBtn[disabled]{ opacity:.4; cursor:not-allowed; }

.hamburger,.backIcon{ width:18px;height:18px; position:relative; }
.hamburger:before,.hamburger:after,.hamburger div{
  content:"";
  position:absolute;left:0;right:0;
  height:2px;background:currentColor;border-radius:2px;
}
.hamburger:before{ top:2px; }
.hamburger div{ top:8px; }
.hamburger:after{ top:14px; }
.backIcon:before{
  content:"";
  position:absolute;left:2px;top:8px;
  width:10px;height:10px;
  border-left:2px solid currentColor;
  border-bottom:2px solid currentColor;
  transform:rotate(45deg);
}

/* =======================
   Menu
======================= */
.menu{
  position:fixed; inset:0;
  display:none;
  background:rgba(0,0,0,.55);
  z-index:50;
  padding:16px;
}
.menu.open{ display:flex; align-items:flex-start; justify-content:flex-end; }
.menuPanel{
  width:min(360px, 100%);
  background:rgba(18,23,38,.96);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:14px;
  max-height:calc(100vh - 32px);  /* mobile overflow fix */
  overflow:auto;                  /* mobile overflow fix */
}
.menuPanel h3{ margin:0 0 10px 0; font-size:16px; }
.menuPanel .row{ display:flex; gap:10px; margin-top:10px; }
.menuPanel .row button{ flex:1; }
.small{ font-size:12px; color:var(--muted); line-height:1.3; }

/* =======================
   Panels / cards
======================= */
.panel{
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.14);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:14px;
  overflow:hidden;
}
.card{
  border:1px solid rgba(255,255,255,.14);
  border-radius:16px;
  background:rgba(255,255,255,.05);
  padding:12px;
}

/* =======================
   Start screen
======================= */
.start{
  display:flex;
  flex-direction:column;
  gap:14px;
  align-items:center;
  text-align:center;
  padding:18px 14px 20px;
}
.startHero{
  width:100%;
  border:1px solid rgba(255,255,255,.16);
  border-radius:18px;
  padding:14px;
  background:
    radial-gradient(560px 240px at 10% 0%, rgba(255,126,224,.28), transparent 62%),
    radial-gradient(560px 260px at 90% 12%, rgba(255,209,102,.24), transparent 62%),
    radial-gradient(520px 260px at 60% 112%, rgba(25,195,125,.22), transparent 62%),
    rgba(255,255,255,.07);
  text-align:center;
}
.startHero h2{
  margin:0;
  font-size:clamp(20px, 4.4vw, 30px); /* better on phones */
  font-weight:950;
  letter-spacing:.2px;
}
.startHero p{
  margin:8px auto 0;
  font-size:clamp(13px, 3.4vw, 16px); /* better on phones */
  color:rgba(255,255,255,.82);
  max-width:58ch;
}

.startSplit{
  width:100%;
  display:grid;
  gap:14px;
  margin-top:12px;
}

.sectionHeader{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin:2px 0 2px;
}
.sectionHeader h3{
  margin:0;
  font-size:13px;
  letter-spacing:.18px;
  text-transform:uppercase;
  color:rgba(255,255,255,.88);
}
.dividerPill{
  height:10px;
  flex:1;
  border-radius:999px;
  background:linear-gradient(90deg, rgba(255,126,224,.35), rgba(255,209,102,.25), rgba(25,195,125,.22), rgba(78,140,255,.30));
  border:1px solid rgba(255,255,255,.08);
}

.levelGrid{
  width:100%;
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:10px;
}
.levelCard{
  border:1px solid rgba(255,255,255,.16);
  border-radius:18px;
  background:rgba(255,255,255,.06);
  box-shadow:0 12px 28px rgba(0,0,0,.28);
  padding:12px;
  text-align:left;
  cursor:pointer;
  transition:transform .08s ease, background .12s ease, border-color .12s ease;
  position:relative;
  overflow:hidden;
}
.levelCard:active{ transform:translateY(1px); }
.levelCard[data-selected="true"]{
  border-color:rgba(120,190,255,.70);
  background:
    radial-gradient(380px 200px at 30% 10%, rgba(120,190,255,.22), transparent 65%),
    rgba(255,255,255,.07);
  box-shadow:0 0 0 3px rgba(120,190,255,.22), 0 16px 34px rgba(0,0,0,.30);
}
.levelTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:6px;
}
.levelName{
  font-weight:900;
  letter-spacing:.2px;
  font-size:clamp(17px, 4.2vw, 22px);
}
.levelBadge{
  font-size:13px;
  padding:5px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.18);
  color:rgba(255,255,255,.78);
  background:rgba(255,255,255,.08);
  white-space:nowrap;
}
.levelDesc{
  margin:0;
  font-size:14px;
  color:rgba(255,255,255,.86);
  line-height:1.4;
}
.levelGlow{ opacity:.85; filter:blur(20px); pointer-events:none; }
.glowBeginner{ background:rgba(255,209,102,.35); }
.glowIntermediate{ background:rgba(78,140,255,.30); }
.glowExpert{ background:rgba(255,126,224,.28); }

.lengthGrid{
  width:100%;
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:10px;
  margin-top:2px;
}
.lengthGrid .btn{
  background:rgba(120,190,255,.16);
  border-color:rgba(120,190,255,.34);
  font-size:clamp(16px, 3.8vw, 20px);
  padding:16px 14px;
  border-radius:999px;
  font-weight:900;
  letter-spacing:.3px;
}

/* =======================
   Game
======================= */
.game{ display:none; gap:12px; }
.game.open{ display:grid; }
.gameGrid{ display:grid; grid-template-rows:auto auto auto; gap:12px; }

.artWrap{
  position:relative;
  border-radius:16px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.03);
  padding:10px;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}
.art{
  width:min(740px, 100%);
  aspect-ratio:360/300;
  display:flex;
  align-items:center;
  justify-content:center;
}
.art img{
  width:100%;
  height:100%;
  object-fit:contain;
  border-radius:12px;
  user-select:none;
  -webkit-user-drag:none;
  opacity:1;
  transform:translateZ(0);
  transition:opacity 220ms ease;
}
.fadeOut img{ opacity:0; }

/* Overlay */
.overlay{
  position:absolute; inset:0;
  display:grid;
  place-items:center;
  opacity:0;
  pointer-events:none;
  transition:opacity 160ms ease;
  backdrop-filter:blur(1px);
}
.overlay.show{ opacity:1; }
.mark{
  width:96px;height:96px;
  border-radius:999px;
  display:grid;
  place-items:center;
  box-shadow:0 10px 30px rgba(0,0,0,.25);
  border:2px solid rgba(255,255,255,.45);
}
.mark svg{ width:54px;height:54px; }
.overlay.good{ background:rgba(25,195,125,.20); }
.overlay.good .mark{ background:rgba(25,195,125,.85); }
.overlay.bad{ background:rgba(255,77,77,.18); }
.overlay.bad .mark{ background:rgba(255,77,77,.85); }

/* =======================
   Answer buttons
======================= */
.answerRow{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:14px;
}
.answerRow > button{
  background:var(--noteBtnBg);
  color:var(--noteBtnText);
  border:2px solid var(--noteBtnBorder);
  border-radius:16px;
  font-weight:900;
  letter-spacing:.5px;
  cursor:pointer;
  transition:transform .06s ease, box-shadow .12s ease;
}
.answerRow > button:active{ transform:translateY(2px); }

/* sizes */
@media (min-width:900px){
  .answerRow > button{ font-size:40px; padding:28px 10px; }
}
@media (min-width:600px) and (max-width:899px){
  .answerRow > button{ font-size:30px; padding:22px 10px; }
}
@media (max-width:599px){
  .answerRow{ grid-template-columns:1fr 1fr; gap:10px; }
  .answerRow > button{ font-size:22px; padding:16px 10px; }
}
@media (max-width:420px){
  .answerRow > button{ font-size:20px; padding:14px 8px; }
}

/* =======================
   Status / Timer
======================= */
.statusBar{
  display:grid;
  grid-template-columns:1fr auto;
  gap:10px;
  align-items:center;
  padding:10px 12px;
  border-radius:16px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.03);
}
.statusLeft{
  display:flex;
  flex-wrap:wrap;
  gap:8px 12px;
  align-items:baseline;
  color:var(--muted);
  font-size:13px;
}
.statusLeft b{ color:var(--text); }
.timer{
  font-variant-numeric:tabular-nums;
  font-weight:800;
  letter-spacing:.2px;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
  min-width:110px;
  text-align:center;
}
@media (max-width:420px){
  .statusLeft{ font-size:12px; }
  .timer{ min-width:92px; padding:6px 8px; }
}

/* =======================
   Generic buttons
======================= */
.btn{
  border:1px solid var(--border);
  background:rgba(255,255,255,.06);
  color:var(--text);
  border-radius:16px;
  padding:12px 12px;
  cursor:pointer;
  transition:transform 80ms ease, background 120ms ease;
  font-weight:750;
  letter-spacing:.2px;
}
.btn:active{ transform:translateY(1px); }
.btn.primary{ background:rgba(78,140,255,.18); border-color:rgba(78,140,255,.35); }
.btn.wide{ width:100%; }
.btn[disabled]{ opacity:.45; cursor:not-allowed; }
.btn.ghost{ background:transparent; }
.btn.danger{ background:rgba(255,77,77,.16); border-color:rgba(255,77,77,.30); }
.btn.good{ background:rgba(25,195,125,.16); border-color:rgba(25,195,125,.30); }

/* =======================
   Results / awards
======================= */
.results,.awards{ display:none; gap:12px; }
.results.open,.awards.open{ display:grid; }

.grid2{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.card h3{ margin:0 0 8px 0; font-size:15px; }
.kv{ display:grid; grid-template-columns:1fr auto; gap:8px; font-size:13px; color:var(--muted); }
.kv b{ color:var(--text); }

.list{
  margin:8px 0 0 0;
  padding:0;
  list-style:none;
  max-height:260px;
  overflow:auto;
}
.list li{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.08);
  margin-bottom:8px;
  background:rgba(0,0,0,.10);
  font-size:13px;
}

.tag{
  padding:2px 8px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  font-size:12px;
  color:var(--muted);
  white-space:nowrap;
  font-variant-numeric:tabular-nums;
}
.tag.ok{ color:rgba(25,195,125,.95); border-color:rgba(25,195,125,.35); }
.tag.no{ color:rgba(255,77,77,.95); border-color:rgba(255,77,77,.35); }

/* Printable certificate area (on-screen only; duplex printing uses #duplexPrint) */
.printArea{
  display:none;
  border:1px dashed rgba(255,255,255,.22);
  border-radius:16px;
  padding:12px;
  background:rgba(255,255,255,.02);
}
.printTitle{ font-weight:900; font-size:18px; margin:0 0 10px 0; }

.awardArtImg{
  width:100%;
  max-width:620px;
  margin:0 auto 10px auto;
  display:block;
}

.printMeta{
  display:flex;
  flex-wrap:wrap;
  gap:10px 14px;
  justify-content:center;
  color:var(--muted);
  font-size:13px;
  margin-bottom:10px;
}
.printMeta b{ color:var(--text); }
.printCols{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.printCols h4{ margin:0 0 8px 0; font-size:14px; text-align:center; }
.printCols ul{
  margin:0; padding:10px; list-style:none;
  border:1px solid rgba(255,255,255,.10);
  border-radius:12px;
  min-height:110px;
  background:rgba(0,0,0,.10);
  font-size:13px;
  color:var(--muted);
}
.printCols li{ padding:3px 0; }
.footerBtns{ display:flex; gap:10px; flex-wrap:wrap; }
.spacer{ height:4px; }

/* =======================
   Mobile responsive (key improvements)
======================= */
@media (max-width:720px){
  /* full-width mobile layout instead of “centered desktop card” */
  .app{ padding:0; justify-content:stretch; }
  .shell{ width:100%; padding:10px; }

  /* header behaves like a native top bar */
  .header{
    top:0;
    border-radius:0;
    margin:0 -10px;
  }

  .panel{ padding:12px; }
  .grid2{ grid-template-columns:1fr; }

  .levelGrid{ grid-template-columns:1fr; }
  .lengthGrid{ grid-template-columns:1fr; }

  /* avoid nested scroll box inside results on mobile */
  .list{ max-height:none; overflow:visible; }
}

/* Extra-small phones */
@media (max-width:420px){
  .shell{ padding:8px; }
  .header{ margin:0 -8px; }
}

/* =======================
   Print (harmless defaults)
======================= */
@media print{
  body{ background:#fff !important; color:#000 !important; }
  .panel{ box-shadow:none !important; }
}
