/* Layout: one column like a phone screen. A status bar, the room stage with the creature,
   the current room's action panel and the room switcher at the bottom. Style and colours from the AleGry.pl 2.0 mockup.
   The game deliberately has a single light "paper" look, like the whole mockup. */
:root {
  --paper: #FFF7EA;
  --paper-2: #FBEBD3;
  --ink: #1D1533;
  --text-2: #574D6E;
  --card: #FFFFFF;
  --tomato: #FF5A3C;
  --tomato-dark: #C93A20;
  --tomato-light: #FFE1D9;
  --lemon: #FFD23F;
  --lemon-light: #FFF3C4;
  --mint: #20B69A;
  --mint-light: #D3F4EC;
  --plum: #7A5CFA;
  --plum-light: #E9E3FF;
  --sky: #3DB8EC;
  --sky-light: #DAF1FC;
  --night: #2A2148;
  --stroke: 3px solid var(--ink);
  --shadow: 5px 5px 0 var(--ink);
  --shadow-small: 3px 3px 0 var(--ink);
  --r: 18px;
  --r-small: 10px;
  --font-display: 'Fredoka', 'Trebuchet MS', sans-serif;
  --font-text: 'Nunito', 'Segoe UI', Verdana, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--paper); color: var(--ink); }
body {
  margin: 0;
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px 24px;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--plum); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; margin: 0; font-weight: 700; text-wrap: balance; }

.app { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

/* ---------- Header ---------- */
.bar { display: flex; align-items: center; gap: 10px; }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); margin-right: auto; min-width: 0; }
.logo svg { flex: none; width: 38px; height: 38px; }
.logo-text { font: 700 24px/1 var(--font-display); letter-spacing: -0.03em; }
.logo-text b { color: var(--tomato); }
.logo small { display: block; font: 800 12px/1.2 var(--font-text); color: var(--text-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font: 700 17px/1 var(--font-display);
  background: var(--card); border: var(--stroke); border-radius: 999px; padding: 7px 12px; box-shadow: var(--shadow-small);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chip-coins { background: var(--lemon); }
.chip-level { position: relative; overflow: hidden; }
.chip-level .xp { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--plum); width: 0; transition: width .4s; }
.btn-icon {
  width: 42px; height: 42px; display: inline-grid; place-items: center; flex: none; cursor: pointer;
  background: var(--card); border: var(--stroke); border-radius: 50%; box-shadow: var(--shadow-small); font-size: 19px; padding: 0;
}
.btn-icon:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 17px/1 var(--font-display);
  background: var(--tomato); color: #fff;
  border: var(--stroke); border-radius: 999px;
  padding: 12px 20px; box-shadow: var(--shadow-small);
  cursor: pointer; text-decoration: none;
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: var(--shadow-small); }
.btn-light { background: var(--card); color: var(--ink); }
.btn-lemon { background: var(--lemon); color: var(--ink); }
.btn-mint { background: var(--mint); color: #fff; }
.btn-night { background: var(--night); color: #fff; }
.btn-small { font-size: 15px; padding: 8px 14px; }

/* ---------- Daily reward ---------- */
.reward {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--lemon); border: var(--stroke); border-radius: var(--r); box-shadow: var(--shadow-small); padding: 10px 14px;
  font-weight: 800;
}
.reward span { flex: 1 1 180px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.meter { background: var(--card); border: var(--stroke); border-radius: var(--r-small); padding: 6px 8px 8px; min-width: 0; }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; font-size: 12px; font-weight: 800; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.meter-top b { font: 700 15px/1 var(--font-display); color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.meter-icon { font-size: 15px; }
.meter-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter-track { height: 10px; border: 2px solid var(--ink); border-radius: 999px; margin-top: 5px; background: var(--paper-2); overflow: hidden; }
.meter-bar { height: 100%; width: 50%; background: var(--mint); transition: width .5s, background-color .3s; }
.meter.medium .meter-bar { background: var(--lemon); }
.meter.low .meter-bar { background: var(--tomato); }
.meter.low { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { background: var(--tomato-light); } }
@media (max-width: 440px) {
  .meter-label { display: none; }
  .meter-top { justify-content: center; gap: 6px; }
}

/* ---------- Stage ---------- */
.stage {
  position: relative; height: clamp(300px, 52vh, 420px);
  border: var(--stroke); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden;
  background: var(--bg, var(--lemon-light));
  transition: background-color .6s;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.stage::before { /* wall: a subtle pattern */
  content: ""; position: absolute; inset: 0 0 22% 0; pointer-events: none;
  background-image: var(--pattern, none); opacity: .55;
}
.stage::after { /* floor */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 22%;
  background: var(--floor, var(--paper-2)); border-top: var(--stroke); pointer-events: none;
}
.stage[data-room="kitchen"] { --bg: var(--lemon-light); --floor: repeating-linear-gradient(90deg, #F3D9A8 0 28px, #EBCB92 28px 56px);
  --pattern: repeating-linear-gradient(0deg, transparent 0 38px, #F1DC8F 38px 40px), repeating-linear-gradient(90deg, transparent 0 38px, #F1DC8F 38px 40px); }
.stage[data-room="bathroom"] { --bg: var(--sky-light); --floor: repeating-linear-gradient(90deg, #BFE5F6 0 30px, #A9DBF2 30px 60px);
  --pattern: radial-gradient(circle at 12px 12px, #B8E2F5 5px, transparent 6px); }
.stage[data-room="bathroom"]::before { background-size: 34px 34px; }
.stage[data-room="bedroom"] { --bg: var(--plum-light); --floor: #D9CFFF;
  --pattern: repeating-linear-gradient(90deg, transparent 0 22px, #DCD3FF 22px 34px); }
.stage[data-room="playroom"] { --bg: var(--mint-light); --floor: repeating-linear-gradient(45deg, #B5EBDD 0 16px, #A3E3D2 16px 32px);
  --pattern: radial-gradient(circle at 20px 20px, #B3E9DA 7px, transparent 8px); }
.stage[data-room="playroom"]::before { background-size: 46px 46px; }
.stage[data-room="shop"] { --bg: var(--tomato-light); --floor: #F7C9BC;
  --pattern: repeating-linear-gradient(90deg, #FFD0C3 0 26px, transparent 26px 52px); }
.stage.night { --bg: var(--night); --floor: #1D1736; --pattern: radial-gradient(circle at 30px 30px, #4A3F7A 2px, transparent 3px); }
.stage.night::before { background-size: 70px 70px; opacity: 1; }
.stage.night .name { background: var(--night); color: #fff; border-color: #fff; }
.stage.sponge { cursor: grab; }

#canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.name {
  position: absolute; left: 12px; top: 12px; z-index: 3;
  background: var(--card); border: var(--stroke); border-radius: 999px; padding: 5px 12px 5px 10px;
  font: 700 16px/1.1 var(--font-display); display: flex; gap: 6px; align-items: center;
}
.name small { font: 800 12px var(--font-text); color: inherit; opacity: .75; }
.speech {
  position: absolute; z-index: 4; left: 50%; top: 14%; transform: translateX(-10%);
  max-width: min(62%, 260px); background: var(--card); border: var(--stroke); border-radius: 16px;
  padding: 8px 12px; font-weight: 800; font-size: 15px; line-height: 1.3; box-shadow: var(--shadow-small);
  animation: enter .25s ease-out;
}
.speech::after { content: ""; position: absolute; left: 18px; bottom: -11px; width: 16px; height: 16px; background: var(--card);
  border-right: var(--stroke); border-bottom: var(--stroke); transform: rotate(45deg) skew(8deg, 8deg); }
@keyframes enter { from { opacity: 0; transform: translateX(-10%) translateY(6px) scale(.92); } }

#effects { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.rise { position: absolute; font: 700 20px var(--font-display); color: var(--ink); text-shadow: 2px 2px 0 #fff; animation: rise 1.1s ease-out forwards; white-space: nowrap; }
@keyframes rise { to { transform: translateY(-60px); opacity: 0; } }
.bubble { position: absolute; width: var(--d, 18px); height: var(--d, 18px); border-radius: 50%;
  border: 2px solid #fff; background: radial-gradient(circle at 30% 30%, #fff, rgba(218,241,252,.5)); box-shadow: 0 0 0 1px rgba(61,184,236,.6);
  animation: pop 1s ease-out forwards; }
@keyframes pop { to { transform: translate(var(--dx, 0), -70px) scale(1.3); opacity: 0; } }
.drop { position: absolute; top: -20px; width: 6px; height: 14px; border-radius: 3px; background: var(--sky); animation: drop .7s linear forwards; }
@keyframes drop { to { transform: translateY(var(--h, 300px)); opacity: .3; } }
.flight { position: absolute; z-index: 5; font-size: 36px; line-height: 1; transition: transform .55s cubic-bezier(.45,-0.3,.6,1), opacity .2s .5s; pointer-events: none; }

/* ---------- Room panel ---------- */
.panel { background: var(--card); border: var(--stroke); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; min-height: 150px; }
.panel h2 { font-size: 22px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.note { font-size: 14px; color: var(--text-2); margin: 0; }

.fridge { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.food { display: flex; flex-direction: column; border: 2px solid var(--ink); border-radius: var(--r-small); overflow: hidden; background: var(--paper); }
.food-eat { all: unset; cursor: pointer; display: flex; flex-direction: column; align-items: center; padding: 8px 4px 4px; gap: 2px; position: relative; }
.food-eat:focus-visible { outline: 3px solid var(--plum); outline-offset: -3px; }
.food-eat:hover .emoji { transform: scale(1.12) rotate(-6deg); }
.food-eat[aria-disabled="true"] { cursor: default; }
.food-eat[aria-disabled="true"] .emoji { filter: grayscale(1); opacity: .4; }
.emoji { font-size: 34px; line-height: 1.1; transition: transform .15s; }
.food-label { font-size: 13px; font-weight: 800; }
.counter { position: absolute; top: 4px; right: 6px; font: 700 13px var(--font-display); background: var(--ink); color: #fff; border-radius: 999px; padding: 1px 7px; }
.food-buy { border: 0; border-top: 2px solid var(--ink); background: var(--lemon-light); font-weight: 800; font-size: 13px; padding: 5px 2px; cursor: pointer; }
.food-buy:hover { background: var(--lemon); }
.food-buy:disabled { opacity: .5; cursor: not-allowed; }

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

.minigames { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.minigame { border: 2px solid var(--ink); border-radius: var(--r-small); padding: 10px; display: flex; flex-direction: column; gap: 6px; background: var(--paper); }
.minigame h3 { font-size: 18px; display: flex; gap: 6px; align-items: center; }
.minigame p { margin: 0; font-size: 14px; color: var(--text-2); flex: 1; }
.minigame .record { font-size: 13px; font-weight: 800; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 999px; padding: 3px; }
.tabs button { border: 0; background: transparent; border-radius: 999px; padding: 6px 12px; font-weight: 800; font-size: 14px; cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.shelves { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.product { border: 2px solid var(--ink); border-radius: var(--r-small); padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; background: var(--paper); }
.product.worn { background: var(--mint-light); }
.product-swatch { width: 38px; height: 38px; border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%; border: 3px solid var(--ink); }
.product .label { font-weight: 800; font-size: 14px; line-height: 1.2; }
.product .desc { font-size: 12px; color: var(--text-2); }

/* ---------- Rooms ---------- */
.rooms { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; position: sticky; bottom: max(8px, env(safe-area-inset-bottom, 0px)); z-index: 6; }
.rooms button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
  background: var(--card); border: var(--stroke); border-radius: var(--r-small); padding: 6px 2px; box-shadow: var(--shadow-small);
  font: 700 13px/1.1 var(--font-display);
}
.rooms button span:first-child { font-size: 22px; line-height: 1.1; }
.rooms button[aria-current="true"] { background: var(--lemon); transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }

/* ---------- Modal (mini games, settings) ---------- */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(29,21,51,.55); display: grid; place-items: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); }
.modal-card { width: min(100%, 480px); max-height: 100%; overflow: auto; background: var(--paper); border: var(--stroke); border-radius: var(--r); box-shadow: var(--shadow); }
.modal-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; background: var(--mint-light); border-bottom: var(--stroke); }
.modal-top h2 { font-size: 21px; }
.modal-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.game-score { display: flex; justify-content: space-between; font-weight: 800; font-variant-numeric: tabular-nums; }
#catch-canvas { width: 100%; aspect-ratio: 3 / 4; max-width: 100%; max-height: 60vh; display: block; margin: 0 auto; border: var(--stroke); border-radius: var(--r-small); background: var(--sky-light); touch-action: none; }
.pairs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pair-card { aspect-ratio: 1; max-width: 100%; border: var(--stroke); border-radius: var(--r-small); background: var(--plum); cursor: pointer; font-size: clamp(24px, 8vw, 38px); display: grid; place-items: center; padding: 0; box-shadow: var(--shadow-small); }
.pair-card.revealed { background: var(--card); }
.pair-card.matched { background: var(--mint-light); box-shadow: none; transform: translate(2px,2px); }
.pair-card:not(.revealed) span { visibility: hidden; }
.simon { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 320px; margin: 0 auto; width: 100%; }
.simon button { aspect-ratio: 1; max-width: 100%; border: var(--stroke); border-radius: 22px; cursor: pointer; box-shadow: var(--shadow-small); opacity: .55; transition: opacity .1s, transform .1s; font-size: 34px; }
.simon button.lit { opacity: 1; transform: scale(1.04); }
.simon button:disabled { cursor: default; }
.summary { text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.summary .big { font: 700 40px/1 var(--font-display); }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 800; font-size: 14px; }
.field input { font: 700 18px var(--font-display); padding: 8px 12px; border: var(--stroke); border-radius: var(--r-small); background: var(--card); color: var(--ink); }
.facts { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 14px; }
.facts b { font-family: var(--font-display); font-size: 17px; display: block; }
.warning { background: var(--tomato-light); border: 2px solid var(--tomato-dark); border-radius: var(--r-small); padding: 10px; display: flex; flex-direction: column; gap: 8px; font-weight: 700; }

.footer { text-align: center; font-size: 13px; color: var(--text-2); margin: 4px 0 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
