:root {
  --blauw: #2457a8; --blauw2: #163a78; --navy: #10284a; --licht: #dfe9f8; --oranje: #ff7b1c; --oranje2: #c65500;
  --creme: #fbf7ee; --linnen: #efe5cf; --tulp: #e0364a; --groen: #3f9f5a; --ink: #182a45;
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #183553; font-family: var(--font); color: var(--ink);
  touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
canvas#c { position: fixed; inset: 0; display: block; touch-action: none; }
.hidden { display: none !important; }

/* top bar: cream with a Delft blue tile strip */
#bar { position: fixed; left: 0; right: 0; top: 0; height: 48px; display: flex; align-items: center; gap: 6px; padding: 0 6px;
  background: var(--creme); color: var(--blauw2); z-index: 5; }
#tiles { position: fixed; left: 0; right: 0; top: 48px; height: 14px; z-index: 5; pointer-events: none;
  background-color: #fff; border-top: 2px solid var(--blauw2); border-bottom: 2px solid var(--blauw2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='10'%3E%3Crect width='20' height='10' fill='%23fdfbf5'/%3E%3Cpath d='M10 1l4 4-4 4-4-4z' fill='%232457a8'/%3E%3Ccircle cx='0' cy='0' r='2.4' fill='%232457a8'/%3E%3Ccircle cx='20' cy='0' r='2.4' fill='%232457a8'/%3E%3Ccircle cx='0' cy='10' r='2.4' fill='%232457a8'/%3E%3Ccircle cx='20' cy='10' r='2.4' fill='%232457a8'/%3E%3Ccircle cx='10' cy='5' r='1.2' fill='%23fdfbf5'/%3E%3C/svg%3E");
  background-repeat: repeat-x; background-size: 20px 10px; box-shadow: 0 3px 6px rgba(0,0,0,.25); }
#info { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
#pname { font-size: 12px; color: #4b5d7a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
#nums { display: flex; gap: 10px; font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; color: var(--blauw2); }
#prog { color: var(--oranje2); }
.grp { display: flex; gap: 4px; }
.ib { height: 40px; min-width: 40px; padding: 0 8px; border: 0; border-radius: 10px; background: var(--blauw); color: #fff;
  display: flex; align-items: center; gap: 5px; cursor: pointer; font: 700 13px var(--font); box-shadow: 0 3px 0 var(--blauw2); }
.ib svg { width: 22px; height: 22px; flex: none; }
.ib:hover { background: #2f68c4; }
.ib.on { background: var(--oranje); box-shadow: 0 3px 0 var(--oranje2); }
.ib.off { opacity: .55; }
.ib.dis { opacity: .35; }
.ib .slash, .ib .xm { display: none; }
.ib.off .slash, .ib.off .xm { display: inline; }
.ib.off .wave { display: none; }
@media (max-width: 900px) { .ib .t { display: none; } .ib { padding: 0; } }
@media (max-width: 380px) { .ib { min-width: 34px; height: 36px; } .grp { gap: 3px; } #nums { font-size: 15px; gap: 6px; } }

#hint { position: fixed; top: 68px; left: 50%; transform: translateX(-50%); z-index: 4; pointer-events: none;
  background: rgba(16,40,74,.82); color: #fff; font-weight: 700; font-size: 13px; padding: 5px 12px; border-radius: 999px;
  white-space: nowrap; max-width: calc(100vw - 20px); overflow: hidden; text-overflow: ellipsis; transition: opacity .3s; }
#zoom { position: fixed; z-index: 4; display: flex; gap: 6px; }
.zb { width: 40px; height: 40px; border-radius: 10px; border: 2px solid #fff; background: var(--oranje); color: #fff; font: 900 24px/1 var(--font);
  display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.3); padding: 0; }
.zb svg { width: 20px; height: 20px; }
#toast { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.9); z-index: 9; pointer-events: none; opacity: 0;
  background: var(--creme); color: var(--blauw2); border: 3px solid var(--blauw); font-weight: 900; font-size: 19px; padding: 10px 22px;
  border-radius: 14px; transition: opacity .25s, transform .25s; text-align: center; box-shadow: 0 6px 0 rgba(0,0,0,.2); max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* overlays */
.ov { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 12px;
  background: radial-gradient(circle at 50% 25%, rgba(36,87,168,.6), rgba(10,24,46,.9)); overflow: auto; }
.panel { position: relative; background: var(--creme); border-radius: 18px; border: 3px solid var(--blauw2); padding: 18px 18px 16px;
  box-shadow: 0 0 0 6px #fff, 0 0 0 9px var(--blauw), 0 20px 40px rgba(0,0,0,.4); width: min(560px, 100%); text-align: center; margin: auto; }
h1 { margin: 0 0 4px; font-size: 38px; line-height: 1; color: var(--blauw2); letter-spacing: .3px; }
h1 span { display: block; font-size: 19px; color: var(--oranje2); margin-top: 5px; letter-spacing: 1px; text-transform: uppercase; }
h2 { margin: 0 0 6px; font-size: 28px; color: var(--blauw2); }
.sp #pim { width: 110px; height: auto; margin: -66px auto -2px; display: block; filter: drop-shadow(0 6px 4px rgba(0,0,0,.25));
  animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }
.intro { margin: 8px 4px 12px; font-size: 14.5px; line-height: 1.38; color: #34496b; }
.cards { display: flex; gap: 8px; margin-bottom: 10px; }
.daily { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: center; background: #fff; border: 2px solid var(--blauw); border-radius: 14px;
  padding: 8px; text-align: left; cursor: pointer; box-shadow: 0 3px 0 var(--licht); }
.daily.resume { border-color: var(--oranje); }
.daily img { width: 108px; height: 72px; border-radius: 8px; object-fit: cover; flex: none; background: #ddd; }
.dinfo { min-width: 0; flex: 1; }
.dtitle { font-weight: 900; font-size: 16px; color: var(--blauw2); }
.resume .dtitle { color: var(--oranje2); }
.dsub { font-size: 12.5px; color: #4b5d7a; margin: 1px 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.streak { display: flex; align-items: center; gap: 4px; font-weight: 900; color: var(--oranje2); font-size: 14px; }
.streak svg { width: 18px; height: 18px; }
.week { display: flex; gap: 3px; margin-top: 4px; }
.week i { width: 20px; height: 20px; border-radius: 4px; background: var(--licht); color: #5a6f92; font: 800 10.5px/20px var(--font);
  text-align: center; font-style: normal; }
.week i.ok { background: var(--blauw); color: #fff; }
.week i.today { box-shadow: 0 0 0 2px var(--oranje); }
.bar { height: 8px; background: var(--licht); border-radius: 4px; overflow: hidden; margin: 4px 0 2px; }
.bar i { display: block; height: 100%; width: 0; background: var(--oranje); }
.big { display: block; width: 100%; border: 0; border-radius: 14px; padding: 13px 10px; margin: 8px 0 0; cursor: pointer;
  font: 900 21px var(--font); color: #fff; background: var(--oranje); box-shadow: 0 5px 0 var(--oranje2); transition: transform .08s; }
.big:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--oranje2); }
.big.alt { background: var(--blauw); box-shadow: 0 5px 0 var(--blauw2); font-size: 18px; padding: 11px 10px; }
.btns { display: flex; gap: 10px; } .btns .big { flex: 1; }
#bPlay { font-size: 24px; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.03); } }
.ctrl { margin: 12px 0 0; font-size: 12px; color: #4b5d7a; display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; }
.ctrl svg { width: 16px; height: 16px; }
.key { display: inline-block; border: 2px solid #9fb3d3; border-bottom-width: 3px; border-radius: 6px; padding: 0 5px; font-weight: 800; font-size: 11px; color: var(--blauw2); }
@media (max-width: 520px) { .cards { flex-direction: column; } }

/* gallery */
.gp { width: min(860px, 100%); display: flex; flex-direction: column; max-height: calc(100vh - 30px); max-height: calc(100dvh - 30px); padding-bottom: 12px; }
.close { position: absolute; right: 10px; top: 8px; width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--blauw2);
  color: #fff; font: 900 26px/1 var(--font); cursor: pointer; }
.album { font-weight: 800; color: var(--oranje2); font-size: 14px; margin-bottom: 8px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; flex: none; scrollbar-width: none; justify-content: center; }
.tabs button { flex: none; border: 0; border-radius: 8px; padding: 8px 14px; font: 800 14px var(--font); background: var(--licht); color: var(--blauw2); cursor: pointer; }
.tabs button.sel { background: var(--blauw2); color: #fff; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; overflow-y: auto; padding: 8px 2px; flex: 1 1 auto; min-height: 120px;
  touch-action: pan-y; grid-auto-rows: max-content; align-content: start; }
@media (max-width: 500px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 6px; } }
.th { position: relative; border: 3px solid transparent; border-radius: 10px; padding: 0; background: #fff; cursor: pointer; overflow: hidden; aspect-ratio: 3/2; }
.th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.th.sel { border-color: var(--oranje); box-shadow: 0 0 0 3px var(--blauw); }
.th .nm { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, rgba(16,40,74,.88)); color: #fff;
  font: 700 11.5px var(--font); padding: 10px 4px 3px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th .ok { position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; border-radius: 50%; background: var(--groen); color: #fff;
  font: 900 14px/22px var(--font); text-align: center; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.th .pc { position: absolute; left: 4px; top: 4px; border-radius: 6px; background: var(--oranje); color: #fff; font: 900 11px/18px var(--font); padding: 0 5px; }
.opts { flex: none; border-top: 2px dashed #c9d6ea; margin-top: 6px; padding-top: 8px; }
.lbl { font-weight: 900; color: var(--blauw2); font-size: 14px; margin-bottom: 4px; }
.counts { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.counts button { border: 0; border-radius: 9px; min-width: 48px; padding: 7px 7px; font: 900 15px var(--font); background: var(--licht); color: var(--blauw2); cursor: pointer; }
.counts button.sel { background: var(--oranje); color: #fff; box-shadow: 0 3px 0 var(--oranje2); }
.tgls { display: flex; gap: 6px 18px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.tg { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; color: var(--blauw2); cursor: pointer; font-size: 14.5px; }
.tg small { font-weight: 600; color: #5a6f92; }
.tg input { display: none; }
.sw { width: 44px; height: 26px; border-radius: 13px; background: #c5d0e2; position: relative; transition: background .2s; flex: none; }
.sw::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.tg input:checked + .sw { background: var(--groen); }
.tg input:checked + .sw::after { left: 21px; }
.gbtns { display: flex; gap: 10px; flex: none; } .gbtns .big { flex: 2; } .gbtns #gFresh { flex: 1; }

/* win */
.wp { width: min(440px, 100%); }
.wpim { width: 110px; height: auto; margin: -70px auto 0; display: block; animation: jump .7s ease-in-out infinite alternate; filter: drop-shadow(0 6px 4px rgba(0,0,0,.25)); }
@keyframes jump { to { transform: translateY(-10px) rotate(4deg); } }
#wText { font-size: 20px; font-weight: 800; margin: 4px 0; color: var(--blauw2); }
.rec { color: var(--oranje2); font-weight: 900; font-size: 18px; margin: 4px 0; }
.rec:empty, .best:empty, .wstreak:empty { display: none; }
.best { margin: 2px 0; color: #4b5d7a; }
.wstreak { margin: 6px 0 2px; font-weight: 900; color: var(--blauw); font-size: 16px; }
.row { display: flex; gap: 10px; }
.row .big { flex: 1; font-size: 18px; }
@media (max-height: 700px) { .sp #pim { width: 80px; margin-top: -48px; } h1 { font-size: 32px; } .intro { font-size: 13px; margin: 4px 0 8px; } .big { padding: 10px; } }

/* small store frame (794x447, 640x360) */
@media (max-height: 560px) {
  .ov { padding: 8px; }
  .panel { padding: 10px 14px 10px; border-radius: 14px; box-shadow: 0 0 0 4px #fff, 0 0 0 6px var(--blauw), 0 10px 30px rgba(0,0,0,.4); }
  .sp { width: min(660px, 100%); }
  .sp #pim { width: 58px; margin: -30px auto -4px; }
  h1 { font-size: 28px; } h1 span { font-size: 14px; margin-top: 2px; }
  .intro { font-size: 12.5px; margin: 4px 4px 6px; }
  .cards { margin-bottom: 2px; }
  .daily { padding: 5px; gap: 8px; }
  .daily img { width: 84px; height: 56px; }
  .dtitle { font-size: 14.5px; }
  .week i { width: 18px; height: 18px; line-height: 18px; }
  .big { padding: 8px 10px; margin-top: 6px; font-size: 19px; }
  #bPlay { font-size: 21px; } .big.alt { padding: 8px 10px; font-size: 16px; }
  .ctrl { margin-top: 6px; }
  .gp { max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); padding: 10px 12px 8px; }
  .gp h2 { font-size: 21px; margin: 0 40px 2px; }
  .close { width: 34px; height: 34px; font-size: 22px; top: 6px; }
  .album { font-size: 12px; margin-bottom: 4px; }
  .tabs button { padding: 5px 12px; font-size: 13px; }
  .grid { min-height: 56px; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); padding: 5px 2px; }
  .opts { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; padding-top: 5px; }
  .lbl { margin: 0; }
  .counts button { min-width: 36px; padding: 5px 5px; font-size: 13px; }
  .tgls { margin-top: 0; gap: 4px 12px; }
  .tg { font-size: 13px; } .tg small { display: none; }
  .gbtns .big { font-size: 18px; padding: 7px 10px; }
  .wpim { width: 76px; margin-top: -46px; }
  .wp h2 { font-size: 24px; }
}
@media (max-height: 420px) {
  .sp .intro { display: none; }
  .sp .ctrl { display: none; }
  .sp #pim { display: none; }
  h1 { font-size: 25px; }
  .week { display: none; }
  .wpim { width: 60px; margin-top: -34px; }
  #wText { font-size: 17px; }
  .album { display: none; }
}
@media (max-height: 420px) and (max-width: 700px) { .cards { flex-direction: row; } .daily img { width: 64px; height: 43px; } }
@media (pointer: coarse) and (max-width: 700px) { .ctrl .kb { display: none; } }
@media (min-width: 1500px) and (min-height: 950px) { .panel { zoom: 1.25; } }
