/* Hintadle: a pixel-style grocery store.
   Palette is approximated from the K-logo colour listings (navy, yellow, red, green, orange).
   Swap in official brand values in :root if you have them. */
:root {
  --blue: #0D3192;
  --blue-d: #081f63;
  --yellow: #FFE600;
  --yellow-d: #b39e00;
  --red: #E8141C;
  --red-d: #8f0b10;
  --green: #51B321;
  --orange: #FF8900;
  --wall: #e7efff;
  --paper: #fffdf2;
  --ink: #0a1a44;
  --dim: #5a6b9a;
  /* Readable text and numbers (Atkinson Hyperlegible keeps 5/S, 8/B, 1/l apart).
     The pixel font is only used for the logo, headings and buttons. */
  --font: 'Atkinson Hyperlegible', system-ui, 'Segoe UI', Arial, sans-serif;
  --pixel: 'Pixelify Sans', 'Atkinson Hyperlegible', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.35;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Tiled shop wall */
  background:
    linear-gradient(rgba(13, 49, 146, .07) 2px, transparent 2px) 0 0 / 56px 56px,
    linear-gradient(90deg, rgba(13, 49, 146, .07) 2px, transparent 2px) 0 0 / 56px 56px,
    linear-gradient(var(--wall), #d3e1fb);
}

/* Checkered shop floor along the bottom of the screen */
.floor {
  position: fixed; left: 0; right: 0; bottom: 0; height: 72px; z-index: -1;
  background: repeating-conic-gradient(#c3d1ee 0% 25%, #eef3ff 0% 50%) 0 0 / 48px 48px;
  border-top: 6px solid var(--blue);
}

[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Storefront: sign + awning ---------- */
.top { display: flex; flex-direction: column; }
.sign {
  order: 1;
  display: flex; align-items: center; justify-content: space-between;
  height: 70px; padding: 0 max(16px, calc(50% - 264px));
  background: var(--blue);
  border-bottom: 6px solid var(--yellow);
}
.logo {
  margin: 0; display: flex; align-items: center; gap: 10px;
  font-size: 30px; font-weight: 700; letter-spacing: 4px;
  color: var(--yellow); text-shadow: 3px 3px 0 var(--blue-d);
}
.awning {
  order: 2; height: 46px;
  background: repeating-linear-gradient(90deg, var(--red) 0 36px, #fff 36px 72px);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .12);
  --teeth: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='14'%3E%3Cpolygon points='0,0 36,0 18,14' fill='black'/%3E%3C/svg%3E");
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 14px) no-repeat, var(--teeth) bottom / 36px 14px repeat-x;
          mask: linear-gradient(#000 0 0) top / 100% calc(100% - 14px) no-repeat, var(--teeth) bottom / 36px 14px repeat-x;
}

/* Chunky keys: yellow header buttons and the red ARVAA key */
.key-btn, .enter-key {
  font: inherit; font-weight: 700; border: 0; cursor: pointer; border-radius: 0;
}
.key-btn {
  width: 46px; height: 46px; font-size: 24px;
  background: var(--yellow); color: var(--blue);
  box-shadow: 0 4px 0 var(--yellow-d);
  display: grid; place-items: center;
}
.key-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--yellow-d); }
.key-btn:hover { background: #fff27a; }

/* ---------- Store floor ---------- */
.store { width: min(560px, 100%); margin: 0 auto; padding: 14px 16px 110px; flex: 1; }
.daily { text-align: center; margin: 4px 0 26px; font-weight: 600; color: var(--blue); letter-spacing: 1px; }
.chip {
  display: inline-block; margin-left: 6px; padding: 0 8px; font-size: 14px;
  background: var(--orange); color: var(--ink); letter-spacing: 1px;
}

/* The aisle: hanging store sign + shelf + shelf-edge label */
.aisle {
  position: relative;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .35) 0 4px, transparent 4px 28px),
    #b7c8ef;
  box-shadow: inset 0 0 0 4px var(--blue), 6px 6px 0 var(--blue-d);
  padding-top: 38px;
}
.store-plate {
  position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  background: #fff; padding: 4px 12px 4px 4px; font-weight: 700; font-size: 18px;
  box-shadow: 0 0 0 4px var(--blue), 4px 4px 0 4px var(--blue-d);
}
.store-plate::before, .store-plate::after { /* hanging chains */
  content: ""; position: absolute; top: -18px; width: 4px; height: 14px; background: var(--blue-d);
}
.store-plate::before { left: 18px; } .store-plate::after { right: 18px; }
.chain { padding: 2px 8px; background: var(--blue); color: #fff; }
.chain-k-market { background: var(--yellow); color: var(--blue); }
.chain-k-supermarket { background: var(--green); color: #fff; }
.chain-k-citymarket { background: var(--red); color: #fff; }

.shelf-unit { display: flex; flex-direction: column; }
.product-art {
  align-self: center; min-height: 132px; display: flex; align-items: flex-end; justify-content: center;
  margin-bottom: -2px; position: relative; z-index: 1;
}
.product-art img.photo {
  width: 132px; height: 132px; object-fit: contain; background: transparent;
  filter: drop-shadow(5px 5px 0 rgba(8, 31, 99, .28));
}
.shelf-board {
  height: 22px;
  background: linear-gradient(#e8a85f 0 6px, #c47e3a 6px 14px, #8c5628 14px 22px);
}
.shelf-label {
  display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px;
  background: var(--yellow); padding: 10px 14px 14px; border-top: 4px solid var(--blue);
}
.shelf-label .cat {
  grid-column: 1; margin: 0; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: var(--blue);
}
.shelf-label h2 {
  grid-column: 1; margin: 0; font-size: 25px; line-height: 1.1; overflow-wrap: anywhere;
}
.price-slot {
  grid-column: 2; grid-row: 1 / span 2; margin: 0;
  background: #fff; color: var(--red); font-size: 34px; font-weight: 700; padding: 2px 10px;
  box-shadow: inset 0 0 0 3px var(--blue); white-space: nowrap;
}
.price-slot.revealed { color: var(--green); }

/* ---------- Guesses as price tags ---------- */
.rows { list-style: none; margin: 28px 0 14px; padding: 0; display: grid; gap: 8px; }
.tag {
  --edge: #c4d0ee; --fill: #f4f7ff; --word: var(--dim);
  position: relative;
  display: grid; grid-template-columns: 24px 1fr auto 30px; align-items: center; gap: 10px;
  height: 54px; padding: 0 12px 0 40px; color: var(--dim);
  background: var(--fill); box-shadow: inset 0 0 0 3px var(--edge);
  clip-path: polygon(20px 0, 100% 0, 100% 100%, 20px 100%, 0 50%);
}
.tag::before { /* the string hole */
  content: ""; position: absolute; left: 20px; top: 50%; width: 10px; height: 10px; margin-top: -5px;
  background: var(--wall); box-shadow: inset 0 0 0 2px var(--edge);
}
.tag .n { opacity: .7; }
.tag .val { font-size: 24px; font-weight: 600; color: var(--ink); }
.tag .word { font-size: 14px; font-weight: 700; letter-spacing: 2px; color: var(--word); }
.tag .arrow { font-size: 24px; text-align: center; color: var(--word); }
.tag.far   { --edge: var(--red);    --fill: #ffe3e4; --word: #b30d14; }
.tag.close { --edge: var(--orange); --fill: #fff1c4; --word: #b35f00; }
.tag.win   { --edge: var(--green);  --fill: #dff5d0; --word: #2c7a00; }
.tag.pop { animation: pop .2s steps(3); }
@keyframes pop { from { transform: translateX(-14px); } to { transform: none; } }

/* ---------- Cash register ---------- */
.register {
  display: flex; gap: 12px; padding: 12px; background: var(--blue);
  box-shadow: inset 0 0 0 4px var(--blue-d), 6px 6px 0 var(--blue-d);
}
.lcd {
  position: relative; flex: 1; height: 60px; background: #0f2a1a;
  box-shadow: inset 0 0 0 4px #04120a, inset 0 -6px 0 rgba(0, 0, 0, .35);
}
.lcd input {
  width: 100%; height: 100%; background: transparent; border: 0; outline: 0;
  color: #8dff6a; font: inherit; font-size: 32px; font-weight: 600; letter-spacing: 2px; padding: 0 46px 0 16px;
}
.lcd input::placeholder { color: #2f7a35; }
.lcd input:disabled { color: #4a8f4f; }
.lcd:focus-within { box-shadow: inset 0 0 0 4px var(--yellow), inset 0 -6px 0 rgba(0, 0, 0, .35); }
.eur { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: #5bbf55; font-size: 26px; }
.enter-key {
  height: 60px; padding: 0 22px; font-size: 20px; letter-spacing: 2px;
  background: var(--red); color: #fff; box-shadow: 0 6px 0 var(--red-d);
}
.enter-key:hover { background: #ff3a42; }
.enter-key:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--red-d); }
.enter-key:disabled { background: #8d93a8; box-shadow: 0 6px 0 #5d6379; cursor: not-allowed; transform: none; }
.enter-key.small { height: 46px; font-size: 17px; box-shadow: 0 5px 0 var(--red-d); }
.enter-key.ghost { background: var(--blue); box-shadow: 0 5px 0 var(--blue-d); }
.msg { min-height: 24px; margin: 12px 0 0; text-align: center; color: var(--red); font-weight: 600; }

/* ---------- Receipt dialogs ---------- */
dialog.receipt {
  width: min(380px, 92vw); padding: 20px 22px 40px; border: 0; color: var(--ink);
  background: var(--paper); font-family: var(--font);
  --paper-teeth: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='10'%3E%3Cpolygon points='0,0 16,0 8,10' fill='black'/%3E%3C/svg%3E");
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 10px) no-repeat, var(--paper-teeth) bottom / 16px 10px repeat-x;
          mask: linear-gradient(#000 0 0) top / 100% calc(100% - 10px) no-repeat, var(--paper-teeth) bottom / 16px 10px repeat-x;
}
dialog.receipt::backdrop {
  background: repeating-linear-gradient(45deg, rgba(8, 31, 99, .82) 0 10px, rgba(8, 31, 99, .74) 10px 20px);
}
dialog.receipt h3 {
  margin: 0 0 10px; text-align: center; font-size: 26px; letter-spacing: 4px; color: var(--blue);
  padding-bottom: 10px; border-bottom: 3px dashed #b8b39a;
}
dialog.receipt h4 { margin: 16px 0 6px; font-weight: 600; letter-spacing: 2px; color: var(--dim); font-size: 15px; }
dialog.receipt ul { padding-left: 18px; margin: 8px 0; }
dialog.receipt form { margin: 14px 0 0; text-align: center; }
b.far { color: #b30d14; } b.close { color: #b35f00; } b.win { color: #2c7a00; }
.center { text-align: center; }
.dim { color: var(--dim); margin: 2px 0; font-size: 15px; }
.dash { border-top: 3px dashed #b8b39a; margin: 12px 0; }
.line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 20px; }
.line b { font-size: 30px; color: var(--green); white-space: nowrap; }
.g { display: grid; grid-template-columns: 22px 1fr auto 24px; gap: 8px; font-size: 17px; }
.g .w { font-size: 13px; letter-spacing: 2px; font-weight: 700; align-self: center; }
.g.far .w, .g.far .a { color: #b30d14; } .g.close .w, .g.close .a { color: #b35f00; } .g.win .w, .g.win .a { color: #2c7a00; }
.rank { text-align: center; margin: 4px 0 6px; font-size: 22px; font-weight: 700; color: var(--blue); }
.res-art { display: flex; justify-content: center; margin: 8px 0; }
.res-art img.photo { width: 110px; height: 110px; object-fit: contain; }
.row-btns { display: flex; gap: 12px; justify-content: center; margin-top: 12px; }
.row-btns form { margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.stat-grid b { display: block; font-size: 30px; color: var(--blue); }
.stat-grid span { font-size: 13px; color: var(--dim); }
.bar { display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: center; margin: 3px 0; }
.bar i { display: block; height: 20px; min-width: 24px; background: var(--blue); color: #fff; font-style: normal; font-size: 14px; padding-left: 6px; }
.bar i.hl { background: var(--green); }

/* ---------- Sprite slots ---------- */
.sprite { image-rendering: pixelated; display: block; }
.sprite-ph {
  display: grid; place-items: center; text-align: center; white-space: pre;
  background: repeating-conic-gradient(#dbe5fb 0% 25%, #f3f7ff 0% 50%) 0 0 / 16px 16px;
  border: 3px dashed var(--blue); color: var(--blue);
  font-size: 11px; line-height: 1.1; padding: 2px; overflow: hidden;
}

.foot { text-align: center; color: var(--dim); font-size: 13px; padding: 0 16px 84px; margin-top: -64px; position: relative; }
.foot p { margin: 0; background: rgba(255, 255, 255, .75); display: inline-block; padding: 2px 8px; }

@media (max-width: 420px) {
  .logo { font-size: 23px; letter-spacing: 2px; }
  .shelf-label h2 { font-size: 21px; }
  .price-slot { font-size: 28px; }
  .store-plate { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { .tag.pop { animation: none; } }

/* ---------- Mode tabs, HUD, paywall ---------- */
.modes { display: flex; gap: 10px; margin: 0 0 16px; }
.mode {
  flex: 1; font: inherit; font-weight: 700; letter-spacing: 2px; padding: 11px 8px; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--blue); color: #fff; box-shadow: inset 0 0 0 3px var(--blue-d), 0 4px 0 var(--blue-d);
}
.mode:hover { filter: brightness(1.15); }
.mode:active { transform: translateY(3px); box-shadow: inset 0 0 0 3px var(--blue-d), 0 1px 0 var(--blue-d); }
.mode.on { background: var(--yellow); color: var(--blue); box-shadow: inset 0 0 0 3px var(--blue), 0 4px 0 var(--yellow-d); }
.lock { color: var(--yellow); } .mode.on .lock { color: var(--blue); }

.hud {
  display: flex; gap: 8px; margin: 0 0 18px; padding: 8px 12px; background: var(--paper);
  box-shadow: inset 0 0 0 3px var(--blue), 4px 4px 0 var(--blue-d);
}
.hud div { flex: 1; text-align: center; }
.hud b { display: block; font-size: 26px; line-height: 1.1; color: var(--blue); }
.hud span { font-size: 12px; letter-spacing: 2px; color: var(--dim); }

.next-bar { margin-top: 16px; text-align: center; }
.next-bar .enter-key { background: var(--green); box-shadow: 0 6px 0 #2f7312; }
.next-bar .enter-key:hover { background: #63cc2e; }

a.enter-key { display: inline-grid; place-items: center; text-decoration: none; }
.pw-row { display: flex; gap: 10px; margin-top: 4px; }
.pw-row input {
  flex: 1; min-width: 0; font: inherit; font-size: 20px; letter-spacing: 2px; padding: 0 10px; height: 46px; border: 0; color: var(--ink); background: #fff; box-shadow: inset 0 0 0 3px var(--blue);
}

/* ---------- Daily: progress pips, store map, day result ---------- */
.pips { display: flex; justify-content: center; gap: 10px; margin: -14px 0 46px; }
.pips i {
  width: 22px; height: 22px; background: #fff; box-shadow: inset 0 0 0 3px var(--dim);
}
.pips i.win { background: var(--green); box-shadow: inset 0 0 0 3px #2f7312; }
.pips i.far { background: var(--red); box-shadow: inset 0 0 0 3px var(--red-d); }
.pips i.now { outline: 3px solid var(--blue); outline-offset: 2px; }

.play { display: block; }
.map-col { margin-top: 26px; }
.map-wrap { background: #fff; box-shadow: 0 0 0 4px var(--blue), 6px 6px 0 4px var(--blue-d); }
.map { display: block; width: 100%; height: auto; max-height: 340px; background: #dfe8f7; }
.map .land { fill: #fff6d6; stroke: var(--blue); stroke-width: 2; stroke-linejoin: round; }
.map .ring { fill: rgba(232, 20, 28, .22); stroke: #E8141C; stroke-width: 4; }
.map .pulse { fill: none; stroke: #E8141C; stroke-width: 3; transform-box: fill-box; transform-origin: center; animation: ping 1.8s ease-out infinite; }
@keyframes ping { from { opacity: .8; transform: scale(1); } to { opacity: 0; transform: scale(1.7); } }
@media (prefers-reduced-motion: reduce) { .map .pulse { animation: none; opacity: 0; } }
/* Desktop: store sign across the top, guesses on the left, the whole of Finland on the right. */
@media (min-width: 860px) {
  .store { width: min(980px, 100%); }
  .play { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; align-items: start; }
  .map-col { margin-top: 28px; position: sticky; top: 12px; }
  .map { max-height: none; }
}
.map-note { margin: 0; padding: 6px 10px; font-size: 14px; color: var(--dim); text-align: center; background: var(--paper); }

.big-score { margin: 6px 0; text-align: center; font-size: 56px; font-weight: 700; line-height: 1; color: var(--blue); }
.day-row { display: grid; grid-template-columns: 22px 1fr auto 40px; gap: 8px; font-size: 16px; align-items: baseline; margin: 5px 0; }
.day-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-row .pt { text-align: right; font-weight: 700; }
.day-row.win .ok, .day-row.win .pt { color: #2c7a00; }
.day-row.far .ok, .day-row.far .pt { color: #b30d14; }

.hist { display: flex; align-items: flex-end; gap: 2px; height: 90px; margin-top: 8px; border-bottom: 3px solid var(--blue); }
.hist i { flex: 1; min-width: 0; background: #aab8de; }
.hist i.me { background: var(--red); }
.hist-axis { display: flex; justify-content: space-between; font-size: 13px; color: var(--dim); margin-top: 2px; }

/* ---------- Fonts: pixel style only for display text ---------- */
.logo, dialog.receipt h3, .enter-key, .key-btn, .mode { font-family: var(--pixel); }
.lcd input { font-weight: 700; }
.tag .val, .price-slot, .line b, .big-score, .stat-grid b, .hud b { font-weight: 700; }

/* ---------- Test mode banner ---------- */
.testbar { position: sticky; top: 0; z-index: 50; display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; padding: 6px 12px; background: var(--orange); color: var(--ink); font-size: 14px; }
.testbar button { font: inherit; font-weight: 700; padding: 2px 8px; border: 0; background: var(--blue); color: #fff; cursor: pointer; }
.testbar .peek { flex-basis: 100%; font-weight: 600; }
#pw-email { letter-spacing: 0; font-size: 16px; }
.pw-row { margin-bottom: 8px; }
