/* Oasis Bloom — tokens, type, layout. 8 px grid. */
@font-face { font-family: 'PlexUI'; font-weight: 400; font-display: swap; src: url(../fonts/plex-400-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2010-2027, U+2030-205E, U+20AC; }
@font-face { font-family: 'PlexUI'; font-weight: 600; font-display: swap; src: url(../fonts/plex-600-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2010-2027, U+2030-205E, U+20AC; }
@font-face { font-family: 'PlexUI'; font-weight: 700; font-display: swap; src: url(../fonts/plex-700-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2010-2027, U+2030-205E, U+20AC; }
@font-face { font-family: 'PlexUI'; font-weight: 400; font-display: swap; src: url(../fonts/plex-400-arabic.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'PlexUI'; font-weight: 600; font-display: swap; src: url(../fonts/plex-600-arabic.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'PlexUI'; font-weight: 700; font-display: swap; src: url(../fonts/plex-700-arabic.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }

:root {
  --sand-0: #FFFCF6; --sand-50: #FBF4E6; --sand-100: #F4E6C8; --sand-200: #EAD6AE; --sand-300: #DCC08C;
  --ink: #2B1D12; --ink-2: #6B5541; --ink-3: #9C8668;
  --teal: #12827F; --teal-d: #0C6A67; --saffron: #F2B23A; --rose: #E0607A; --palm: #3F8A3A; --palm-l: #E3F1DA;
  --r-s: 12px; --r-m: 16px; --r-l: 24px;
  --shadow: 0 2px 0 rgba(120, 84, 40, .14), 0 6px 16px rgba(120, 84, 40, .10);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --ease-out: cubic-bezier(.2, .9, .3, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sand-100); color: var(--ink); }
body { font-family: 'PlexUI', system-ui, sans-serif; font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
html[dir=rtl] body { line-height: 1.7; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
img { display: block; }
b, strong { font-weight: 700; }
.ic { width: 24px; height: 24px; flex: none; }
[hidden] { display: none !important; }

/* ---- layout ---- */
#app { position: fixed; inset: 0; display: flex; }
#play { position: relative; flex: 1; display: flex; flex-direction: column; min-width: 0; padding-top: var(--safe-t);
  background: radial-gradient(120% 60% at 50% 0%, var(--sand-50), var(--sand-100) 70%); }
#top { display: flex; align-items: center; gap: 8px; padding: 8px 16px; height: 56px; flex: none; }
#orders { display: flex; gap: 8px; padding: 4px 16px 8px; flex: none; min-height: 112px; }
#boardWrap { flex: 1; min-height: 0; display: flex; align-items: flex-start; justify-content: center; padding: 16px 12px 0; }
#board { position: relative; width: 100%; height: 100%; max-width: 504px; touch-action: none; }
#nav { flex: none; display: flex; justify-content: space-around; padding: 8px 8px calc(8px + var(--safe-b)); }

#oasisPane { position: fixed; inset: 0; z-index: 20; display: none; background: var(--sand-200); }
#oasisPane.open { display: block; }
#oasis { position: absolute; inset: 0; overflow: hidden; }
#oasisBack { position: absolute; top: calc(12px + var(--safe-t)); inset-inline-start: 16px; z-index: 3; }
html[dir=rtl] #oasisBack .ic { transform: scaleX(-1); }

#app.wide #oasisPane { position: relative; display: block; flex: 1; z-index: 1; }
#app.wide #oasisBack { display: none; }
#app.wide #play { flex: none; width: 480px; box-shadow: -1px 0 0 rgba(120, 84, 40, .15); }
#app.wide #nav [data-k=oasis] { display: none; }

#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 40; }
.fly { position: fixed; left: 0; top: 0; z-index: 45; pointer-events: none; filter: drop-shadow(0 4px 6px rgba(80, 50, 20, .25)); }
.float-text { position: fixed; z-index: 46; pointer-events: none; font-weight: 700; font-size: 18px; color: var(--ink);
  background: var(--sand-0); padding: 4px 12px; border-radius: 999px; box-shadow: var(--shadow); white-space: nowrap; }
.float-text.warn { color: #9B3B22; }
.float-text.good { color: var(--palm); }

/* ---- board: a carved clay frame, glazed sand tiles, soft light from the top left ---- */
#board .frame, #board .tiles, #board .items { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); }
#board .frame { width: calc(var(--cell) * 7 + 16px); height: calc(var(--cell) * 9 + 16px); top: 0; border-radius: 24px;
  background: linear-gradient(160deg, #EBCB91 0%, #D9AE6C 55%, #C99A58 100%);
  box-shadow: inset 0 2px 0 rgba(255, 244, 214, .7), inset 0 -3px 0 rgba(120, 78, 30, .25), 0 2px 0 rgba(120, 78, 30, .18), 0 14px 28px rgba(120, 84, 40, .22); }
#board .tiles { display: grid; grid-template-columns: repeat(7, var(--cell)); grid-auto-rows: var(--cell); border-radius: 17px; overflow: hidden;
  background: #C9A066; box-shadow: inset 0 2px 6px rgba(90, 55, 15, .45); }
#board .tiles::before, #board .tiles::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 2; }
#board .tiles::before { background: radial-gradient(120% 80% at 18% 8%, rgba(255, 250, 230, .38), rgba(255, 250, 230, 0) 55%), radial-gradient(90% 70% at 90% 100%, rgba(110, 70, 25, .16), rgba(110, 70, 25, 0) 60%); }
#board .tiles::after { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .32 0 0 0 0 .16 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E") 0 0 / 120px 120px; opacity: .22; mix-blend-mode: multiply; }
.tile { position: relative; margin: 1.5px; border-radius: 11px; background: linear-gradient(155deg, #FBF1DC, #F2E2C2);
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, .75), inset 0 -2px 0 rgba(170, 125, 60, .16), inset 0 0 0 1px rgba(170, 125, 60, .06); transition: background .15s, box-shadow .15s; }
.tile.b { background: linear-gradient(155deg, #F6E8CB, #EBD6AE); }
.tile.sand { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M4 17c6-5 12-5 18 0s10 4 14 1M2 27c7-5 14-5 20 0s10 4 16 0' fill='none' stroke='%23C9A867' stroke-width='2.2' stroke-linecap='round' opacity='.5'/%3E%3C/svg%3E") center / 78% no-repeat, linear-gradient(160deg, #E8CD96, #D8B678);
  box-shadow: inset 0 -3px 0 rgba(150, 110, 50, .16), inset 0 2px 0 rgba(255, 245, 220, .45); }
.tile.sel { box-shadow: inset 0 0 0 3px var(--teal), inset 0 1.5px 0 rgba(255, 255, 255, .75); background: linear-gradient(155deg, #F1FBF8, #DDF0EB); }
.tile.hover { background: linear-gradient(155deg, #FFF8E8, #FBEBC8); }
.tile.target { background: linear-gradient(155deg, #FFF4D2, #FBE3A2); box-shadow: inset 0 0 0 2px rgba(242, 178, 58, .75), inset 0 1.5px 0 rgba(255, 255, 255, .8); animation: tgt 1s ease-in-out infinite; }
.tile.snap { background: linear-gradient(155deg, #FFF0BF, #F8D57E); box-shadow: inset 0 0 0 3px var(--saffron), 0 0 14px rgba(242, 178, 58, .7); animation: none; }
@keyframes tgt { 50% { box-shadow: inset 0 0 0 3px rgba(242, 178, 58, .95), inset 0 1.5px 0 rgba(255, 255, 255, .8); } }
.tile.hint::after { content: ''; position: absolute; inset: -1px; border-radius: 12px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .9), 0 0 12px rgba(242, 178, 58, .8); opacity: 0; animation: hintGlow 1.6s ease-in-out; }
@keyframes hintGlow { 25%, 75% { opacity: 1; } 50% { opacity: .35; } }

/* items: a contact shadow on the tile, the sprite breathing gently above it */
.it { position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell); will-change: transform; z-index: 1; }
.it > .sp { position: absolute; inset: 6%; width: 88%; height: 88%; object-fit: contain; pointer-events: none; transform-origin: 50% 88%;
  animation: breath 3.2s ease-in-out var(--d, 0s) infinite; }
.it > .sh { position: absolute; left: 22%; right: 22%; bottom: 7%; height: 13%; border-radius: 50%; background: radial-gradient(closest-side, rgba(95, 60, 20, .32), rgba(95, 60, 20, 0));
  animation: shadowBreath 3.2s ease-in-out var(--d, 0s) infinite; pointer-events: none; }
@keyframes breath { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-3.5%) scale(1.025, 1.035); } }
@keyframes shadowBreath { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.86); opacity: .75; } }
.it.press > .sp { transform: scale(.9, .94); animation: none; transition: transform 60ms ease-out; }
.it.drag { z-index: 10; transition: none; }
.it.drag > .sp { animation: none; filter: drop-shadow(0 14px 10px rgba(80, 50, 20, .32)); }
.it.drag > .sh { opacity: 0; animation: none; }
.it.ghost { z-index: 9; pointer-events: none; }
.it.target > .sp { animation: tgtItem .9s ease-in-out infinite; }
@keyframes tgtItem { 50% { transform: scale(1.07); } }
.it.gen { z-index: 2; }
.it.gen > .sp { inset: -2%; width: 104%; height: 104%; animation: genIdle 2.6s ease-in-out var(--d, 0s) infinite; }
.it.gen > .sh { left: 16%; right: 16%; bottom: 3%; height: 15%; animation: none; }
.it.gen > .glow { position: absolute; inset: -14%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 236, 170, .95), rgba(255, 220, 120, .45) 45%, rgba(255, 220, 120, 0) 72%);
  animation: genGlow 2.6s ease-in-out infinite; }
#board.dry .it.gen > .glow { animation: none; opacity: 0; }
#board.dry .it.gen > .sp { filter: saturate(.55) brightness(.96); animation: none; }
@keyframes genGlow { 0%, 100% { opacity: .55; transform: scale(.92); } 50% { opacity: 1; transform: scale(1.05); } }
@keyframes genIdle { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-3%) scale(1.03, .98); } }
.it.sandy > .sp, .it.sandy > .sh { display: none; }
.it .sand { display: none; }
.it .ok { position: absolute; right: 2px; bottom: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--palm); border: 2px solid #fff; display: none; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.it .ok::after { content: ''; position: absolute; left: 4px; top: 2px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.it.need .ok { display: block; }
#app.picking .it:not(.gen):not(.sandy) > .sp { animation: pickPulse 1s ease-in-out infinite; }
@keyframes pickPulse { 50% { transform: scale(1.08); filter: drop-shadow(0 0 8px rgba(242, 178, 58, .9)); } }
.fly.orb { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #FFFBE6, #F7C64A 55%, #E39A1E); box-shadow: 0 0 10px rgba(247, 198, 74, .9); filter: none; }

/* dock under the board: the power tray, swapped for the item info when something is selected */
#dock { position: relative; flex: none; height: 72px; margin: 8px 16px 0; }
#tray, #info { position: absolute; inset: 0; transition: opacity .16s ease-out, transform .2s var(--ease-out); }
#info { opacity: 0; transform: translateY(8px); pointer-events: none; }
#dock.info #info { opacity: 1; transform: none; pointer-events: auto; }
#dock.info #tray { opacity: 0; transform: translateY(-6px); pointer-events: none; }
#tray { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 0 8px; border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 252, 244, .75), rgba(250, 238, 212, .75)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8), 0 1px 0 rgba(150, 110, 50, .12); }
.pw { position: relative; width: 44px; height: 56px; display: grid; place-items: center; }
.pw .pwi { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(160deg, #FFFDF7, #F5E7C9);
  box-shadow: 0 2px 0 rgba(150, 105, 45, .2), 0 4px 10px rgba(120, 84, 40, .12), inset 0 1px 0 #fff; transition: transform .1s ease-out, box-shadow .1s; }
.pw img { width: 34px; height: 34px; object-fit: contain; }
.pw:active .pwi { transform: translateY(2px) scale(.95); box-shadow: 0 0 0 rgba(150, 105, 45, .2), 0 2px 6px rgba(120, 84, 40, .12), inset 0 1px 0 #fff; }
.pw em { position: absolute; top: 2px; inset-inline-end: -2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--teal); color: #fff;
  font: 700 12px/20px 'PlexUI', system-ui, sans-serif; font-style: normal; text-align: center; box-shadow: 0 0 0 2px var(--sand-0); }
.pw.none .pwi { filter: saturate(.3); opacity: .7; }
.pw.none em { background: var(--saffron); color: var(--ink); }
.pw.on .pwi { box-shadow: 0 0 0 3px var(--saffron), 0 0 16px rgba(242, 178, 58, .7); transform: translateY(-3px); }

body.reduce *, body.reduce *::before { animation-duration: 0s !important; }
